Verse Library verse

01 Fragment

Uses a Tracker Device to decrement item counts when players interact, managing resource dispensing.

verse-library/decrement/01-fragment.verse

using { /Fortnite.com/Devices }

# This is our main "Brain" script. 
# Think of it as the game rulebook for this specific dispenser.
dispenser_brain := script():
    # We need references to the devices in our level.
    # 'tracker' is the Tracker Device we placed in the editor.
    # 'potion' is the Prop Mover holding the potion.
    tracker: TrackerDevice = TrackerDevice{ }
    potion: PropMover = PropMover{ }

    # This is the "Event" that fires when a player touches the potion.
    # In Fortnite, this is like a Trigger Volume.
    on_player_touches_potion := func(trigger: TriggerVolume):
        # STEP 1: Check if we still have potions left.
        # The Tracker's "Current Value" tells us how many are left.
        if tracker.Get_Current_Value() > 0:
            
            # STEP 2: DECREMENT!
            # This is the magic line. We lower the tracker by 1.
            # If it was 1, it becomes 0. If it was 5, it becomes 4.
            tracker.Decrement()

            # STEP 3: Give the player the potion (Heal them).
            # For this demo, we'll just move the potion away to show it's "used."
            potion.Set_Position(vector{0, 0, 0}) # Moves it to the ground (or wherever)

            print("Potion taken! Dispenser is now empty.")
        else:
            print("Dispenser is empty! Go find another one.")

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