using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script. It controls the rewards. treasure_hunt := class(creative_device): # This is the Item Granter. It holds the Gold. @editable ItemGranter : item_granter_device = item_granter_device{} # This is the HUD Message. It shows text. @editable HudMessage : hud_message_device = hud_message_device{} # This is the Trigger. It watches for players. @editable Trigger : trigger_device = trigger_device{} # This runs when the game starts. OnBegin() : void = # Connect the trigger to our reward logic. # When the trigger fires, run GiveReward. Trigger.TriggeredEvent.Subscribe(GiveReward) # This function gives the reward. GiveReward(Agent : ?agent) : void = # 1. Grant items via the Item Granter device. # The item_granter_device is pre-configured in the World Editor # with the item and quantity you want to give (e.g. 10 Gold). # GrantRandomItem gives the next item the device is holding. # note: item_granter_device has no runtime quantity API; set the # item and stack size in the device's properties panel instead. if (A := Agent?): ItemGranter.GrantItem(A) # 2. Show a message on the screen. # We use the HUD Message device. HudMessage.Show(A)