diff options
author | onefang | 2021-09-06 21:15:36 +1000 |
---|---|---|
committer | onefang | 2021-09-06 21:15:36 +1000 |
commit | 10e2f77d57ecc5e306900b112d70c2600f941ae4 (patch) | |
tree | e634b6ac7d20886b9fe256b8c69696a011e4e0b6 /1chatter.lsl | |
parent | Oops, left this out of the OhSilly sit commit. (diff) | |
download | 1ring-10e2f77d57ecc5e306900b112d70c2600f941ae4.zip 1ring-10e2f77d57ecc5e306900b112d70c2600f941ae4.tar.gz 1ring-10e2f77d57ecc5e306900b112d70c2600f941ae4.tar.bz2 1ring-10e2f77d57ecc5e306900b112d70c2600f941ae4.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | 1chatter.lsl | 73 |
1 files changed, 63 insertions, 10 deletions
diff --git a/1chatter.lsl b/1chatter.lsl index 9970462..b41df53 100644 --- a/1chatter.lsl +++ b/1chatter.lsl | |||
@@ -38,6 +38,8 @@ integer lSUBSTITUTE = -7; | |||
38 | integer lSUBSTITUTE_DONE = -8; | 38 | integer lSUBSTITUTE_DONE = -8; |
39 | integer lNEXT_WORD = -9; | 39 | integer lNEXT_WORD = -9; |
40 | integer lNEXT_WORD_DONE = -10; | 40 | integer lNEXT_WORD_DONE = -10; |
41 | integer lCHECK = -11; | ||
42 | integer lCHECK_DONE = -12; | ||
41 | integer lCONTROL = -13; | 43 | integer lCONTROL = -13; |
42 | integer lCONTROL_DONE = -14; | 44 | integer lCONTROL_DONE = -14; |
43 | integer lCMD = -15; | 45 | integer lCMD = -15; |
@@ -52,6 +54,7 @@ d(string m) {if (DEBUG) llInstantMessage(Owner, llGetScriptName() + ": " + m);} | |||
52 | D(string m) {llRegionSay(DEBUG_CHANNEL, llGetScriptName() + ": " + m);} | 54 | D(string m) {llRegionSay(DEBUG_CHANNEL, llGetScriptName() + ": " + m);} |
53 | s(string m) {s(Owner, m);} | 55 | s(string m) {s(Owner, m);} |
54 | s(key id, string m) {if (id == Owner) llOwnerSay(m); else llInstantMessage(id, m);} | 56 | s(key id, string m) {if (id == Owner) llOwnerSay(m); else llInstantMessage(id, m);} |
57 | S(string m) {llInstantMessage(Owner, llGetScriptName() + ": " + m);} | ||
55 | sendScript(integer cmd, list args) {sendScript(LibraryKey, cmd, ScriptName, args);} | 58 | sendScript(integer cmd, list args) {sendScript(LibraryKey, cmd, ScriptName, args);} |
56 | sendScript(key them, integer cmd, list args) {sendScript(them, cmd, inKey2Name(them), args);} | 59 | sendScript(key them, integer cmd, list args) {sendScript(them, cmd, inKey2Name(them), args);} |
57 | sendScript(integer cmd, string name, list args) {sendScript(LibraryKey, cmd, name, args);} | 60 | sendScript(integer cmd, string name, list args) {sendScript(LibraryKey, cmd, name, args);} |
@@ -59,7 +62,12 @@ sendScript(key them, integer cmd, string name, list args) | |||
59 | { | 62 | { |
60 | llMessageLinked(LINK_SET, cmd, llDumpList2String([ScriptKey, name] + args, lSEP), them); | 63 | llMessageLinked(LINK_SET, cmd, llDumpList2String([ScriptKey, name] + args, lSEP), them); |
61 | } | 64 | } |
62 | sendPrim(key them, string cmd, list args) {osMessageObject(them, llDumpList2String([ScriptName] + args, lSEP));} | 65 | integer pingPrim(key k) |
66 | { | ||
67 | if (NULL_KEY != k) return (0 != llGetListLength(llGetObjectDetails(k, [OBJECT_DESC]))); | ||
68 | return FALSE; | ||
69 | } | ||
70 | sendPrim(key them, string cmd, list args) {if (pingPrim(them)) osMessageObject(them, llDumpList2String([ScriptName] + args, lSEP));} | ||
63 | 71 | ||
64 | string inKey2Name(key k) | 72 | string inKey2Name(key k) |
65 | { | 73 | { |
@@ -596,16 +604,47 @@ addMenuItem(string fr, string menu, string cmd, list args) | |||
596 | e += getToggle(fr, llList2String(args, 0)); | 604 | e += getToggle(fr, llList2String(args, 0)); |
597 | else | 605 | else |
598 | e += llList2String(args, 0); | 606 | e += llList2String(args, 0); |
599 | if ("TOMENU" == cmd) e += "…"; | 607 | if ("TOMENU" == cmd) |
608 | e += "…"; | ||
609 | else if ("TOGGLE" == cmd) | ||
610 | { | ||
611 | string cm = llList2String(args, 0); | ||
612 | if (-1 == listFindString(Settings, fr + llToUpper(cm), sSTRIDE)) | ||
613 | d("ERROR! Not found setting " + fr + cm + "!"); | ||
614 | } | ||
615 | else if ("BUTTON" == cmd) | ||
616 | { | ||
617 | string cm = llList2String(args, 1); | ||
618 | |||
619 | if (-1 == listFindString(Commands, fr + llToUpper(cm), cSTRIDE)) | ||
620 | d("ERROR! Not found command " + fr + " " + cm + "!"); | ||
621 | else | ||
622 | { | ||
623 | sendScript(getSetting(fr + "SCRIPTKEY"), lCHECK, fr, | ||
624 | [fCARD, LibraryKey, menu, cm, | ||
625 | llDumpList2String(llListReplaceList(args, [], 0, 1), "|")]); | ||
626 | } | ||
627 | } | ||
628 | else | ||
629 | { | ||
630 | if (-1 == listFindString(Commands, fr + llToUpper(cmd), cSTRIDE)) | ||
631 | d("ERROR! Not found command " + fr + cmd + "!"); | ||
632 | else | ||
633 | { | ||
634 | sendScript(getSetting(fr + "SCRIPTKEY"), lCHECK, fr, | ||
635 | [fCARD, LibraryKey, menu, cmd, | ||
636 | llDumpList2String(llListReplaceList(args, [], 0, 0), "|")]); | ||
637 | } | ||
638 | } | ||
600 | c += llDumpList2String(llListReplaceList(args, [], 0, 0), " "); | 639 | c += llDumpList2String(llListReplaceList(args, [], 0, 0), " "); |
601 | saveMenu(menu, llList2String(Menus, f + mTITLE), llList2Integer(Menus, f + mAUTH), e, c, llList2Integer(Menus, f + mDYN)); | 640 | saveMenu(menu, llList2String(Menus, f + mTITLE), llList2Integer(Menus, f + mAUTH), e, c, llList2Integer(Menus, f + mDYN)); |
602 | } | 641 | } |
603 | } | 642 | } |
604 | 643 | ||
605 | dynamicMenu(key id, string menu, string name, string title, string entries, string command) | 644 | dynamicMenu(key id, string menu, string name, string title, string entries, string command, integer ret) |
606 | { | 645 | { |
607 | //d("dynamicMenu " + menu + " -> " + name + "\n" + id + "@" + name); | 646 | //d("dynamicMenu " + menu + " -> " + name + "\n" + id + "@" + name); |
608 | saveMenu(id + "@" + name, title, aALL, entries, command, TRUE); | 647 | saveMenu(id + "@" + name, title, aALL, entries, command, ret); |
609 | saveMuser(id, id + "@" + name, entries, -1, menu); | 648 | saveMuser(id, id + "@" + name, entries, -1, menu); |
610 | showMenu(id); | 649 | showMenu(id); |
611 | } | 650 | } |
@@ -785,7 +824,7 @@ showMenu(key id) | |||
785 | integer l = llGetListLength(entries); | 824 | integer l = llGetListLength(entries); |
786 | integer n; | 825 | integer n; |
787 | 826 | ||
788 | if (llList2Integer(Menus, m + mDYN)) | 827 | if (dM) |
789 | { | 828 | { |
790 | for (; n < l; ++n) | 829 | for (; n < l; ++n) |
791 | { | 830 | { |
@@ -912,10 +951,11 @@ integer handleMenu(integer f, key id, string button) | |||
912 | list lst; | 951 | list lst; |
913 | integer page = llList2Integer(Musers, f + uPAGE); | 952 | integer page = llList2Integer(Musers, f + uPAGE); |
914 | integer m = findMenu(menu); // This was already checked before it was stuffed into Musers. | 953 | integer m = findMenu(menu); // This was already checked before it was stuffed into Musers. |
954 | integer dm = llList2Integer(Menus, m + mDYN); | ||
915 | integer e = 0; | 955 | integer e = 0; |
916 | 956 | ||
917 | //d("handleMenu(" + llKey2Name(id) + "," + button + ") " + menu + " -> " + cmd); | 957 | //d("handleMenu(" + llKey2Name(id) + "," + button + ") " + menu + " -> " + cmd); |
918 | if (llList2Integer(Menus, m + mDYN)) | 958 | if (dm) |
919 | dM = menu; | 959 | dM = menu; |
920 | // Find the corresponding command for this button. | 960 | // Find the corresponding command for this button. |
921 | lst = llParseStringKeepNulls(llList2String(Menus, m + mCMDS), ["|"], []); | 961 | lst = llParseStringKeepNulls(llList2String(Menus, m + mCMDS), ["|"], []); |
@@ -1023,7 +1063,7 @@ d("handleMenu(" + llKey2Name(id) + "," + button + ") " + menu + " -> " + fr + cm | |||
1023 | f = listFindString(Commands, fr + cmd, cSTRIDE); | 1063 | f = listFindString(Commands, fr + cmd, cSTRIDE); |
1024 | if (-1 != f) | 1064 | if (-1 != f) |
1025 | i = doThing(id, menu + "->" + button, fr, cmd, data, fMENU); | 1065 | i = doThing(id, menu + "->" + button, fr, cmd, data, fMENU); |
1026 | if ("" != dM) | 1066 | if ((dm != 2) && ("" != dM)) |
1027 | lastMenu(id, dM); | 1067 | lastMenu(id, dM); |
1028 | return i; | 1068 | return i; |
1029 | } | 1069 | } |
@@ -1031,6 +1071,12 @@ d("handleMenu(" + llKey2Name(id) + "," + button + ") " + menu + " -> " + fr + cm | |||
1031 | return TRUE; | 1071 | return TRUE; |
1032 | } | 1072 | } |
1033 | 1073 | ||
1074 | integer checkThing(key id, string button, string fr, string cmd, string data, integer source) | ||
1075 | { | ||
1076 | if ((fr != (ScriptName + ".") && ("*." != fr))) return FALSE; | ||
1077 | return TRUE; | ||
1078 | } | ||
1079 | |||
1034 | integer doThing(key id, string command, string fr, string cmd, string data, integer source) | 1080 | integer doThing(key id, string command, string fr, string cmd, string data, integer source) |
1035 | { | 1081 | { |
1036 | if ("*.." == fr) return TRUE; | 1082 | if ("*.." == fr) return TRUE; |
@@ -1386,6 +1432,12 @@ fr="1AOor2"; | |||
1386 | } | 1432 | } |
1387 | } | 1433 | } |
1388 | } | 1434 | } |
1435 | else if (lCHECK_DONE == num) | ||
1436 | { | ||
1437 | //d("lCHECK_DONE " + llKey2Name(llList2Key(input, 3)) + " -> " + llList2String(input, 2) + "| returned " + llList2String(input, 4)); | ||
1438 | if (!llList2Integer(input, 4)) | ||
1439 | S("ERROR - Invalid command for " + llList2String(input, 2)); | ||
1440 | } | ||
1389 | else if (lCMD == num) | 1441 | else if (lCMD == num) |
1390 | { | 1442 | { |
1391 | doThing(llList2Key(input, 3), llList2String(input, 4), fr + ".", | 1443 | doThing(llList2Key(input, 3), llList2String(input, 4), fr + ".", |
@@ -1400,10 +1452,11 @@ fr="1AOor2"; | |||
1400 | else if (lDYNAMIC == num) | 1452 | else if (lDYNAMIC == num) |
1401 | { | 1453 | { |
1402 | string menu = llList2String(input, 3); | 1454 | string menu = llList2String(input, 3); |
1403 | if ("" != menu) | 1455 | integer f = llSubStringIndex(menu, "."); |
1456 | if (("" != menu) && (-1 == f)) | ||
1404 | menu = fr + "." + menu; | 1457 | menu = fr + "." + menu; |
1405 | dynamicMenu(llList2Key(input, 2), menu, fr + "." + llList2String(input, 4), | 1458 | dynamicMenu(llList2Key(input, 2), menu, fr + "." + llList2String(input, 4), |
1406 | llList2String(input, 5), llList2String(input, 6), llList2String(input, 7)); | 1459 | llList2String(input, 5), llList2String(input, 6), llList2String(input, 7), llList2Integer(input, 8)); |
1407 | } | 1460 | } |
1408 | else if (lMENU == num) | 1461 | else if (lMENU == num) |
1409 | { | 1462 | { |
@@ -1527,7 +1580,7 @@ d("listen 1ring.CHANNEL " + message + " -> " + button + " " + cmd + " " + data); | |||
1527 | llSensor("", NULL_KEY, llList2Integer(Scanners, nTYPE), 100.0, PI); | 1580 | llSensor("", NULL_KEY, llList2Integer(Scanners, nTYPE), 100.0, PI); |
1528 | dynamicMenu(id, menu, menu, | 1581 | dynamicMenu(id, menu, menu, |
1529 | llList2String(Scanners, nTITLE), | 1582 | llList2String(Scanners, nTITLE), |
1530 | llDumpList2String(items, "|"), llDumpList2String(keys, "|")); | 1583 | llDumpList2String(items, "|"), llDumpList2String(keys, "|"), 2); |
1531 | } | 1584 | } |
1532 | } | 1585 | } |
1533 | 1586 | ||