1
0

KanEd-Test04.lsl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. integer counter;
  2. integer second;
  3. vector startPosition;
  4. default
  5. {
  6. state_entry()
  7. {
  8. llSay( 0, "Hello, Avatar! Touch to change position.");
  9. counter = 0;
  10. startPosition = llGetPos();
  11. }
  12. touch_start(integer total_number)
  13. {
  14. counter = counter + 1;
  15. llSay( 0, "Touched by angel number " + (string)counter);
  16. llSetTimerEvent( 1 ); // arrange for a "timer event" every second.
  17. }
  18. timer() // do these instructions every time the timer event occurs.
  19. {
  20. second++;
  21. // choose three random distances between 0. and 10.0.
  22. float X_distance = llFrand( 10.0 );
  23. float Y_distance = llFrand( 10.0 );
  24. float Z_distance = llFrand( 10.0 );
  25. // combine these distance components into a vector and use it
  26. // to increment the starting position and reposition the object.
  27. vector increment = < X_distance, Y_distance, Z_distance >;
  28. vector newPosition = startPosition + increment;
  29. llSetPos( newPosition ); // reposition object.
  30. if ( second > 19 ) // then time to wrap this up.
  31. {
  32. // move object back to starting position...
  33. while ( llVecDist( llGetPos(), startPosition ) > 0.001)
  34. {
  35. llSetPos( startPosition );
  36. }
  37. llSay( 0, "Object now resting and resetting script." );
  38. llResetScript(); // return object to ready state.
  39. }
  40. }
  41. }