Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
titleInteraction example
image "Lights.svg"
 
handle showLight
in "#theRect"
with (elem, status, datapool) // datapool can always be added to have access to every value in the datapool
'
// elem is the element referenced via "in"
// status is the value of showLight
elem.style.fill = status === 0 ? "red" : status === 1 ? "yellow" : "green"
'

event "click" 
on "#theRect"
simulation step simulation // executes an actual simulation step

event "click" 
on "#theRect"
set showLight
'
if (showLight != 1) {
    return 1 // this sets showLight to 1
}
'

// Only set this boolean variable in this tick
event "click"
on "#theRedOne"
signal thisIsABoolean

...