diff options
author | David Walter Seikel | 2012-01-04 20:33:54 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 20:33:54 +1000 |
commit | db13ada463c2908eba68b166a9ccc4963db019f5 (patch) | |
tree | ed693d9d9532bea0d890f08199a0bcd5b1e73430 /LuaSL/Test sim/objects/onefang's test bed/~menucfg | |
parent | README files should include at least a basic description of what it's all abo... (diff) | |
download | SledjHamr-db13ada463c2908eba68b166a9ccc4963db019f5.zip SledjHamr-db13ada463c2908eba68b166a9ccc4963db019f5.tar.gz SledjHamr-db13ada463c2908eba68b166a9ccc4963db019f5.tar.bz2 SledjHamr-db13ada463c2908eba68b166a9ccc4963db019f5.tar.xz |
Add a test sim with an MLP bed in it.
No animations yet, wont need them until later, maybe wont need them until this is ready for in world testing.
Diffstat (limited to '')
-rw-r--r-- | LuaSL/Test sim/objects/onefang's test bed/~menucfg | 296 |
1 files changed, 296 insertions, 0 deletions
diff --git a/LuaSL/Test sim/objects/onefang's test bed/~menucfg b/LuaSL/Test sim/objects/onefang's test bed/~menucfg new file mode 100644 index 0000000..d38843d --- /dev/null +++ b/LuaSL/Test sim/objects/onefang's test bed/~menucfg | |||
@@ -0,0 +1,296 @@ | |||
1 | // MLPV2 Version 2.2, by Learjeff Innis, based on | ||
2 | // MLP MULTI-LOVE-POSE V1.2 - Copyright (c) 2006, by Miffy Fluffy (BSD License) | ||
3 | // 15-color balls by Lizz Silverstar | ||
4 | // autoback, multi-contin menu fixed | ||
5 | // OpenSim port by Jez Ember | ||
6 | // Meta 7 fixes by onefang Rejected | ||
7 | |||
8 | integer MAX_BALLS = 6; | ||
9 | |||
10 | // Multicolor ball patch by Lizz Silverstar | ||
11 | // The colors var used to store the color values is a 32 bit integer (0x00000000) | ||
12 | // This is broken up into 8 nibbles of which we will currently use the lower 4 nibbles | ||
13 | // the first ball color is in the lower 4 bits, the second in the next 4 bits, etc | ||
14 | // Masks and shifting are used to store and extract the data. | ||
15 | // 4 bits gives us 15 colors. 0 = no ball, 1-15 = color | ||
16 | // these index values are then used by the ~ball code to set the correct color | ||
17 | // 1st ball mask is 0x0000000F, no shift | ||
18 | // 2nd ball mask is 0x000000F0, shift of 4 | ||
19 | // 3rd ball mask is 0x00000F00, shift of 8 | ||
20 | // 4th ball mask is 0x0000F000, shift of 12 | ||
21 | |||
22 | list Colornames = [ | ||
23 | "HIDE", "PINK", "BLUE", "PINK2", | ||
24 | "BLUE2", "GREEN", "MAGENTA", "RED", | ||
25 | "ORANGE", "WHITE", "BLACK", "YELLOW", | ||
26 | "CYAN", "RED2", "TEAL", "GREEN2"]; | ||
27 | |||
28 | |||
29 | integer PoseIx; | ||
30 | |||
31 | integer CurButtonIx; // index of current button | ||
32 | integer b0; // index of current button from start of current menu | ||
33 | |||
34 | integer AutoBack; | ||
35 | integer chat = TRUE; | ||
36 | integer redo = TRUE; | ||
37 | integer menuusers; | ||
38 | integer group; | ||
39 | integer ballusers; | ||
40 | integer SaneMenuOrder; | ||
41 | integer ReloadOnRez = FALSE; | ||
42 | |||
43 | string cmd; | ||
44 | string pose; | ||
45 | string pose0; | ||
46 | |||
47 | list buttons; | ||
48 | list buttonindex; | ||
49 | list commands; | ||
50 | list menus; | ||
51 | list balls; | ||
52 | list users; | ||
53 | |||
54 | list SoundNames; | ||
55 | list Sounds; | ||
56 | list LMButtons; | ||
57 | list LMParms; | ||
58 | |||
59 | |||
60 | // Globals for reading card config | ||
61 | integer ConfigLineIndex; | ||
62 | list ConfigCards; // list of names of config cards | ||
63 | string ConfigCardName; // name of card being read | ||
64 | integer ConfigCardIndex; // index of next card to read | ||
65 | key ConfigQueryId; | ||
66 | |||
67 | // Replacement for llListFindList which is currently broken in OSLSL | ||
68 | integer myListFind(list a, string b) { | ||
69 | integer x; | ||
70 | integer l=llGetListLength(a); | ||
71 | |||
72 | for(x=0; x<l; x++) { | ||
73 | if(llList2String(a,x) == b) { | ||
74 | return x; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | return -1; | ||
79 | } | ||
80 | |||
81 | integer next_card() | ||
82 | { | ||
83 | if (ConfigCardIndex >= llGetListLength(ConfigCards)) { | ||
84 | ConfigCards = []; | ||
85 | return (FALSE); | ||
86 | } | ||
87 | |||
88 | ConfigLineIndex = 0; | ||
89 | ConfigCardName = llList2String(ConfigCards, ConfigCardIndex); | ||
90 | ConfigCardIndex++; | ||
91 | ConfigQueryId = llGetNotecardLine(ConfigCardName, ConfigLineIndex); | ||
92 | llOwnerSay("Reading " + ConfigCardName); | ||
93 | return (TRUE); | ||
94 | } | ||
95 | |||
96 | default { | ||
97 | state_entry() { | ||
98 | // ch = (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim | ||
99 | llMessageLinked(LINK_THIS,1,"OK?",(key)""); //msg to memory: ask if ready | ||
100 | } | ||
101 | link_message(integer from, integer num, string str, key id) { | ||
102 | if (num == 2 && str == "OK") state load; //memory ready | ||
103 | } | ||
104 | } | ||
105 | |||
106 | |||
107 | state load { | ||
108 | state_entry() { | ||
109 | string item; | ||
110 | ConfigCards = []; | ||
111 | integer n = llGetInventoryNumber(INVENTORY_NOTECARD); | ||
112 | while (n-- > 0) { | ||
113 | item = llGetInventoryName(INVENTORY_NOTECARD, n); | ||
114 | if (llSubStringIndex(item, ".MENUITEMS") != -1) { | ||
115 | ConfigCards += (list) item; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | ConfigCardIndex = 0; | ||
120 | ConfigCards = llListSort(ConfigCards, 1, TRUE); | ||
121 | next_card(); | ||
122 | } | ||
123 | |||
124 | dataserver(key query_id, string data) { | ||
125 | if (query_id != ConfigQueryId) { | ||
126 | return; | ||
127 | } | ||
128 | if (data == EOF) { | ||
129 | if (next_card()) { | ||
130 | return; | ||
131 | } | ||
132 | state on; | ||
133 | } | ||
134 | |||
135 | integer ix = llSubStringIndex(data,"//"); //remove comments | ||
136 | if (ix != -1) { | ||
137 | if (ix == 0) data = ""; | ||
138 | else data = llGetSubString(data, 0, ix - 1); | ||
139 | } | ||
140 | |||
141 | data = llStringTrim(data, STRING_TRIM_TAIL); | ||
142 | if (data != "") { | ||
143 | ix = llSubStringIndex(data," "); | ||
144 | cmd = data; | ||
145 | if (ix != -1) { //split command from data | ||
146 | cmd = llGetSubString(data, 0, ix - 1); | ||
147 | data = llGetSubString(data, ix+1, -1); | ||
148 | } | ||
149 | list ldata = llParseStringKeepNulls(data,[" | "," | "," | "," | "," |","| ","|"],[]); | ||
150 | string arg1 = llList2String(ldata, 0); | ||
151 | // llSay(0, cmd + ":" + data); | ||
152 | if (cmd == "MENU") { | ||
153 | integer auth; | ||
154 | |||
155 | if (PoseIx < 2) { | ||
156 | llOwnerSay("warning: first two items in .MENUITEMS must be: POSE stand / POSE default"); | ||
157 | } | ||
158 | llOwnerSay("loading '"+arg1+"' menu"); | ||
159 | |||
160 | if (llList2String(ldata, 1) == "GROUP") auth = 1; //access to submenus | ||
161 | else if (llList2String(ldata, 1) != "OWNER") auth = 2; //0=owner 1=group 2=all | ||
162 | |||
163 | integer colors; | ||
164 | string ball_color; | ||
165 | integer colorIx; | ||
166 | integer ixB; | ||
167 | for (ixB=0; ixB < MAX_BALLS; ++ixB) { // for each possible ball | ||
168 | ball_color = llList2String(ldata, ixB + 2); // get next color name from config | ||
169 | |||
170 | colorIx = myListFind(Colornames, ball_color); | ||
171 | |||
172 | if (colorIx != -1) { | ||
173 | colors += (colorIx << (4 * ixB)); // 4 = bits per color (16 colors) | ||
174 | } | ||
175 | } | ||
176 | |||
177 | menus += (list) arg1; | ||
178 | balls += (list) colors; | ||
179 | buttonindex += (list) CurButtonIx; | ||
180 | users += (list) auth; | ||
181 | |||
182 | // if (llListFindList(buttons, (list)arg1) == -1) { | ||
183 | |||
184 | if (myListFind(buttons, arg1) == -1) { | ||
185 | |||
186 | integer jx = myListFind(buttons, "-"); | ||
187 | |||
188 | if (jx != -1) { | ||
189 | buttons = llListReplaceList(buttons, (list)arg1, jx, jx); | ||
190 | // "TOMENU" is already in commands list from the 'TOMENU -' | ||
191 | } else if (CurButtonIx > 2) { | ||
192 | llOwnerSay("No unused 'TOMENU -' for " + arg1); | ||
193 | } | ||
194 | } | ||
195 | |||
196 | b0 = 0; | ||
197 | } else if (cmd == "AUTOBACK") { | ||
198 | AutoBack = (arg1 != "0"); | ||
199 | } else if (cmd == "NORELOAD") { | ||
200 | ReloadOnRez = (arg1 != "0"); // whether to reload menu on rez | ||
201 | } else if (cmd == "MENUORDER") { | ||
202 | SaneMenuOrder = (arg1 != "0"); // keep menu buttons in same order as in file | ||
203 | } else { | ||
204 | |||
205 | // automatic menu extension (don't do for main menu) | ||
206 | if (b0 == 12 && llGetListLength(menus) > 1) { | ||
207 | // Add a "more" button before last item | ||
208 | integer ixA = -1; | ||
209 | if (AutoBack) { | ||
210 | ixA = -2; | ||
211 | // Add a "BACK" button | ||
212 | buttons = llListInsertList(buttons, (list)"BACK", ixA); | ||
213 | commands = llListInsertList(commands, (list)"BACK", ixA); | ||
214 | ++CurButtonIx; | ||
215 | } | ||
216 | buttons = llListInsertList(buttons, (list)"More-->", ixA); | ||
217 | commands = llListInsertList(commands, (list)"MORE", ixA); | ||
218 | ++CurButtonIx; | ||
219 | b0 = -ixA; | ||
220 | } | ||
221 | if (cmd == "POSE") { | ||
222 | llMessageLinked(LINK_THIS,9+PoseIx,data, (key)""); | ||
223 | if (!PoseIx) pose0 = arg1; | ||
224 | cmd = (string)PoseIx; | ||
225 | ++PoseIx; | ||
226 | } else if (cmd == "REDO") { | ||
227 | if (llList2String(ldata, 1) != "OFF") redo = 1; | ||
228 | } else if (cmd == "CHAT") { | ||
229 | if (llList2String(ldata, 1) != "OFF") chat = 1; | ||
230 | } else if (cmd == "BALLUSERS") { | ||
231 | if (llList2String(ldata, 1) == "GROUP") ballusers = 1; | ||
232 | } else if (cmd == "MENUUSERS") { | ||
233 | if (llList2String(ldata, 1) == "GROUP") menuusers = 1; | ||
234 | else if (llList2String(ldata, 1) != "OWNER") menuusers = 2; | ||
235 | } else if (cmd == "LINKMSG") { | ||
236 | LMButtons += arg1; | ||
237 | LMParms += llList2String(ldata, 1); | ||
238 | } else if (cmd == "SOUND") { | ||
239 | SoundNames += (list) arg1; | ||
240 | Sounds += (list) llList2String(ldata, 1); | ||
241 | } | ||
242 | commands += (list) cmd; | ||
243 | buttons += (list) arg1; | ||
244 | ++CurButtonIx; | ||
245 | ++b0; | ||
246 | } | ||
247 | } | ||
248 | ++ConfigLineIndex; | ||
249 | ConfigQueryId = llGetNotecardLine(ConfigCardName, ConfigLineIndex); //read next line of menuitems notecard | ||
250 | } | ||
251 | state_exit() { | ||
252 | buttonindex += (list) CurButtonIx; //enter last buttonindex | ||
253 | commands += (list) ""; //empty command for undefined buttons (-1) | ||
254 | |||
255 | integer ix; | ||
256 | integer count; | ||
257 | while ((ix = myListFind(buttons, "-")) != -1) { | ||
258 | ++count; | ||
259 | buttons = llDeleteSubList(buttons, ix, ix); | ||
260 | commands = llDeleteSubList(commands, ix, ix); | ||
261 | } | ||
262 | if (count) { | ||
263 | for (ix = 1; ix < llGetListLength(buttonindex); ++ix) { | ||
264 | buttonindex = llListReplaceList(buttonindex, | ||
265 | (list)(llList2Integer(buttonindex, ix) - count), ix, ix); | ||
266 | } | ||
267 | } | ||
268 | // llMessageLinked(LINK_THIS,1,"LOADED",(string)PoseIx); //msg to memory | ||
269 | llMessageLinked(LINK_THIS,9+PoseIx,"LOADED",(key)""); //msg to pose | ||
270 | } | ||
271 | } | ||
272 | |||
273 | state on { | ||
274 | state_entry() { | ||
275 | llMessageLinked(LINK_THIS, -3, llList2CSV(menus), (key)""); menus = []; | ||
276 | llMessageLinked(LINK_THIS, -4, llList2CSV(buttonindex), (key)""); buttonindex = []; | ||
277 | llMessageLinked(LINK_THIS, -5, llList2CSV(balls), (key)""); balls = []; | ||
278 | llMessageLinked(LINK_THIS, -6, llList2CSV(users), (key)""); users = []; | ||
279 | llMessageLinked(LINK_THIS, -7, llList2CSV(LMButtons), (key)""); LMButtons = []; | ||
280 | |||
281 | llMessageLinked(LINK_THIS, -8, llDumpList2String(LMParms, "|"), (key)""); LMParms = []; | ||
282 | |||
283 | llMessageLinked(LINK_THIS, -9, llList2CSV(SoundNames), (key)""); SoundNames = []; | ||
284 | llMessageLinked(LINK_THIS, -10, llList2CSV(Sounds), (key)""); Sounds = []; | ||
285 | |||
286 | llMessageLinked(LINK_THIS, -2, llList2CSV(commands), (key)""); commands = []; | ||
287 | llMessageLinked(LINK_THIS, -1, llList2CSV(buttons), (key)""); buttons = []; | ||
288 | |||
289 | |||
290 | // finally, scalars (signals 'done' as well) | ||
291 | llMessageLinked(LINK_THIS, -20, | ||
292 | llList2CSV([ redo, chat, ballusers, menuusers, SaneMenuOrder, ReloadOnRez ]), (key)""); | ||
293 | |||
294 | llOwnerSay((string)CurButtonIx+" menuitems loaded ("+llGetScriptName()+": "+(string)llGetFreeMemory()+" bytes free)"); | ||
295 | } | ||
296 | } | ||