Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Vehicles Train_and_train_car_script_for_Open  

Train_and_train_car_script_for_Open

First the readme:

Train Engine/Ca...

Category: Vehicles
By : Charles Allen
Created: 2010-11-18 Edited: 2010-11-18
Worlds: Second Life

the Zip file

Download all files for Train_and_train_car_script_for_Open
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Train_and_train_car_script_for_Open_1.lsl
Get file # 2. Train_and_train_car_script_for_Open_2.lsl
1 // vvv Configuration/Settings vvv
2 // Sounds
3 // Arrive at Station
4 string stop = "";
5 float stopvolume = 1.0;
6 // Running
7 string running = "";
8 float runningvolume = 1.0;
9 // Idle
10 string idle = "";
11 float idlevolume = 1.0;
12 // Leave Station
13 string start = "";
14 float startvolume = 1.0;
15 float startsoundlength = 0.5;
16 // Multiple Trains
17 integer enginechannel = -549816546;
18 // Speed
19 float speed = 10.0;
20 // Train Offset
21 vector cpoffset = <0.0, 0.0, -1.199>;
22 // Train Checkpoints
23 list checkpoints = ["<128.21408, 64.01570, 63.43275>", "<118.21558, 64.01607, 63.44098>:0s:", "<108.21135, 63.93224, 63.44129>:20:Reading Railroad:Pennsylvania Railroad", "<98.64242, 64.58298, 63.43275>", "<89.63821, 66.57278, 63.44098>", "<82.54501, 70.11105, 63.44129>", "<76.58730, 75.55882, 63.43275>", "<71.72843, 81.54896, 63.44098>", "<68.27763, 88.99255, 63.44129>", "<66.32258, 98.22130, 63.43275>", "<65.64206, 107.66950, 63.44098>", "<65.64206, 117.63175, 63.44129>", "<65.64170, 127.63023, 63.43275>", "<65.64206, 137.62869, 63.44098>:0s:", "<65.64206, 147.61710, 63.44098>:20:Pennsylvania Railroad:B. & O. Railroad", "<66.35152, 157.35495, 63.43275>", "<68.34132, 166.35918, 63.44098>", "<71.87959, 173.45236, 63.44129>", "<77.32736, 179.41008, 63.43275>", "<83.31750, 184.26895, 63.44098>", "<90.76109, 187.71974, 63.44129>", "<99.98985, 189.67482, 63.43275>", "<109.43803, 190.35532, 63.44098>", "<119.40030, 190.35532, 63.44129>", "<129.39877, 190.35568, 63.43275>", "<139.39725, 190.35532, 63.44098>:0s:", "<149.22479, 190.33736, 63.44098>:20:B. & O. Railroad:Short Line", "<158.96265, 189.62785, 63.43275>", "<167.96687, 187.63806, 63.44098>", "<175.06004, 184.09982, 63.44128>", "<181.01776, 178.65202, 63.43275>", "<185.87663, 172.66190, 63.44098>", "<189.32744, 165.21828, 63.44129>", "<191.28250, 155.98955, 63.43275>", "<191.96301, 146.54137, 63.44098>", "<191.96301, 136.57907, 63.44129>", "<191.96336, 126.58061, 63.43275>", "<191.96300, 116.58212, 63.44098>:0s:", "<191.97081, 106.75428, 63.44098>:20:Short Line:Reading Railroad", "<191.26131, 97.01643, 63.43275>", "<189.27151, 88.01220, 63.44098>", "<185.73326, 80.91902, 63.44129>", "<180.28548, 74.96130, 63.43275>", "<174.29536, 70.10243, 63.44098>", "<166.85175, 66.65163, 63.44129>", "<157.62302, 64.69656, 63.43275>", "<148.17484, 64.01606, 63.44098>", "<138.21254, 64.01606, 63.44129>"];
24 // ^^^ Configuration/Settings ^^^
25
26 integer checkpoint = 0;
27 integer numcheckpoints = 0;
28 vector next_pos;
29 string cpdata;
30 string spause;
31 float pause;
32 string csname;
33 string nsname;
34 integer cpdataloc;
35 rotation rot;
36 vector increment;
37 integer i;
38 integer soundstart = 0;
39
40 next_checkpoint()
41 {
42 if(checkpoint >= numcheckpoints)
43 {
44 checkpoint = 0;
45 llSetRot(<0.70711, 0.00000, -0.70711, 0.00000>);
46 if(llGetFreeMemory() <= 2000) llResetScript();
47 }
48 next_pos = ZERO_VECTOR;
49 cpdata = llList2String(checkpoints, checkpoint);
50 spause = "";
51 pause = 0.0;
52 csname = "";
53 nsname = "";
54 cpdataloc = llSubStringIndex(cpdata, ":");
55 if(cpdataloc == -1)
56 {
57 next_pos = ((vector)cpdata + cpoffset);
58 }
59 else
60 {
61 next_pos = ((vector)llGetSubString(cpdata, 0, cpdataloc - 1) + cpoffset);
62 cpdata = llDeleteSubString(cpdata, 0, cpdataloc);
63 cpdataloc = llSubStringIndex(cpdata, ":");
64 spause = llGetSubString(cpdata, 0, cpdataloc - 1);
65 if(llGetSubString(spause, -1, -1) == "s" && stop != "")
66 {
68 llPlaySound(stop, stopvolume);
69 pause = (float)llGetSubString(cpdata, 0, cpdataloc - 2);
70 }
71 else
72 {
73 pause = (float)llGetSubString(cpdata, 0, cpdataloc - 1);
74 }
75 cpdata = llDeleteSubString(cpdata, 0, cpdataloc);
76 cpdataloc = llSubStringIndex(cpdata, ":");
77 if(cpdataloc != -1)
78 {
79 if(idle != "")
80 {
81 llLoopSound(idle, idlevolume);
82 }
83 csname = llGetSubString(cpdata, 0, cpdataloc - 1);
84 cpdata = llDeleteSubString(cpdata, 0, cpdataloc);
85 nsname = llGetSubString(cpdata, 0, -1);
86 if(llStringLength(csname) > 0) llWhisper(0, "Arrived at " + csname + ".");
87 }
88 if(pause > 0.0)
89 {
90 llSleep(pause);
91 if(start != "")
92 {
94 llPlaySound(start, startvolume);
96 soundstart = 1;
97 }
98 }
99 if(llStringLength(nsname) > 0) llWhisper(0, "Next stop " + nsname + ".");
100 }
101 if(soundstart == 1)
102 {
103 if(llGetTime() >= startsoundlength)
104 {
105 soundstart = 0;
106 llLoopSound(running, runningvolume);
107 }
108 }
109 llShout(enginechannel, "nextpos");
110 rot = llGetRot() * llRotBetween(<0,0,1> * llGetRot(), next_pos - llGetPos());
111 increment = (next_pos - llGetPos()) / speed;
112 for(i=0;i<speed;++i)
113 {
115 }
116 checkpoint++;
117 next_checkpoint();
118 }
119
120 default
121 {
123 {
124 numcheckpoints = llGetListLength(checkpoints);
125 checkpoint = 0;
126 llSetRot(<0.70711, 0.00000, -0.70711, 0.00000>);
127 next_checkpoint();
128 }
129
130 on_rez(integer start_param)
131 {
133 }
134 }

Train_and_train_car_script_for_Open

Lastly the Train car

Category: Vehicles
By : Charles Allen
Created: 2010-11-18 Edited: 2010-11-18
Worlds: Second Life

1 // vvv Configuration/Settings vvv
2 // Multiple Cars
3 integer carnumber = 1;
4 // Multiple Trains
5 integer enginechannel = -549816546;
6 // Speed
7 float speed = 10.0; // Higher = Slower, but will look smoother.
8 // Train Offset
9 vector cpoffset = <0.0, 0.0, -1.884>;
10 // Train Checkpoints
11 list checkpoints = ["<128.21408, 64.01570, 63.43275>", "<118.21558, 64.01607, 63.44098>:0s:", "<108.21135, 63.93224, 63.44129>:20:Reading Railroad:Pennsylvania Railroad", "<98.64242, 64.58298, 63.43275>", "<89.63821, 66.57278, 63.44098>", "<82.54501, 70.11105, 63.44129>", "<76.58730, 75.55882, 63.43275>", "<71.72843, 81.54896, 63.44098>", "<68.27763, 88.99255, 63.44129>", "<66.32258, 98.22130, 63.43275>", "<65.64206, 107.66950, 63.44098>", "<65.64206, 117.63175, 63.44129>", "<65.64170, 127.63023, 63.43275>", "<65.64206, 137.62869, 63.44098>:0s:", "<65.64206, 147.61710, 63.44098>:20:Pennsylvania Railroad:B. & O. Railroad", "<66.35152, 157.35495, 63.43275>", "<68.34132, 166.35918, 63.44098>", "<71.87959, 173.45236, 63.44129>", "<77.32736, 179.41008, 63.43275>", "<83.31750, 184.26895, 63.44098>", "<90.76109, 187.71974, 63.44129>", "<99.98985, 189.67482, 63.43275>", "<109.43803, 190.35532, 63.44098>", "<119.40030, 190.35532, 63.44129>", "<129.39877, 190.35568, 63.43275>", "<139.39725, 190.35532, 63.44098>:0s:", "<149.22479, 190.33736, 63.44098>:20:B. & O. Railroad:Short Line", "<158.96265, 189.62785, 63.43275>", "<167.96687, 187.63806, 63.44098>", "<175.06004, 184.09982, 63.44128>", "<181.01776, 178.65202, 63.43275>", "<185.87663, 172.66190, 63.44098>", "<189.32744, 165.21828, 63.44129>", "<191.28250, 155.98955, 63.43275>", "<191.96301, 146.54137, 63.44098>", "<191.96301, 136.57907, 63.44129>", "<191.96336, 126.58061, 63.43275>", "<191.96300, 116.58212, 63.44098>:0s:", "<191.97081, 106.75428, 63.44098>:20:Short Line:Reading Railroad", "<191.26131, 97.01643, 63.43275>", "<189.27151, 88.01220, 63.44098>", "<185.73326, 80.91902, 63.44129>", "<180.28548, 74.96130, 63.43275>", "<174.29536, 70.10243, 63.44098>", "<166.85175, 66.65163, 63.44129>", "<157.62302, 64.69656, 63.43275>", "<148.17484, 64.01606, 63.44098>", "<138.21254, 64.01606, 63.44129>"];
12 // ^^^ Configuration/Settings ^^^
13
14 key owner;
15 integer checkpoint = 0;
16 integer numcheckpoints = 0;
17 vector next_pos;
18 string cpdata;
19 integer cpdataloc;
20 rotation rot;
21 vector increment;
22 integer i;
23
24 next_checkpoint()
25 {
26 if(checkpoint >= numcheckpoints)
27 {
28 checkpoint = 0;
29 llSetRot(<0.70711, 0.00000, -0.70711, 0.00000>);
30 }
31 else if(checkpoint == (numcheckpoints - 1) - carnumber && llGetFreeMemory() <= 2000)
32 {
34 }
35 next_pos = ZERO_VECTOR;
36 cpdata = llList2String(checkpoints, checkpoint);
37 cpdataloc = llSubStringIndex(cpdata, ":");
38 if(cpdataloc == -1)
39 {
40 next_pos = ((vector)cpdata + cpoffset);
41 }
42 else
43 {
44 next_pos = ((vector)llGetSubString(cpdata, 0, cpdataloc - 1) + cpoffset);
45 cpdata = llDeleteSubString(cpdata, 0, cpdataloc);
46 cpdataloc = llSubStringIndex(cpdata, ":");
47 }
48 rot = llGetRot() * llRotBetween(<0,0,1> * llGetRot(), next_pos - llGetPos());
49 increment = (next_pos - llGetPos()) / speed;
50 for(i=0;i<speed;++i)
51 {
53 }
54 checkpoint++;
55 }
56
57 default
58 {
60 {
61 owner = llGetOwner();
62 llListen(enginechannel, "", NULL_KEY, "nextpos");
63 numcheckpoints = llGetListLength(checkpoints);
64 checkpoint = (numcheckpoints - 1) - carnumber;
65 next_checkpoint();
66 llSetRot(<0.70711, 0.00000, -0.70711, 0.00000>);
67 }
68
69 on_rez(integer start_param)
70 {
72 }
73
74 listen(integer channel, string name, key id, string message)
75 {
76 if(llGetOwnerKey(id) == owner)
77 {
78 next_checkpoint();
79 }
80 }
81 }

Back to the Best Free Tools in Second Life and OpenSim.