using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # CuddleDispenser: a creative_device that wires a trigger_device # to an item_granter_device so stepping on the trigger hands out loot. cuddle_dispenser := class(creative_device): # This is a "Variable". # Think of a variable as a loot box. # It starts empty, but we will fill it with the Item Granter. # Tag this with @editable so UEFN shows it in the Details panel — # that is where you drag-and-drop your Item Granter device to link it. @editable Granter : item_granter_device = item_granter_device{} # This is a "Variable" for the Trigger device. # Same idea: tag it @editable and assign it in the Details panel. @editable MyTrigger : trigger_device = trigger_device{} # OnBegin is called automatically when the island starts. # Think of it as the "Match Start" whistle — it runs once, # and we use it to subscribe to the trigger's overlap event. OnBegin() : void = # Subscribe means: "Watch for this event and call my handler." # TriggeredEvent fires whenever a player steps on the trigger. MyTrigger.TriggeredEvent.Subscribe(OnPlayerTriggered) # This is a "Function". # Think of a function as a specific move in Fortnite, like "Vault" or "Peek". # It's a block of instructions that happens when called. # TriggeredEvent passes the agent (the player) who activated the trigger. OnPlayerTriggered(TriggeredAgent : ?agent) : void = # Cast agent to fort_character so we can confirm it is a real player. # If the cast fails (e.g. an NPC), the if-block is skipped safely. if (ActualAgent := TriggeredAgent?, Player := ActualAgent.GetFortCharacter[]): # GrantItem tells the Item Granter to give its configured item # to this specific player — like pressing "Equip" in your inventory. Granter.GrantItem(ActualAgent)