using { /Fortnite.com/Devices } # Rule 1: real module, opened with using
using { /Verse.org/Simulation } # needed for agent and @editable
# Rule 6: one focused job — this device only manages a simple win condition
win_tracker := class(creative_device):
@editable
WinButton : button_device = button_device{} # Rule 1: real device type
WinningScore : int = 1 # Part 3: a constant
var CurrentScore : int = 0 # Part 3: a variable
OnBegin<override>() : void = # Part 4: real startup event
WinButton.InteractedWithEvent.Subscribe(OnWinPressed) # Rule 1 + Part 4
# Rule 5: changes state, so <transacts>; validate before acting
OnWinPressed(Agent : agent)<transacts> : void =
if (CurrentScore < WinningScore): # Rule 4: check first
set CurrentScore += 1 # then change state
Print("We have a winner!") # Rule 7: leave a trail
Verse Library
verse
08 Device
Implements a win condition tracker using module imports, device bindings, state variables, and transactors.
verse-library/verse-the-important-rules/08-device.verse