using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script block MyVendingMachineScript := class(creative_device): # 1. Link the devices here # We need to connect the Button and the Vending Machine @editable my_button: button_device = button_device{} @editable my_shop: vending_machine_device = vending_machine_device{} # 2. The "On Begin Play" event # This runs once when the island starts OnBegin(): void = Print("Game starting! Shop is closed.") # Subscribe to the button's interaction event # InteractedWithEvent fires when a player presses the button my_button.InteractedWithEvent.Subscribe(OnInteract) # 3. The "On Interact" event # This runs when a player presses the button OnInteract(Agent: agent): void = Print("Button pressed! Opening shop...") # This line wakes up the vending machine # It uses the Enable() function from Verse my_shop.Enable() # Optional: disable the button so it can only be pressed once my_button.Disable()