Verse Library verse

01 Device

Waits for a perfect target hit and grants a reward item to the interacting agent.

verse-library/skilled-interaction-device-design-examples/01-device.verse

# This is a comment. It explains the code to humans.
# We are making a script for our Target Device.

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

# This is our main script. It acts as a creative_device
# and holds references to the two devices we placed in the editor.
target_practice_script := class(creative_device):

    # These are the two devices we placed in the editor.
    # Assign them in the Details panel in UEFN.
    @editable
    TargetDevice : skilled_interaction_device = skilled_interaction_device{}

    @editable
    PrizeBox : item_granter_device = item_granter_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # We wait for the player to interact with the target.
        # 'InteractedWithPerfectEvent' fires when someone hits the Perfect zone.
        # 'InteractedWithGoodEvent' fires when someone hits the Good zone.
        loop:
            # Block here until the Perfect zone is triggered.
            Agent := TargetDevice.InteractedWithPerfectEvent.Await()
            # If it was a perfect hit, we give the prize!
            PrizeBox.GrantItem(Agent)

Comments

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