Verse Library verse

01 Device

Spawns a healing item from a configured spawner when a player enters a trigger zone.

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

# This is our healing station script
# It runs when the game starts

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

healing_station := class(creative_device):

    # We connect the Item Spawner device in the editor
    # Drag your Item Spawner into this property slot
    @editable
    HealingBox : item_spawner_device = item_spawner_device{}

    # We connect the Trigger device in the editor
    # Drag your Trigger into this property slot
    @editable
    HealingButton : trigger_device = trigger_device{}

    # OnBegin runs automatically when the game starts
    OnBegin<override>()<suspends> : void =
        # We tell the trigger what to do when a player enters
        # A trigger is like a sensor that watches for players
        HealingButton.TriggeredEvent.Subscribe(OnPlayerHeals)

    # This function runs when someone hits the button
    # We tell the Item Spawner to spawn the item
    OnPlayerHeals(Agent : ?agent) : void =
        # We call SpawnItem on the Item Spawner device
        # The spawner already knows which item to give

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