SHARE
TWEET

Untitled

a guest Jul 11th, 2019 130 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float trainSpeed = .01;
  2. float trainAngle;
  3.  
  4. vector trainStart;
  5. vector currentPos;
  6. float xSpeed;
  7. float ySpeed;
  8. integer listen_handle;
  9. float trackLength = .3;
  10. float counter = .01;
  11. rotation trainRot;
  12.  
  13. float rotCount = 1;
  14. float rotAmount;
  15. float t = 0;
  16.  
  17. notify(string message)
  18. {
  19.     llOwnerSay(message);
  20. }
  21.  
  22. moveTrainToStart(vector coords)
  23. {
  24.     llSetPos(coords);
  25. }
  26.  
  27.  
  28.  
  29. default
  30. {
  31.     state_entry()
  32.     {
  33.         notify("Switching to listeningState");
  34.         state listeningState;
  35.     }
  36. }
  37.  
  38. state listeningState
  39. {
  40.     state_entry()
  41.     {
  42.         notify("Entered listeningState");
  43.         listen_handle = llListen(5, "", NULL_KEY, "");
  44.         llSetRot(<0,0,0,0>);
  45.     }
  46.    
  47.     listen(integer channel, string name, key id, string message)
  48.     {
  49.         if (channel == 5)
  50.         {
  51.             trainRot = llGetLocalRot();
  52.             trainStart = ((vector)(message));
  53.             currentPos = ((vector)(trainStart));
  54.             trainAngle = llAtan2(currentPos.x, currentPos.y);
  55.             moveTrainToStart(trainStart);
  56.             state movingTrain;
  57.         }
  58.     }
  59. }
  60.  
  61. state movingTrain
  62. {
  63.     state_entry()
  64.     {
  65.        
  66.     }
  67.     touch_start(integer number)
  68.     {
  69.         while (counter < trackLength)
  70.         {
  71.             rotAmount += 3;
  72.             trainRot = llEuler2Rot(<0.0, 0.0, rotAmount> * DEG_TO_RAD );
  73.             xSpeed = llCos(trainAngle) * trainSpeed;
  74.             ySpeed = llSin(trainAngle) * trainSpeed;
  75.             currentPos.x = currentPos.x + xSpeed;
  76.             currentPos.y = currentPos.y + ySpeed;
  77.            
  78.             counter += trainSpeed;
  79.             llSetRot(trainRot);
  80.             llSetPos(currentPos);
  81.         }
  82.     }
  83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top