Verse Library verse

01 Device

Implements a device that increments a score variable when players enter a trigger and updates a HUD display.

verse-library/rubric/01-device.verse

# This is a comment. It helps us remember what the code does.

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

# We define our scorekeeper as a Verse device so it can
# live on the island and talk to other UEFN devices.
scorekeeper_device := class(creative_device):

    # Drag your Trigger Volume here in the UEFN Details panel.
    @editable
    MyTrigger : trigger_device = trigger_device{}

    # Drag your HUD Message Device here in the UEFN Details panel.
    # hud_message_device shows text on screen for a player.
    # Replace this with your actual device reference.
    @editable
    MyHUD : hud_message_device = hud_message_device{}

    # We create a variable named 'Score'.
    # It starts at 0. It is an integer (a whole number).
    # 'var' means the value is allowed to change.
    var Score : int = 0

    # OnBegin runs automatically when the game starts.
    OnBegin<override>()<suspends> : void =
        # We tell the trigger to call our function
        # whenever a player enters it.
        MyTrigger.TriggeredEvent.Subscribe(OnPlayerEntered)

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