opensim – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 1 | integer dialog_channel= 427; // set a dialog channel |
2 | list menu = [ "Go up", "Go down" ]; |
||
3 | vector startPosition; |
||
4 | float groundLevel; |
||
5 | |||
6 | default |
||
7 | { |
||
8 | state_entry() |
||
9 | { |
||
10 | // arrange to listen for dialog answers (from multiple users) |
||
11 | llListen( dialog_channel, "", NULL_KEY, ""); |
||
12 | |||
13 | startPosition = llGetPos(); |
||
14 | groundLevel = llGround( startPosition ); |
||
15 | } |
||
16 | |||
17 | touch_start(integer total_number) |
||
18 | { |
||
19 | llDialog( llDetectedKey( 0 ), "What do you want to do?", menu, |
||
20 | dialog_channel ); |
||
21 | } |
||
22 | |||
23 | listen(integer channel, string name, key id, string choice ) |
||
24 | { |
||
25 | vector position = llGetPos(); |
||
26 | |||
27 | // if a valid choice was made, implement that choice if possible. |
||
28 | // (llListFindList returns -1 if choice is not in the menu list.) |
||
29 | if ( llListFindList( menu, [ choice ]) != -1 ) |
||
30 | { |
||
31 | if ( choice == "Go up" ) |
||
32 | { |
||
33 | if( position.z < ( startPosition.z + 10.0 ) ) |
||
34 | { |
||
35 | llSetPos( llGetPos() + < 0, 0, 1.0 > ); // move up |
||
36 | } |
||
37 | } |
||
38 | else if( choice == "Go down" ) |
||
39 | { |
||
40 | if( position.z > ( groundLevel + 1.0 ) ) |
||
41 | { |
||
42 | llSetPos( llGetPos() + < 0, 0, -1.0 > ); // move down |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 | else |
||
47 | { |
||
48 | llSay( 0, "Invalid choice: " + choice ); |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 |