# This is our main script file. # It connects a trigger to a reward. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a new "Actor". # An Actor is a thing in our game world. # Think of it like a character or a prop. rusty_can_trap := class(creative_device): # This is our Trigger Volume. # It watches for players. # Wire this in the UEFN editor Details panel. @editable Trigger : trigger_device = trigger_device{} # This is our Item Granter. # It gives the item. # Wire this in the UEFN editor Details panel. @editable Granter : item_granter_device = item_granter_device{} # OnBegin runs once when the game starts. # We use it to subscribe to the trigger's overlap event. OnBegin() : void = # TriggeredEvent fires whenever any agent steps inside. # We pass our handler function to be called each time. Trigger.TriggeredEvent.Subscribe(OnTriggered) # This function runs when a player steps in. # Agent is the game's word for a player or NPC. OnTriggered(Agent : agent) : void = # We tell the granter to give its configured item. # The item type is set in the UEFN editor, not in code. # note: item_granter_device.GrantItem takes an agent, not a string. Granter.GrantItem(Agent)