Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float trainSpeed = .01;
- float trainAngle;
- vector trainStart;
- vector currentPos;
- float xSpeed;
- float ySpeed;
- integer listen_handle;
- float trackLength = .3;
- float counter = .01;
- rotation trainRot;
- float rotCount = 1;
- float rotAmount;
- float t = 0;
- notify(string message)
- {
- llOwnerSay(message);
- }
- moveTrainToStart(vector coords)
- {
- llSetPos(coords);
- }
- default
- {
- state_entry()
- {
- notify("Switching to listeningState");
- state listeningState;
- }
- }
- state listeningState
- {
- state_entry()
- {
- notify("Entered listeningState");
- listen_handle = llListen(5, "", NULL_KEY, "");
- llSetRot(<0,0,0,0>);
- }
- listen(integer channel, string name, key id, string message)
- {
- if (channel == 5)
- {
- trainRot = llGetLocalRot();
- trainStart = ((vector)(message));
- currentPos = ((vector)(trainStart));
- trainAngle = llAtan2(currentPos.x, currentPos.y);
- moveTrainToStart(trainStart);
- state movingTrain;
- }
- }
- }
- state movingTrain
- {
- state_entry()
- {
- }
- touch_start(integer number)
- {
- while (counter < trackLength)
- {
- rotAmount += 3;
- trainRot = llEuler2Rot(<0.0, 0.0, rotAmount> * DEG_TO_RAD );
- xSpeed = llCos(trainAngle) * trainSpeed;
- ySpeed = llSin(trainAngle) * trainSpeed;
- currentPos.x = currentPos.x + xSpeed;
- currentPos.y = currentPos.y + ySpeed;
- counter += trainSpeed;
- llSetRot(trainRot);
- llSetPos(currentPos);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement