429

Writing program scripts with JavaScript
Using a toggle switch

  • Use the toggle switch to make a lamp turn on and off
    DEF LightSwitch TouchSensor { }
    DEF LampLight SpotLight { . . . }
    
    DEF Toggle Script { . . . }
    
    ROUTE LightSwitch.isActive TO Toggle.set_active
    ROUTE Toggle.on_changed    TO LampLight.set_on