KanEd-Test12.lsl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. vector startPosition;
  2. float groundLevel;
  3. default
  4. {
  5. state_entry()
  6. {
  7. // get permission to take over the avatar's control inputs.
  8. llRequestPermissions( llGetOwner(), PERMISSION_TAKE_CONTROLS );
  9. startPosition = llGetPos();
  10. groundLevel = llGround( startPosition );
  11. }
  12. run_time_permissions( integer perm ) // event for processing
  13. // permission dialog.
  14. {
  15. if ( perm & PERMISSION_TAKE_CONTROLS ) // permission has been given.
  16. {
  17. // go ahead and take over the forward and backward controls.
  18. llTakeControls( CONTROL_FWD | CONTROL_BACK, TRUE, FALSE );
  19. }
  20. }
  21. control( key id, integer held, integer change ) // event for processing
  22. // key press.
  23. {
  24. vector position = llGetPos();
  25. if ( change & held & CONTROL_FWD )
  26. { // the "move forward" control has been activated.
  27. if( position.z < (startPosition.z + 10.0) )
  28. {
  29. llSetPos( llGetPos() + < 0, 0, 1.0 >); // move up
  30. }
  31. }
  32. else if ( change & held & CONTROL_BACK )
  33. { // the "move backward" key has been activated.
  34. if( position.z > groundLevel + 1.0 )
  35. {
  36. llSetPos( llGetPos() + < 0, 0, -1.0 >); // move down
  37. }
  38. }
  39. }
  40. }