Light Switch โ
A lamp that lights the room and glows when on, dark when off, from one button on the lamp itself. No HUD needed: the lamp is its own project.
You need: a lamp with a prim named switch and a prim named bulb, plus *BUILD, *FUNCTIONS and [add-on] - Conditions & Variables - 1Click inside.
1. Variable โ
Tools โ { } โ Create New Variable: String, light, initial OFF.
2. The switch function โ
Re-scan, click
switchto create its function.Add Condition:
$light==OFF. Save.Success branch (turn on):
- Change Variable:
$lightSetON - Point of Light:
$THIS, linkbulb, ON, color<1.0, 0.9, 0.7>, intensity 1, radius 8, falloff 0.75 - Glow:
$THIS, linkbulb, faces All, 0.3 - Full Bright:
$THIS, linkbulb, faces All, ON - Sound Play
click
- Change Variable:
Failure branch (turn off):
- Change Variable:
$lightSetOFF - Point of Light:
$THIS, linkbulb, OFF - Glow:
bulb, 0 - Full Bright:
bulb, OFF - Sound Play
click
- Change Variable:
3. Start dark โ
Rez event: Point of Light OFF, Glow 0, Full Bright OFF, $light = OFF. That way a freshly rezzed lamp is always off.
4. Build, test, finish โ
Click the switch: warm light, glowing bulb. Click again: dark. Finish! when done.
Variations โ
- Dimmer: an integer
$level(0โ3) and a chain of conditions, each setting a different intensity. - Remote control: move the condition into a Receive Command
toggleevent and send it from a HUD (commands guide). - Color: add a Color Picker to a HUD that controls the lamp's
bulbfaces.