Verse Library verse

01 Fragment

Links a trigger to an item granter. Fires loot when players activate the device.

verse-library/3-add-devices/01-fragment.verse

using { /Fortnite.com/Devices }

# This is our main script. Think of it as the brain of the island.
ChaosButton = script() override {
    # 1. DEFINE THE DEVICES
    # We are creating two variables: one for the Trigger, one for the Granter.
    # These act as the "plugs" we will connect in the editor.
    trigger_device: Device = Device{}
    granter_device: Device = Device{}

    # 2. THE MAIN LOOP
    # This function runs forever once the game starts.
    Run() = async {
        # We wait here until the trigger device is activated.
        # 'trigger_device.Activated' is an event.
        # 'await' means "pause the code until this happens."
        await trigger_device.Activated

        # 3. DO THE THING
        # Now that the trigger was pressed, we tell the granter to fire.
        # 'Fire()' is a function (a command) that makes the item granter drop loot.
        granter_device.Fire()
        
        # Optional: Reset the trigger so it can be pressed again?
        # For this simple demo, we'll just let it be a one-time chaos button.
    }
}

# This line tells the game to start our ChaosButton script.
ChaosButton{}

Comments

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