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<override>()<suspends>: 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
Verse Library
verse
01 Device
Connects a button to a vending machine, enabling the shop when players interact with it.
verse-library/enable-or-disable-vending-machines/01-device.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.