Verse Library verse

01 Device

Adds twenty-five health points to any player entering a specific trigger zone.

verse-library/using-restorative-items-in-fortnite-creative/01-device.verse

# This is our healing pizza script!
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# We tell Verse which device we are using.
# This is like giving the script a name tag.
healing_pizza_manager := class(creative_device):

    # We connect to a Trigger device placed in the world.
    # The Trigger fires when a player walks into its zone.
    @editable
    HealTrigger : trigger_device = trigger_device{}

    # This is the main function.
    # It runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # We subscribe to the TriggeredEvent so we know
        # when a player walks into the trigger zone.
        HealTrigger.TriggeredEvent.Subscribe(OnPlayerEntered)

    # This function runs every time a player enters the trigger.
    OnPlayerEntered(Agent : agent) : void =
        # We need to turn the agent into a fort_character
        # so we can change their health.
        # note: GetFortCharacter() returns an option type; we use 'if' to unwrap it safely.
        if (Character := Agent.GetFortCharacter[]):
            # Then we heal them!

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