Difference between revisions of "User:Toady Nakamura/Touch Toggle Light"

From Second Life Wiki
Jump to navigation Jump to search
m (created page)
 
m (addedline)
Line 1: Line 1:
*Based on Simon Kline's "Scripting from Scratch Class" in 2010
*Based on Simon Kline's "Scripting from Scratch Class" in 2010
*Modified by --[[User:Toady Nakamura|Toady Nakamura]] 11:42, 14 May 2012 (PDT) 2011 for LSL wiki
*Place in prim, touch to change from dark to light.
*Place in prim, touch to change from dark to light.
*Example of on/off toggling  
*Example of on/off toggling  

Revision as of 11:42, 14 May 2012

  • Based on Simon Kline's "Scripting from Scratch Class" in 2010
  • Modified by --Toady Nakamura 11:42, 14 May 2012 (PDT) 2011 for LSL wiki
  • Place in prim, touch to change from dark to light.
  • Example of on/off toggling


<lsl>integer on_off = FALSE; //STARTS IN THE OFF POSITION

default {

   touch_start(integer total_number)
   {
       if (on_off == TRUE)        // if the light exactly equals "==" ON turn it off
       {
           llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <1, 1, 0.5>, 1.0, 10.0, 0.75,PRIM_GLOW ,ALL_SIDES,0]);
           llOwnerSay("Light is Off");
           on_off = FALSE;     // Flip to FALSE now that light is OFF
                               // note here only one "=" sign as the value is being set
       
       }
       
       else  // otherwise do the opposite
       {
           llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 1, 0.5>, 1.0, 10.0, 0.75,PRIM_GLOW ,ALL_SIDES,0.2]);
           llOwnerSay("Light is On");
           on_off = TRUE;  // flip to TRUE now that light is ON
       }
   }

} </lsl>