From 10e2f77d57ecc5e306900b112d70c2600f941ae4 Mon Sep 17 00:00:00 2001 From: onefang Date: Mon, 6 Sep 2021 21:15:36 +1000 Subject: Various common tweaks. New instant message logger. Check if a prim still exists before sending it a message. New dynamic menu return option. Check menu commands at startup. --- 1AOor2.lsl | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 7 deletions(-) (limited to '1AOor2.lsl') diff --git a/1AOor2.lsl b/1AOor2.lsl index 111a3d5..e336ab7 100644 --- a/1AOor2.lsl +++ b/1AOor2.lsl @@ -45,6 +45,8 @@ integer lSUBSTITUTE = -7; integer lSUBSTITUTE_DONE = -8; integer lNEXT_WORD = -9; integer lNEXT_WORD_DONE = -10; +integer lCHECK = -11; +integer lCHECK_DONE = -12; integer lCONTROL = -13; integer lCONTROL_DONE = -14; integer lCMD = -15; @@ -64,6 +66,7 @@ d(string m) {if (DEBUG) llInstantMessage(Owner, llGetScriptName() + ": " + m);} D(string m) {llRegionSay(DEBUG_CHANNEL, llGetScriptName() + ": " + m);} s(string m) {s(Owner, m);} s(key id, string m) {if (id == Owner) llOwnerSay(m); else llInstantMessage(id, m);} +S(string m) {llInstantMessage(Owner, llGetScriptName() + ": " + m);} sendScript(integer cmd, list args) {sendScript(LibraryKey, cmd, ScriptName, args);} sendScript(key them, integer cmd, list args) {sendScript(them, cmd, inKey2Name(them), args);} sendScript(integer cmd, string name, list args) {sendScript(LibraryKey, cmd, name, args);} @@ -71,9 +74,16 @@ sendScript(key them, integer cmd, string name, list args) { llMessageLinked(LINK_SET, cmd, llDumpList2String([ScriptKey, name] + args, lSEP), them); } +integer pingPrim(key k) +{ + if (NULL_KEY != k) + return (0 != llGetListLength(llGetObjectDetails(k, [OBJECT_DESC]))); + return FALSE; +} sendPrim(key them, string cmd, list args) { - osMessageObject(them, llDumpList2String([ScriptName, cmd] + args, lSEP)); + if (pingPrim(them)) + osMessageObject(them, llDumpList2String([ScriptName, cmd] + args, lSEP)); } addEvent(float delay, string cmds) { @@ -188,7 +198,11 @@ list readCard(string card) dynamicMenu(key id, string menu, string name, string title, string entries, string command) { - sendScript(lDYNAMIC, [id, menu, name, title, entries, command]); + dynamicMenu(id, menu, name, title, entries, command, 1); +} +dynamicMenu(key id, string menu, string name, string title, string entries, string command, integer ret) +{ + sendScript(lDYNAMIC, [id, menu, name, title, entries, command, ret]); } integer Chosen; @@ -206,16 +220,27 @@ linky(integer num, string message, key id) key them = llList2Key(input, 0); string fr = llList2Key(input, 1); //d("linky " + num + " " + message); - if (lCMD == num) + if ((lCHECK == num) || (lCMD == num)) { -//d("link CHAT " + llDumpList2String(input, " ~ ")); if ((fr == (ScriptName + ".")) || (fr == "*.")) { key a = llList2Key(input, 3); string button = llList2String(input, 4); - integer r = doThing(a, button, fr, + integer r; + if (lCHECK == num) + { +//d("link CHECK " + llDumpList2String(input, " ~ ")); + r = checkThing(a, button, fr, llList2String(input, 5), llList2String(input, 6), llList2Integer(input, 2)); - sendScript(lCMD_DONE, [button, a, r]); + sendScript(num - 1, [llList2String(input, 6), a, r]); + } + else + { +//d("link CHAT " + llDumpList2String(input, " ~ ")); + r = doThing(a, button, fr, + llList2String(input, 5), llList2String(input, 6), llList2Integer(input, 2)); + sendScript(num - 1, [button, a, r]); + } } } else if (lRESET_DONE == num) @@ -237,6 +262,44 @@ d("linky RESET_DONE"); } // END boilerplate, mostly. +integer checkThing(key id, string button, string fr, string cmd, string data, integer source) +{ + if ((fr != (ScriptName + ".") && ("*." != fr))) return TRUE; + if (("POSE" == cmd) || ("SINGLE_POSE" == cmd)) + { +//d("CHECKING " + data); + // POSE piggyback,~,piggyback-sit + list p = llParseStringKeepNulls(llGetSubString(data, 5, -1), [",", "|"], []); + string name = llList2String(p, 0); + integer l = llGetListLength(p); + integer i; + + p = llListReplaceList(p, [], 0, 0); + l--; + for (i = 0; i < l; i++) + { + string a = llList2String(p, i); + integer e = FALSE; + integer f = FALSE; + list ae = splitEmote(a); + string an = llList2String(ae, 0); + + // Coz LSL doesn't short circuit, and we don't want to checkAnim("~") + if ("~" == an) + e = TRUE; + else if (!checkAnim(an, TRUE)) + e = TRUE; + if (e) + { + p = llListReplaceList(p, [], i, i); + i--; l--; + } + } + savePose(name, llDumpList2String(p, "|"), "", ""); + } + return TRUE; +} + integer doThing(key id, string button, string fr, string cmd, string data, integer source) { integer set = -1; @@ -375,7 +438,7 @@ integer doThing(key id, string button, string fr, string cmd, string data, integ keys += "|COUPLE_WITH " + llList2String(b, i); names += "|" + llList2String(b, i + 2); } - dynamicMenu(Owner, "couples", What, " Pick someone to '" + What + "' with -", + dynamicMenu(Owner, menu, What, " Pick someone to '" + What + "' with -", llGetSubString(names, 1, -1), llGetSubString(keys, 1, -1)); PIN = (integer) llFrand(DEBUG_CHANNEL - 2) + 2; vector RefPos = llGetPos(); -- cgit v1.1