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
Ski Lift Ski_Lift  

Ski_Lift

The scripts

Category: Ski Lift
By : wiki.YAK.net
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Ski_Lift
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Ski_Lift_1.lsl
1 vector Lo = <128,120,50>;
2 vector Hi = <10,150,110>;
3 vector Side = <0, -5, 0>;
4
5 integer Period = 40;
6 integer TTL = 600;
7 integer Life; // time to live
8 vector Corner;
9 float Phase;
10
11
12 Balloon() {
15
16 // more like a baloon
20
24
25 // more like a plane
28
29 llSitTarget( <.4,0,.4>, ZERO_ROTATION );
30 llSetSitText("RIDE");
31 llSetCameraEyeOffset(<-3, 0, 3>);
32 llSetCameraAtOffset(<2, 0, 2>);
33 }
34
35 SetAltitude(float alt) {
37 }
38
39 vector TargetFromNormalized(float t) {
40 vector b; //begin
41 vector e; //end
42
43 // This t ranges 0 .. 1
44 if( t < 0.1 ) {
45 t = t / 0.1;
46 b = Lo+Side;
47 e = Lo;
48 } else if( t < 0.5 ) {
49 t = (t+-0.1)/0.4;
50 b = Lo;
51 e = Hi;
52 } else if( t < 0.6 ) {
53 t = (t+-.5)/.1;
54 b = Hi;
55 e = Hi+Side;
56 } else {
57 t = (t+-.6) / .4;
58 b = Hi+Side;
59 e = Lo+Side;
60 }
61 return b + t*(e-b);
62 }
63
64
65
66
67 vector TargetFromTimeOfDay(integer periodSecs) {
68
69 integer period = periodSecs * 1000; // now in ms
70 float t = llGetTimeOfDay(); // secs
71 integer rem = (integer)(t*1000) % period; // ms
72 t = (float)rem / (float)period; // normalized 0 .. 1
73
74 // adjust for phase
75 t += Phase;
76 if(t>1) t= t+-1;
77
78 vector targ = TargetFromNormalized(t);
79 return targ;
80 }
81 SetAcceleration(vector desired_acceleration) {
82 // Using Newtons Second law, thanks to lsl wiki
83 //float mass = llGetMass();
84 //llSetForce(mass * (desired_acceleration + <0,0,9.8>), FALSE);
85 llApplyImpulse(llGetMass()*desired_acceleration,FALSE);
86 }
87 SetVel(vector velocity) {
88 float clamp = 15;
89 vector accel = velocity - llGetVel();
90 if( llVecMag(accel) > clamp ) {
91 accel = clamp * llVecNorm(accel);
92 }
93 //llShout(0, "SetVel " +(string)velocity+ " Accel " + (string)accel );
94 SetAcceleration( accel );
95 }
96 SetTarget(vector targ) {
97 vector diff = targ - llGetPos();
98 SetVel(diff); // time frame 1 sec.
99 }
100 Move() {
101 vector targ = TargetFromTimeOfDay(Period);
102 float dist = llVecMag( targ - llGetPos() );
103 //llShout( 0, (string)dist + " ########## " + (string)( TargetFromTimeOfDay(120) ) );
104 //llShout(0, "At " +(string)llGetPos()+ " To " +(string)targ );
105 // TODO
106 SetAltitude(targ.z);
107 SetTarget(targ);
108 }
109
110
111
112 default
113 {
114 on_rez(integer a) {
115 Phase = (float)(a%1000)/1000.0; // phase: a from 0 to 999
116 state moving;
117 }
119 {
121 llSay(0, "Hello, Avatar!");
122 }
123
124 touch_start(integer total_number)
125 {
126 llSay(0, "Touched.");
127 state moving;
128 }
129 }
130
131 state moving {
132 state_entry() {
133 llListen(404, "", NULL_KEY, "");
134 llSetTimerEvent(1.0);
135 Life = TTL;
136 Corner = llGetRegionCorner();
138 Balloon();
139 Move();
140 }
141 timer() {
142 //-- Life;//NO Longer Needed
143 if(Life < 0) {
144 llShout(0, "TTL Bye at " + (string)llGetPos() );
145 llDie();
146 }
147 if(Corner != llGetRegionCorner()) {
148 llShout(0, "Wrong Corner: " + (string)llGetRegionName());
149 llDie();
150 }
151
152 Move();
153 }
154 //touch_start(integer ignore) {
155 // state default;
156 //}
157 listen(integer channel, string name, key id, string message) {
158 llShout(404, (string)llGetPos() );
159 llDie();
160 }
161 }
162
163 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
164 @@@ Above here is the seat, named "Ride Me".
165 @@@ Following here is the rezzer object.
166 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
167
168 string Payload = "Ride Me";
169 integer N = 8;
170
171 Rez(integer a) {
172 llRezObject(Payload, llGetPos()+<0,0,5>, <0,0,0>, <0,0,0,0>, a);
173 }
174
175 default
176 {
177 touch_start(integer total_number)
178 {
179 llSay(0, "Creating ski lift");
180 integer i;
181 for ( i=0; i<N; i++) {
182 Rez(i*1000/N);
183 }
184 state running;
185 }
186 }
187 state running {
188 touch_start(integer ignore) {
189 llSay(0, "Destructing ski lift");
190 llShout(404, "Die");
191 state default;
192 }
193 }

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