Difference between revisions of "Pointing Stick"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "integer on = TRUE; default { state_entry() { llSetText("Touch to activate",<0,1,0>,1); } changed(integer change) { if(change & (CHANGED_OWNE…")
 
Line 1: Line 1:
{{LSL HEADER}}
|title =[[User: rhonin Nissondorf|rhonin]
|content=*[[Pointing Stick]]
integer on = TRUE;
integer on = TRUE;



Revision as of 08:44, 12 March 2011

Template:LSL HEADER |title =[[User: rhonin Nissondorf|rhonin]

|content=*Pointing Stick

integer on = TRUE;


default {

   state_entry()
   {  
 
     llSetText("Touch to activate",<0,1,0>,1);
   }
 changed(integer change)
  {
      if(change & (CHANGED_OWNER | CHANGED_INVENTORY))
          llResetScript();
  }
       

on_rez(integer x)

     {
         llResetScript();
   

} touch_start(integer y)

   {
      if (on == TRUE)
      {
          llRequestPermissions(llDetectedKey(0),
             PERMISSION_TAKE_CONTROLS);
             on = FALSE;
   }
   else if (on == FALSE)
   {
      
       llReleaseControls();
       on = TRUE;
             
   }

}

   run_time_permissions(integer perm)
   {
       if (perm & PERMISSION_TAKE_CONTROLS)
   {
           llTakeControls( CONTROL_FWD|CONTROL_BACK|CONTROL_ROT_LEFT|CONTROL_ROT_RIGHT,TRUE,FALSE);
  }

}

   control(key id, integer level, integer edge)
   {
         
     
       
       
      
   if (level & CONTROL_FWD)
       {
          llSetLinkPrimitiveParamsFast(-4,[ PRIM_POSITION, llGetPos() +<0,00,0.25> * llGetLocalRot()]);
   }
     if (level & CONTROL_BACK)
   {
          llSetLinkPrimitiveParamsFast(-4,[ PRIM_POSITION, llGetPos() +<0,00,-0.25> * llGetLocalRot()]);

}

   if(level & CONTROL_ROT_LEFT)
  {
               llSetLinkPrimitiveParamsFast(-4,[PRIM_ROT_LOCAL, llGetLocalRot() * llEuler2Rot(<0,0,5>*DEG_TO_RAD)]);

}

    if (level& CONTROL_ROT_RIGHT)

{

               llSetLinkPrimitiveParamsFast(-4,[PRIM_ROT_LOCAL, llGetLocalRot() * llEuler2Rot(<0,0,-5>*DEG_TO_RAD)]);

}

       }
     
   
   

}