# This is a Verse Script. It lives inside a device on your map. # Think of this script as the "brain" of your dispenser. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Players } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a "Device" class. This is the blueprint for our dispenser. # In the Scene Graph, this device is a node that holds our logic. dispenser_device := class(creative_device): # --- VARIABLES: The "Loot Box" --- # A reference to the button device placed on your map. # In the UEFN Outliner, set this property to point at your button_device. @editable DispenserButton : button_device = button_device{} # A reference to the item granter device that actually hands items to players. # Place an item_granter_device on your map, configure its item in the UEFN # Details panel (e.g. Launchpad, Port-A-Fort, Repair Torch), then wire it here. # Change which device you point at to change the loot — no code edits needed! @editable ItemGranter : item_granter_device = item_granter_device{} # --- FUNCTIONS: The "Combo Moves" --- # This function takes a player and tells the item granter to give them the item. # It's like a vending machine: Insert Coin (Player) -> Get Snack (Item). GivePortableItem(Agent : agent) : void = # item_granter_device.GrantItem requires an agent, which every player is. # This is like pulling the specific can of soda from the shelf and handing it over. ItemGranter.GrantItem(Agent) # Optional: log a message to the UEFN Output Log so you know it fired. # note: player.PrintToScreen does not exist in Verse; Print() writes to the log. Print("Dispenser: item granted to agent.") # --- EVENTS: The "Storm Timer" --- # OnBegin runs once when the level starts. # It's like the match starting — we set up our triggers here. OnBegin() : void = # Connect the button's InteractedWithEvent to our function. # When the button is pressed, run GivePortableItem with the agent who pressed it. # This is the core loop: Press -> Trigger -> Action. DispenserButton.InteractedWithEvent.Subscribe(GivePortableItem)