Verse Library verse

01 Device

Spawns items continuously when a switch is activated, preventing game freezes with a short delay loop.

verse-library/continuous-item-spawning/01-device.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is our main script block.
# It connects our devices.
snack_machine := class(creative_device):

    # These properties are set in the UEFN editor.
    # Drag your Item Spawner device into MySpawner.
    # Drag your Switch device into MySwitch.
    @editable
    MySpawner : item_spawner_device = item_spawner_device{}

    @editable
    MySwitch : switch_device = switch_device{}

    # This is the main function.
    # It runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # Wait for the switch to be turned on.
        # This is like waiting for the player to flip the switch.
        MySwitch.TurnedOnEvent.Await()

        # Start an infinite loop.
        # This keeps running forever.
        loop:
            # Wait for a tiny moment.
            # This gives the game time to catch up.
            # Without this, the game might freeze.
            Sleep(0.1)

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in