Verse Library verse

01 Fragment

Traps that detect player entry and validate inventory before granting rewards.

verse-library/fortnite-basic-count-up-timer-using-nested-if-statements/01-fragment.verse

# loot_goblin_trap.verse
using { /Verse.org/Simulation }
using { /Fortnite.com/Devices }

# This is our main "Entity" (the script object itself).
# Think of it as the brain of the trap.
class LootGoblinTrap extends creative_device:

    # @editable means you can drag-and-drop devices into this slot in UEFN.
    # We need the Trigger to know when someone walks in.
    @editable
    TriggerZone : trigger_zone_device = trigger_zone_device{}

    # We need the Item Granter to give the loot.
    @editable
    AmmoBox : item_granter_device = item_granter_device{}

    # A variable to store the player who entered.
    # 'optional_player' means it might be empty (no player).
    var entered_player : optional_player = None

    # This function runs when the game starts.
    OnBegin<override>()<suspends>: void =
        # Connect the trigger's "OnActorBeginOverlap" event to our function.
        # This means: "Whenever something enters the zone, run CheckEntry."
        TriggerZone.OnActorBeginOverlap.Bind(
            fun(actor: actor): void =
                CheckEntry(actor)
        )

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