clockwerk-opensim-config – Blame information for rev 9

Subversion Repositories:
Rev:
Rev Author Line No. Line
9 vero 1 vector startPosition;
2 float groundLevel;
3  
4 default
5 {
6 state_entry()
7 {
8 llListen( 0, "", llGetOwner(), "");
9  
10 startPosition = llGetPos();
11 groundLevel = llGround( startPosition );
12  
13 llSay( 0, "Control this object with chat commands like:" );
14 llSay( 0, "'up' or 'down' followed by a distance." );
15 }
16  
17 listen( integer channel, string name, key id, string message )
18 {
19 // separate the input into blank-delmited tokens.
20 list parsed = llParseString2List( message, [ " " ], [] );
21  
22 // get the first part--the "command".
23 string command = llList2String( parsed, 0 );
24  
25 // get the second part--the "distance".
26 string distance_string = llList2String( parsed, 1 );
27 float distance = ( float )distance_string;
28  
29 vector position = llGetPos();
30  
31 if( command == "up" )
32 {
33 if( ( position.z + distance ) < (startPosition.z + 10.0 ) )
34 {
35 llSetPos( llGetPos() + < 0, 0, distance > ); // move up
36 llSetText( "Went up " + (string)distance, < 1, 0, 0 >, 1 );
37 }
38 else
39 {
40 llSetText( "Can't go so high.", < 1, 0, 0 >, 1 );
41 }
42 }
43 else if( command == "down" )
44 {
45 if( ( position.z - distance ) > groundLevel )
46 {
47 llSetPos( llGetPos() + < 0, 0, -distance > ); // move down
48 llSetText( "Went down " + (string)distance, < 1, 0, 0 >, 1 );
49 }
50 else
51 {
52 llSetText( "Can't go so low.", < 1, 0, 0 >, 1 );
53 }
54 }
55 }
56 }
57