Thanks for posting @BrendannnD.
We also use this pattern in the Tagged Lights Puzzle Tutorial.
For example, the button handler looks like:
button_event_handler := class():
# Positions used to access the lights this button controls.
Indices : []int
# tagged_lights_puzzle that created this button_event_handler so we can call functions on it.
PuzzleDevice : tagged_lights_puzzle
OnButtonPressed(Player : agent) : void =
# Tell the PuzzleDevice to toggle the lights at the positions this button controls.
PuzzleDevice.ToggleLights(Indices)