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.") # This runs once when the game starts. # We "listen" for the trigger volume event. listen(on_player_touches_potion)