Verse Library verse

01 Device

Runs a loop of explosions at a player's location when they activate a trigger device.

verse-library/introduction-to-loops/01-device.verse

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

# This is our main device. It attaches to a trigger_device placed in the level.
chaos_explosion_device := class(creative_device):

    # CONFIGURATION
    # How many explosions do we want at most?
    # Change this value in the UEFN details panel.
    @editable
    ExplosionCount : int = 5

    # The trigger device wired to this script (drag it in via the UEFN details panel).
    @editable
    Trigger : trigger_device = trigger_device{}

    # This runs when the game starts
    OnBegin<override>()<suspends> : void =
        # Subscribe to the trigger's TriggeredEvent so we react when a player steps on it.
        Trigger.TriggeredEvent.Subscribe(OnTriggered)

    # This runs when a player activates the trigger.
    # trigger_device passes an optional agent; we accept it as ?agent.
    OnTriggered(Agent : ?agent) : void =
        # Unwrap the agent; do nothing if no agent was provided.
        if (A := Agent?):

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