diff options
author | David Walter Seikel | 2012-01-16 05:38:46 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-16 05:38:46 +1000 |
commit | 568b3e624c538fa7354a7853bdea2eb54a0155ad (patch) | |
tree | 968ae965f789c825db89869db913b86cf67149f7 | |
parent | Make things more robust against a half arsed parser. (diff) | |
download | SledjHamr-568b3e624c538fa7354a7853bdea2eb54a0155ad.zip SledjHamr-568b3e624c538fa7354a7853bdea2eb54a0155ad.tar.gz SledjHamr-568b3e624c538fa7354a7853bdea2eb54a0155ad.tar.bz2 SledjHamr-568b3e624c538fa7354a7853bdea2eb54a0155ad.tar.xz |
Add a proper LSL file for easy testing.
-rw-r--r-- | LuaSL/test2.lsl | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/LuaSL/test2.lsl b/LuaSL/test2.lsl new file mode 100644 index 0000000..3b93b64 --- /dev/null +++ b/LuaSL/test2.lsl | |||
@@ -0,0 +1,108 @@ | |||
1 | // MLPV2 Version 2.3j, by Learjeff Innis, based on | ||
2 | //MLP MULTI-LOVE-POSE V1.2 - Copyright (c) 2006, by Miffy Fluffy (BSD License) | ||
3 | // OpenSim port by Jez Ember | ||
4 | // Meta 7 fixes by onefang Rejected and one by Tatjana Kidd. | ||
5 | |||
6 | integer MAX_BALLS = 6; | ||
7 | |||
8 | integer ch; | ||
9 | integer swap; | ||
10 | integer BallCount; | ||
11 | |||
12 | string pr1; | ||
13 | string pr2; | ||
14 | |||
15 | integer Zoffset; | ||
16 | |||
17 | vector RefPos; | ||
18 | rotation RefRot; | ||
19 | |||
20 | getRefPos() { //reference position | ||
21 | RefPos = llGetPos(); | ||
22 | RefRot = llGetRot(); | ||
23 | Zoffset = (integer)llGetObjectDesc(); | ||
24 | RefPos.z += (float) Zoffset / 100.; | ||
25 | } | ||
26 | |||
27 | list Pdata; | ||
28 | |||
29 | getPosNew(string pdata) { | ||
30 | Pdata = llParseString2List(pdata, [" "],[]); | ||
31 | } | ||
32 | |||
33 | setPos() { | ||
34 | pr1 = (string)((vector)llList2String(Pdata, 0) * RefRot + RefPos); | ||
35 | pr2 = (string)((vector)llList2String(Pdata, 2) * RefRot + RefPos); | ||
36 | pr1 += (string)(llEuler2Rot((vector)llList2String(Pdata, 1) * DEG_TO_RAD) * RefRot); | ||
37 | pr2 += (string)(llEuler2Rot((vector)llList2String(Pdata, 3) * DEG_TO_RAD) * RefRot); | ||
38 | if (BallCount > 1) { | ||
39 | llSay(ch+swap,pr1); //msg to ball1/2 | ||
40 | llSay(ch+!swap,pr2); | ||
41 | } else { | ||
42 | llSay(ch,pr1); //msg to ball1/2 | ||
43 | } | ||
44 | |||
45 | integer ix; | ||
46 | for (ix = 2; ix < BallCount; ++ix) { | ||
47 | llSay(ch + ix, (string)((vector)llList2String(Pdata, 2*ix) * RefRot + RefPos) | ||
48 | + (string)(llEuler2Rot((vector)llList2String(Pdata, 2*ix + 1) * DEG_TO_RAD) * RefRot)); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | getChan() { | ||
53 | ch = (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim | ||
54 | } | ||
55 | |||
56 | default { | ||
57 | state_entry() { | ||
58 | getRefPos(); | ||
59 | getChan(); | ||
60 | } | ||
61 | |||
62 | on_rez(integer arg) { | ||
63 | getRefPos(); | ||
64 | getChan(); | ||
65 | } | ||
66 | |||
67 | link_message(integer from, integer num, string cmd, key pkey) { | ||
68 | if (cmd == "PRIMTOUCH"){ | ||
69 | return; | ||
70 | } | ||
71 | |||
72 | if (num == 1 && cmd == "STOP") { | ||
73 | swap = 0; | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | if (num) return; | ||
78 | |||
79 | if (cmd == "POSE") { | ||
80 | list parms = llCSV2List((string)pkey); | ||
81 | BallCount = llList2Integer(parms,1); | ||
82 | return; | ||
83 | } else if (cmd == "POSEPOS") { | ||
84 | // p = (integer)((string)pkey | ||
85 | getPosNew((string)pkey); | ||
86 | setPos(); | ||
87 | } else if (cmd == "SWAP") { | ||
88 | swap = (integer)((string)pkey) & 1; | ||
89 | llSay(ch+swap,pr1); //msg to ball1/2 | ||
90 | llSay(ch+!swap,pr2); | ||
91 | } else if (cmd == "REPOS") { | ||
92 | getRefPos(); | ||
93 | } else if (llGetSubString(cmd, 0, 0) == "Z") { | ||
94 | // Changed by Tatjana to make it work :) | ||
95 | integer change; | ||
96 | if (llGetSubString(cmd,1,1) == "+") change = (integer)llGetSubString(cmd,2,10); | ||
97 | else change = (integer)llGetSubString(cmd,1,10); | ||
98 | // End Tatjana changing (Penny helped, of course!) | ||
99 | Zoffset += change; | ||
100 | RefPos.z += (float)change/100.; | ||
101 | setPos(); | ||
102 | llOwnerSay("Height Adjustment: change by " + (string) change + "cm, new offset: " + (string)Zoffset + "cm"); | ||
103 | llSetObjectDesc((string)Zoffset); | ||
104 | } else if (cmd == "GETREFPOS") { | ||
105 | llMessageLinked(LINK_THIS,8,(string)RefPos,(string)RefRot); //send reference position to pose | ||
106 | } | ||
107 | } | ||
108 | } | ||