clockwerk-opensim-config – Blame information for rev 9

Subversion Repositories:
Rev:
Rev Author Line No. Line
9 vero 1 vector startPos;
2 vector curPos;
3 vector curForce;
4 integer second;
5  
6 default
7 {
8 state_entry()
9 {
10 llSay( 0, "Hello, Avatar! Touch to launch me straight up.");
11 llSetStatus( 1, TRUE );
12 startPos = < 0, 0, 0 >;
13 }
14  
15 touch_start(integer total_number)
16 {
17 startPos = llGetPos();
18 curPos = startPos;
19 curForce = < 0, 0, 0 >;
20 second = 0;
21  
22 llSetColor( < 1.0, 0.0, 0.0 > , ALL_SIDES ); // set color to red.
23  
24 float objMass = llGetMass();
25 float Z_force = 10.2 * objMass;
26  
27 llSetForce( < 0.0, 0.0, Z_force >, FALSE );
28  
29 llSay( 0, "Force of " + (string)Z_force + " being applied." );
30 llSetTimerEvent(1);
31 }
32  
33 timer()
34 {
35 second++;
36 curPos = llGetPos();
37 float curDisplacement = llVecMag( curPos - startPos );
38  
39 if( ( curDisplacement > 30. ) && // then object is too far away, and
40 ( llGetForce() != < 0.0, 0.0, 0.0 > ) ) // force not already zero,
41 { // then let gravity take over, and change color to green.
42 llSetForce( < 0.0, 0.0, 0.0 >, FALSE );
43 llSetColor( < 0, 1.0, 0 >, ALL_SIDES );
44 llSay( 0, "Force removed; object in free flight." );
45 }
46  
47 if ( second > 19 ) // then time to wrap this up.
48 {
49 // turn object blue and zero force to be safe....
50 llSetColor( < 0, 0, 1.0 >, ALL_SIDES ); // change color to blue.
51 llSetForce( < 0, 0, 0 >, FALSE );
52  
53 // ...move object back to starting position...
54 // ...after saving current status of Physics attribute.
55 integer savedStatus = llGetStatus( 1 );
56 llSetStatus( 1, FALSE ); // turn physics off.
57 while ( llVecDist( llGetPos(), startPos ) > 0.001)
58 {
59 llSetPos( startPos );
60 }
61 llSetStatus( 1, savedStatus ); // restore Physics status.
62  
63 //...and then turn color to black and Reset the script.
64 llSetColor( < 1, 1, 1 >, ALL_SIDES );
65 llSetTimerEvent( 0 ); // turn off timer events.
66 llSay( 0, "Done and resetting script." );
67 llResetScript(); // return object to ready state.
68 }
69 }
70 }
71