SHOW:
|
|
- or go back to the newest paste.
1 | integer out = FALSE; | |
2 | integer rod_equip = FALSE; | |
3 | - | |
3 | + | |
4 | key rod_owner; // 3. Since you are passing messages over several events we need to store the rod owner key in a global variable. | |
5 | ||
6 | //time 15 seconds delay for it to be visible | |
7 | ||
8 | - | |
8 | + | integer lchan; |
9 | ||
10 | default | |
11 | { | |
12 | state_entry() | |
13 | { | |
14 | llListen(-11223,"Fishing Rod","",""); | |
15 | ||
16 | ||
17 | } | |
18 | //listen for fishing rod is equip | |
19 | listen(integer channel, string what, key who, string msg) | |
20 | { | |
21 | - | |
21 | + | |
22 | - | list tmp = llParseString2List(msg,["_"],[]); // 4. We parse the message sent from the rod to the pond. The message will be split into elements in a list at the separator. |
22 | + | list tmp = llParseString2List(msg,["_"],[]); // 4. We parse the message sent from the rod to the pond. The message will be split into elements in a list at the separator. |
23 | - | |
23 | + | |
24 | - | string cmd = llList2String(tmp,0); // 5. The value to the left of the separator will become the first element in the list. i,e "Equip". Note that list elements begin at 0. |
24 | + | string cmd = llList2String(tmp,0); // 5. The value to the left of the separator will become the first element in the list. i,e "Equip". Note that list elements begin at 0. |
25 | - | |
25 | + | |
26 | - | string val = llList2String(tmp,1); // 6. The value to the right of the separator will become the second element in the list. i,e The rod owner key. |
26 | + | string val = llList2String(tmp,1); // 6. The value to the right of the separator will become the second element in the list. i,e The rod owner key. |
27 | ||
28 | if(cmd=="Equip" ) // 7. Note this changes to if(cmd=="Equip" ) because we are checking the parsed message. | |
29 | { | |
30 | - | |
30 | + | |
31 | rod_equip = TRUE; | |
32 | - | rod_owner = (key)ref; // 8. We need to store this in the global variable container so we can send it on to the spawner. |
32 | + | rod_owner = (key)val; // 8. We need to store this in the global variable container so we can send it on to the spawner. |
33 | return; | |
34 | } | |
35 | else | |
36 | { | |
37 | rod_equip = FALSE; | |
38 | return; | |
39 | } | |
40 | - | |
40 | + | |
41 | - | |
41 | + | |
42 | ||
43 | } | |
44 | ||
45 | touch_start(integer total_number) | |
46 | { | |
47 | - | //ask for the fishing rod |
47 | + | |
48 | lchan = ((integer)("0x"+llGetSubString((string)llDetectedKey(0),-8,-1)) - 723) | 0x8000000; | |
49 | //ask for the fishing rod | |
50 | ||
51 | - | llOwnerSay("Toggle Fish"); |
51 | + | |
52 | if(out == TRUE && rod_equip == TRUE) | |
53 | - | llSay(-11223,"off_"+ rod_owner); |
53 | + | |
54 | llOwnerSay("Toggle off"); | |
55 | out = FALSE; | |
56 | llSay(lchan,"off_"+ rod_owner); | |
57 | return; | |
58 | } | |
59 | ||
60 | - | llSay(-11223,"on_"+ rod_owner); //9. We send the message on to the spawners and whichever spawner with an owner key that matches the rod owner key will spawn fish. |
60 | + | |
61 | { | |
62 | llOwnerSay("Toggle On"); | |
63 | out = !out; | |
64 | llSay(lchan,"on_"+ rod_owner); //9. We send the message on to the spawners and whichever spawner with an owner key that matches the rod owner key will spawn fish. | |
65 | return; | |
66 | } | |
67 | ||
68 | } | |
69 | } |