LSL Status/Kan-ed12

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(New page: '''Code:''' vector startPosition; float groundLevel; default { state_entry() { // get permission to take over the avatar's control inputs. llRequestPermissi...)
 
m (Robot: Cosmetic changes)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
__NOTOC__
 +
{{Quicklinks}}
 +
<br />
 +
 
'''Code:'''
 
'''Code:'''
  
Line 47: Line 51:
 
  }
 
  }
  
'''Status:''' Not Working. Lacking the control and run_time_permissions events. Currently llTakeControls(), llGround(), and llRequestPermissions() are not implemented.
+
'''Status:''' Working!
 +
 
 +
[[Category:Scripts]]

Latest revision as of 20:30, 3 March 2012


Code:

vector startPosition;
float groundLevel;

default 
{
   state_entry() 
   { 
      // get permission to take over the avatar's control inputs.
      llRequestPermissions( llGetOwner(), PERMISSION_TAKE_CONTROLS );
      
      startPosition = llGetPos();
      groundLevel = llGround( startPosition );
   }

   run_time_permissions( integer perm )  // event for processing 
                                          // permission dialog.
   {
       if ( perm & PERMISSION_TAKE_CONTROLS )  // permission has been given.
       { 
           // go ahead and take over the forward and backward controls.
           llTakeControls( CONTROL_FWD | CONTROL_BACK, TRUE, FALSE ); 
       }
   }
    
   control( key id, integer held, integer change )  // event for processing 
                                                     // key press.
   { 
       vector position = llGetPos();
       
       if ( change & held & CONTROL_FWD ) 
       {   // the "move forward" control has been activated.
           if( position.z < (startPosition.z + 10.0) )
           {
              llSetPos( llGetPos() + < 0, 0, 1.0 >); // move up
           }
       } 
       else if ( change & held & CONTROL_BACK ) 
       {   // the "move backward" key has been activated.
           if( position.z > groundLevel + 1.0 ) 
           {
              llSetPos( llGetPos() + < 0, 0, -1.0 >); // move down
           }
       }
   }
}

Status: Working!

Personal tools
General
About This Wiki