# This is a Verse script for a grenade dispenser. # It gives a player a grenade when they use a device. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script block. # It holds all the code for our dispenser. grenade_dispenser := class(creative_device): # 'ItemGranter' is a item_granter_device placed in your scene. # Connect it in the UEFN editor's details panel. # note: Verse has no direct GiveItem() API on player; item_granter_device is the correct way to grant items. @editable ItemGranter : item_granter_device = item_granter_device{} # OnBegin runs when the island starts. # We subscribe to the item granter's activation here. OnBegin() : void = # We print a message to the console. # This helps us know the device started correctly. Print("Grenade dispenser is ready!") # This function is called by a button_device or switch # wired to this device via the UEFN event binding panel. # 'Agent' is the person who flipped the switch. OnPlayerUsed(Agent : agent) : void = # We tell the item granter to give its configured item to the agent. # Set the item granter's item to "Grenade" in the UEFN editor. ItemGranter.GrantItem(Agent) # We print a message to the console. # This helps us know it worked. Print("A grenade was granted!")