Push latest changes
This commit is contained in:
parent
aa26ff7406
commit
17262bdaf0
2 changed files with 154 additions and 16 deletions
130
Next Engine.lsl
130
Next Engine.lsl
|
@ -37,6 +37,50 @@ string EXIT_MENU = "-exit-";
|
||||||
string NEXT_MENU = "-->";
|
string NEXT_MENU = "-->";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
integer g_iDebugIndent=0;
|
||||||
|
|
||||||
|
|
||||||
|
DEBUG_FUNC(integer iEnter, string sLabel, list lParams) {
|
||||||
|
if(iEnter){
|
||||||
|
llOwnerSay(MakeIndent() + "ENTER " + sLabel + " [" + llList2CSV(lParams) + "]");
|
||||||
|
g_iDebugIndent++;
|
||||||
|
} else {
|
||||||
|
g_iDebugIndent --;
|
||||||
|
if(g_iDebugIndent<0)g_iDebugIndent=0;
|
||||||
|
|
||||||
|
llOwnerSay(MakeIndent() + "LEAVE " + sLabel + " [" + llList2CSV(lParams) + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_STMT(integer iEnter, string sLabel) {
|
||||||
|
if(iEnter) {
|
||||||
|
llOwnerSay(MakeIndent() + "STMT " + sLabel);
|
||||||
|
g_iDebugIndent ++;
|
||||||
|
}else {
|
||||||
|
g_iDebugIndent--;
|
||||||
|
if(g_iDebugIndent<0)g_iDebugIndent=0;
|
||||||
|
|
||||||
|
llOwnerSay(MakeIndent() + "RET " + sLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG(string sMsg) {
|
||||||
|
llOwnerSay(MakeIndent() + " > " + sMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
string MakeIndent()
|
||||||
|
{
|
||||||
|
integer i = 0;
|
||||||
|
string sIndent = "";
|
||||||
|
for(i = 0;i<g_iDebugIndent;i++){
|
||||||
|
sIndent += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "[" + llGetScriptName() + "] " + sIndent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string SLURL(key kID){
|
string SLURL(key kID){
|
||||||
return "secondlife:///app/agent/"+(string)kID+"/about";
|
return "secondlife:///app/agent/"+(string)kID+"/about";
|
||||||
}
|
}
|
||||||
|
@ -258,6 +302,7 @@ integer calcMaxPages(string sMenu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
string getPage(string sMenu, integer iPage, integer iCheckUUID) {
|
string getPage(string sMenu, integer iPage, integer iCheckUUID) {
|
||||||
|
DEBUG_FUNC(TRUE, "getPage", [sMenu, iPage, iCheckUUID]);
|
||||||
// Retrieve buttons and utility lists from JSON
|
// Retrieve buttons and utility lists from JSON
|
||||||
list lButtons = llJson2List(llJsonGetValue(sMenu, ["buttons"]));
|
list lButtons = llJson2List(llJsonGetValue(sMenu, ["buttons"]));
|
||||||
list lUtility = llJson2List(llJsonGetValue(sMenu, ["utility"]));
|
list lUtility = llJson2List(llJsonGetValue(sMenu, ["utility"]));
|
||||||
|
@ -298,7 +343,7 @@ string getPage(string sMenu, integer iPage, integer iCheckUUID) {
|
||||||
i =0;
|
i =0;
|
||||||
integer end = llGetListLength(lPageButtons);
|
integer end = llGetListLength(lPageButtons);
|
||||||
integer idNum = 0;
|
integer idNum = 0;
|
||||||
string sExtraText = "";
|
string sExtraText = " ";
|
||||||
for(i=0;i<end;i++) {
|
for(i=0;i<end;i++) {
|
||||||
string sButton = llList2String(lPageButtons, i);
|
string sButton = llList2String(lPageButtons, i);
|
||||||
if(IsLikelyAvatarID(sButton)) {
|
if(IsLikelyAvatarID(sButton)) {
|
||||||
|
@ -310,7 +355,10 @@ string getPage(string sMenu, integer iPage, integer iCheckUUID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@returnMenu;
|
@returnMenu;
|
||||||
return llList2Json(JSON_OBJECT, ["text", sExtraText, "buttons", "~!~" + llDumpList2String(lPageButtons, "~!~") + "~!~"]);
|
DEBUG("Buttons list: " + llList2CSV(lPageButtons));
|
||||||
|
string jsReply=llList2Json(JSON_OBJECT, ["text", sExtraText, "buttons", "~!~" + llDumpList2String(lPageButtons, "~!~") + "~!~"]);
|
||||||
|
DEBUG_FUNC(FALSE, "getPage", [jsReply]);
|
||||||
|
return jsReply;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendMenuButton(string sMenu, string sButton) {
|
AppendMenuButton(string sMenu, string sButton) {
|
||||||
|
@ -355,17 +403,25 @@ default
|
||||||
|
|
||||||
listen(integer c,string n,key i,string m) {
|
listen(integer c,string n,key i,string m) {
|
||||||
// Get the menu path
|
// Get the menu path
|
||||||
|
DEBUG_FUNC(TRUE, "listen", [i,m]);
|
||||||
|
|
||||||
string sMenuID = getMenuID(i);
|
string sMenuID = getMenuID(i);
|
||||||
|
|
||||||
// Get the current page number
|
// Get the current page number
|
||||||
integer iPage = getPageNumber(i);
|
integer iPage = getPageNumber(i);
|
||||||
|
DEBUG("Get current page number for menu " + sMenuID + ": " + (string)iPage);
|
||||||
|
|
||||||
string sMenu = "";
|
string sMenu = "";
|
||||||
|
|
||||||
if(sMenuID != "") readMenu(sMenuID);
|
if(sMenuID != "") sMenu = readMenu(sMenuID);
|
||||||
integer iMaxPages = calcMaxPages(sMenu);
|
DEBUG("Menu Json: " + sMenu);
|
||||||
|
|
||||||
|
integer iMaxPages = 0;
|
||||||
|
if(sMenuID != "") iMaxPages = calcMaxPages(sMenu);
|
||||||
|
DEBUG("Get max number of pages: " + (string)iMaxPages);
|
||||||
|
|
||||||
if(m == PREVIOUS_MENU) {
|
if(m == PREVIOUS_MENU) {
|
||||||
|
DEBUG_STMT(TRUE, "Previous Menu");
|
||||||
// Update the time remaining
|
// Update the time remaining
|
||||||
updateTimer(i, MENU_TIMER);
|
updateTimer(i, MENU_TIMER);
|
||||||
|
|
||||||
|
@ -373,7 +429,7 @@ default
|
||||||
|
|
||||||
if(iPage < 0) iPage=0;
|
if(iPage < 0) iPage=0;
|
||||||
|
|
||||||
string sPage = getPage(sMenuID, iPage, TRUE);
|
string sPage = getPage(sMenu, iPage, TRUE);
|
||||||
|
|
||||||
list lPageButtons = llParseString2List(llJsonGetValue(sPage, ["buttons"]), ["~!~"], []);
|
list lPageButtons = llParseString2List(llJsonGetValue(sPage, ["buttons"]), ["~!~"], []);
|
||||||
|
|
||||||
|
@ -382,7 +438,9 @@ default
|
||||||
|
|
||||||
if(iMaxPages > 1) sAppend += "\n\nPage " + (string)iPage + "/" + (string)(iMaxPages-1);
|
if(iMaxPages > 1) sAppend += "\n\nPage " + (string)iPage + "/" + (string)(iMaxPages-1);
|
||||||
llDialog(i, llJsonGetValue(sMenu, ["prompt"]) + sAppend, lPageButtons, getChannel(i));
|
llDialog(i, llJsonGetValue(sMenu, ["prompt"]) + sAppend, lPageButtons, getChannel(i));
|
||||||
|
DEBUG_STMT(FALSE, "Previous Menu");
|
||||||
} else if(m == NEXT_MENU) {
|
} else if(m == NEXT_MENU) {
|
||||||
|
DEBUG_STMT(TRUE, "Next Menu");
|
||||||
// Update the time remaining
|
// Update the time remaining
|
||||||
updateTimer(i, MENU_TIMER);
|
updateTimer(i, MENU_TIMER);
|
||||||
|
|
||||||
|
@ -390,7 +448,7 @@ default
|
||||||
|
|
||||||
if(iPage < iMaxPages-1) iPage=iMaxPages-1;
|
if(iPage < iMaxPages-1) iPage=iMaxPages-1;
|
||||||
|
|
||||||
string sPage = getPage(sMenuID, iPage, TRUE);
|
string sPage = getPage(sMenu, iPage, TRUE);
|
||||||
|
|
||||||
list lPageButtons = llParseString2List(llJsonGetValue(sPage, ["buttons"]), ["~!~"], []);
|
list lPageButtons = llParseString2List(llJsonGetValue(sPage, ["buttons"]), ["~!~"], []);
|
||||||
|
|
||||||
|
@ -399,11 +457,13 @@ default
|
||||||
|
|
||||||
if(iMaxPages > 1) sAppend += "\n\nPage " + (string)iPage + "/" + (string)(iMaxPages-1);
|
if(iMaxPages > 1) sAppend += "\n\nPage " + (string)iPage + "/" + (string)(iMaxPages-1);
|
||||||
llDialog(i, llJsonGetValue(sMenu, ["prompt"]) + sAppend, lPageButtons, getChannel(i));
|
llDialog(i, llJsonGetValue(sMenu, ["prompt"]) + sAppend, lPageButtons, getChannel(i));
|
||||||
|
DEBUG_STMT(FALSE, "Next Menu");
|
||||||
} else if(m == " ") {
|
} else if(m == " ") {
|
||||||
|
DEBUG_STMT(TRUE, "Empty Button");
|
||||||
// Update the time remaining
|
// Update the time remaining
|
||||||
updateTimer(i, MENU_TIMER);
|
updateTimer(i, MENU_TIMER);
|
||||||
|
|
||||||
string sPage = getPage(sMenuID, iPage, TRUE);
|
string sPage = getPage(sMenu, iPage, TRUE);
|
||||||
|
|
||||||
list lPageButtons = llParseString2List(llJsonGetValue(sPage, ["buttons"]), ["~!~"], []);
|
list lPageButtons = llParseString2List(llJsonGetValue(sPage, ["buttons"]), ["~!~"], []);
|
||||||
|
|
||||||
|
@ -412,13 +472,51 @@ default
|
||||||
|
|
||||||
if(iMaxPages > 1) sAppend += "\n\nPage " + (string)iPage + "/" + (string)(iMaxPages-1);
|
if(iMaxPages > 1) sAppend += "\n\nPage " + (string)iPage + "/" + (string)(iMaxPages-1);
|
||||||
llDialog(i, llJsonGetValue(sMenu, ["prompt"]) + sAppend, lPageButtons, getChannel(i));
|
llDialog(i, llJsonGetValue(sMenu, ["prompt"]) + sAppend, lPageButtons, getChannel(i));
|
||||||
|
DEBUG_STMT(FALSE, "Empty Button");
|
||||||
} else if(m == EXIT_MENU) {
|
} else if(m == EXIT_MENU) {
|
||||||
|
DEBUG_STMT(TRUE, "Exit Menu");
|
||||||
stopListen(i);
|
stopListen(i);
|
||||||
|
DEBUG_STMT(FALSE, "Exit Menu");
|
||||||
} else {
|
} else {
|
||||||
|
DEBUG_STMT(TRUE, "Process Response");
|
||||||
// Stop listening, and send a signal
|
// Stop listening, and send a signal
|
||||||
string sPage = getPage(sMenuID, iPage, FALSE);
|
string sPage = "";
|
||||||
|
if(sMenu != "") sPage = getPage(sMenu, iPage, FALSE);
|
||||||
|
|
||||||
|
DEBUG("Parse Buttons");
|
||||||
|
// Check Message, if message is found in list, it isn't UUID.
|
||||||
|
// If message is not found, it is likely uuid
|
||||||
|
list lButtons = llParseString2List(llJsonGetValue(sPage, ["buttons"]), ["~!~"], []);
|
||||||
|
integer iIndex = llListFindList(lButtons, [m]);
|
||||||
|
|
||||||
|
DEBUG("Buttons : " + llDumpList2String(lButtons, " ~ "));
|
||||||
|
|
||||||
|
if(iIndex==-1 && sMenuID != "") {
|
||||||
|
// Loop over to find the index
|
||||||
|
integer iIDNum = (integer)m;
|
||||||
|
integer x = 0;
|
||||||
|
integer xe = llGetListLength(lButtons);
|
||||||
|
integer iID = 0;
|
||||||
|
for(x=0;x<xe;x++) {
|
||||||
|
string sButton = llList2String(lButtons, x);
|
||||||
|
if(IsLikelyAvatarID(sButton)) {
|
||||||
|
if(iIDNum == iID) {
|
||||||
|
llOwnerSay("Send button response signal over LM");
|
||||||
|
}
|
||||||
|
|
||||||
|
iID ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
llOwnerSay("Send button response signal over LM");
|
||||||
|
// Send reply signal
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_STMT(FALSE, "Process Response");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG_FUNC(FALSE, "listen", []);
|
||||||
}
|
}
|
||||||
|
|
||||||
link_message(integer s,integer n,string m,key i) {
|
link_message(integer s,integer n,string m,key i) {
|
||||||
|
@ -427,29 +525,29 @@ default
|
||||||
startListen(i, iChan, "", "", GENERAL_TIMER);
|
startListen(i, iChan, "", "", GENERAL_TIMER);
|
||||||
llMessageLinked(LINK_SET, LINK_SIGNAL_CHANNEL_BACK, (string)iChan, "");
|
llMessageLinked(LINK_SET, LINK_SIGNAL_CHANNEL_BACK, (string)iChan, "");
|
||||||
} else if(n == LINK_SIGNAL_SHOW_MENU) {
|
} else if(n == LINK_SIGNAL_SHOW_MENU) {
|
||||||
string sMenu = readMenu(llJsonGetValue(m,["menu"]));
|
string jsMenu = readMenu(llJsonGetValue(m,["menu"]));
|
||||||
integer iChan = generateChannel(FALSE);
|
integer iChan = generateChannel(FALSE);
|
||||||
|
|
||||||
startListen(i, iChan, m, llJsonGetValue(sMenu, ["prompt"]), MENU_TIMER);
|
startListen(i, iChan, llJsonGetValue(m,["menu"]), llJsonGetValue(jsMenu, ["prompt"]), MENU_TIMER);
|
||||||
|
|
||||||
// Show the dialog window now after constructing pages if needed.
|
// Show the dialog window now after constructing pages if needed.
|
||||||
integer maxPages = calcMaxPages(sMenu);
|
integer maxPages = calcMaxPages(jsMenu);
|
||||||
// Now show the dialog for page 1
|
// Now show the dialog for page 1
|
||||||
integer iPage = 1;
|
integer iPage = 1;
|
||||||
if(jsonValueExists(m, ["page"])) iPage = (integer)llJsonGetValue(m,["page"]);
|
if(jsonValueExists(m, ["page"])) iPage = (integer)llJsonGetValue(m,["page"]);
|
||||||
|
|
||||||
string sPage = getPage(sMenu, iPage, TRUE);
|
string jsPage = getPage(jsMenu, iPage, TRUE);
|
||||||
list lPageButtons = llParseString2List(llJsonGetValue(sPage, ["buttons"]), ["~!~"], []);
|
list lPageButtons = llParseString2List(llJsonGetValue(jsPage, ["buttons"]), ["~!~"], []);
|
||||||
|
|
||||||
updatePage(i, iPage);
|
updatePage(i, iPage);
|
||||||
string sAppend = llJsonGetValue(sPage, ["text"]);
|
string sAppend = llJsonGetValue(jsPage, ["text"]);
|
||||||
|
|
||||||
if(maxPages>1) sAppend += "\n\nPage " + (string)iPage+"/" + (string)(maxPages-1);
|
if(maxPages>1) sAppend += "\n\nPage " + (string)iPage+"/" + (string)(maxPages-1);
|
||||||
|
|
||||||
//llOwnerSay("DEBUG\n" + llJsonGetValue(sMenu, ["prompt"]) + sAppend + "\n\n" + llJsonGetValue(sPage, ["buttons"]));
|
//llOwnerSay("DEBUG\n" + llJsonGetValue(sMenu, ["prompt"]) + sAppend + "\n\n" + llJsonGetValue(sPage, ["buttons"]));
|
||||||
|
|
||||||
|
|
||||||
llDialog(i, llJsonGetValue(sMenu, ["prompt"])+sAppend, lPageButtons, getChannel(i));
|
llDialog(i, llJsonGetValue(jsMenu, ["prompt"])+sAppend, lPageButtons, getChannel(i));
|
||||||
} else if(n == LINK_SIGNAL_REGISTER_MENU) {
|
} else if(n == LINK_SIGNAL_REGISTER_MENU) {
|
||||||
string sMenuJson = llLinksetDataRead("menus." + (string)i);
|
string sMenuJson = llLinksetDataRead("menus." + (string)i);
|
||||||
if(sMenuJson == "" ) {
|
if(sMenuJson == "" ) {
|
||||||
|
@ -460,7 +558,7 @@ default
|
||||||
}else sMenuJson = AddMenuButton(sMenuJson, m);
|
}else sMenuJson = AddMenuButton(sMenuJson, m);
|
||||||
|
|
||||||
llLinksetDataWrite("menus."+(string)i, sMenuJson);
|
llLinksetDataWrite("menus."+(string)i, sMenuJson);
|
||||||
llSleep(0.1);
|
llSleep(0.5);
|
||||||
llMessageLinked(LINK_SET, LINK_SIGNAL_QUERY_MENU, (string)i + "/" + m, "");
|
llMessageLinked(LINK_SET, LINK_SIGNAL_QUERY_MENU, (string)i + "/" + m, "");
|
||||||
} else if(n == LINK_SIGNAL_RESET) {
|
} else if(n == LINK_SIGNAL_RESET) {
|
||||||
llResetScript();
|
llResetScript();
|
||||||
|
|
|
@ -59,4 +59,44 @@ SetMenuPrompt(string sMenu, string sPromptText) {
|
||||||
|
|
||||||
showMenu(key kID, string sMenu, integer iPage) {
|
showMenu(key kID, string sMenu, integer iPage) {
|
||||||
llMessageLinked(LINK_SET, LINK_SIGNAL_SHOW_MENU, llList2Json(JSON_OBJECT, ["menu", sMenu, "page", iPage]), kID);
|
llMessageLinked(LINK_SET, LINK_SIGNAL_SHOW_MENU, llList2Json(JSON_OBJECT, ["menu", sMenu, "page", iPage]), kID);
|
||||||
|
}
|
||||||
|
|
||||||
|
integer g_iDebugIndent=0;
|
||||||
|
DEBUG_FUNC(integer iEnter, string sLabel, list lParams) {
|
||||||
|
if(iEnter){
|
||||||
|
llOwnerSay(MakeIndent() + "ENTER " + sLabel + " [" + llList2CSV(lParams) + "]");
|
||||||
|
g_iDebugIndent++;
|
||||||
|
} else {
|
||||||
|
g_iDebugIndent --;
|
||||||
|
if(g_iDebugIndent<0)g_iDebugIndent=0;
|
||||||
|
|
||||||
|
llOwnerSay(MakeIndent() + "LEAVE " + sLabel + " [" + llList2CSV(lParams) + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_STMT(integer iEnter, string sLabel) {
|
||||||
|
if(iEnter) {
|
||||||
|
llOwnerSay(MakeIndent() + "STMT " + sLabel);
|
||||||
|
g_iDebugIndent ++;
|
||||||
|
}else {
|
||||||
|
g_iDebugIndent--;
|
||||||
|
if(g_iDebugIndent<0)g_iDebugIndent=0;
|
||||||
|
|
||||||
|
llOwnerSay(MakeIndent() + "RET " + sLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG(string sMsg) {
|
||||||
|
llOwnerSay(MakeIndent() + " > " + sMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
string MakeIndent()
|
||||||
|
{
|
||||||
|
integer i = 0;
|
||||||
|
string sIndent = "";
|
||||||
|
for(i = 0;i<g_iDebugIndent;i++){
|
||||||
|
sIndent += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "[" + llGetScriptName() + "] " + sIndent;
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue