Verse Library verse

03 Fragment

Enables a trap twice with a one-second delay when a player activates a button.

verse-library/verse-functions-and-when-to-use-them-in-a-fortnite-island/03-fragment.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

device ButtonTrapController : creative_device {

    @editable
    Trap : trap_device = trap_device{}

    @editable
    Button : button_device = button_device{}

    OnBegin<override>()<suspends> : void = {
        Button.InteractedWithEvent.Subscribe(FireTheTrapTwice)
    }

    # The <suspends> modifier lets this function use Sleep().
    FireTheTrapTwice(Presser : agent)<suspends> : void = {
        # First boom!
        Trap.Enable()
        Print("First boom!")

        # Wait 1 second before the second boom.
        Sleep(1.0)

        # Second boom!
        Trap.Enable()
        Print("Second boom!")
    }
}

Comments

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