using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We define our own "Flopper Dispenser" device. # Think of this as the blueprint for our Loot Box. flopper_dispenser_device := class(creative_device): # VARIABLES: These are the settings you can change in the UE Editor panel. # This is like setting the "Damage" on a trap, but here we set which # item-granter device hands out the Flopper. # We wire a item_granter_device in the editor — it is pre-configured # with the Flopper type you want (e.g. Snowy Flopper). @editable FlopperGranter : item_granter_device = item_granter_device{} # We also need a trigger_device to detect the player walking in. # Wire this to your Trigger Volume in the editor. @editable EntranceTrigger : trigger_device = trigger_device{} # OnBegin runs once when the game session starts. # We use it to subscribe to the trigger's event — like plugging # the doorbell wire into the chime. OnBegin() : void = # Subscribe: whenever the trigger fires, call OnPlayerEntered. EntranceTrigger.TriggeredEvent.Subscribe(OnPlayerEntered) # This function fires every time the trigger activates. # 'Agent' is whoever set it off — could be a player. OnPlayerEntered(Agent : agent) : void = # 1. Check if the agent is a Fortnite player character. # cast to fort_playspace_character gives us access to player actions. # note: agent is already the correct type for GrantItem; we cast # purely to confirm this is a real player and not an NPC/prop. if (Player := agent as fort_character): # 2. Use the pre-configured item_granter_device to hand the # Flopper directly to the player's inventory. # item_granter_device handles slot-availability internally: # if inventory is full it will not grant the item. FlopperGranter.GrantItem(agent) # 3. Feedback — print to the Verse log so you can verify # in the Output Log tab that the grant was attempted. Print("Flopper dispensed to player!") else: # Whatever entered the trigger was not a player — ignore it. Print("Non-player entered trigger, ignoring.")