# This is our main script file. # It connects the button to the item dispenser. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We define a new "Thing" called CuddleDispenser. # A "Thing" is a container for our code. # creative_device is the real base class for island scripts in Verse. cuddle_dispenser := class(creative_device): # This is the button player will press. # We link it to the Button device in the editor. @editable MyButton : button_device = button_device{} # This is the device that gives the item. # We link it to the Grant Item device. @editable MyGranter : item_granter_device = item_granter_device{} # This function runs when the game starts. # It sets up the connection. OnBegin() : void = # We wait for the button to be pressed. # When it is pressed, we run the "GiveItem" function. MyButton.InteractedWithEvent.Subscribe(GiveItem) # This function actually gives the item. # InteractedWithEvent passes the agent (player) who pressed the button. GiveItem(Agent : agent) : void = # The "Agent" is the player who pressed the button. # We tell the granter to give an item to that player. MyGranter.GrantItem(Agent)