befor wanting to release it as a code snippet for others to use, i thought to see if it can be improved for efficiency
the memory usage is pritty low after going from list storage to parsing strings, lemme know what you think or where there`s room for optimization or some reordering for easy reading for the final post befor sharing it on the wiki (or where ever)
string dialog_text(string a, integer i)
{
string tmp = "";
if (count_total <= 11)
{
dialog_count = count_total + 1;
}
while (i < dialog_count)
{
integer z = i - 1;
tmp += parse(land_text, z);
i++;
}
return tmp;
}
list dialog_menu(string a, integer i)
{
list tmp = [];
if (count_total <= 11)
{
dialog_count = count_total + 1;
}
while (i < dialog_count)
{
tmp += (string)i;
i++;
}
if (count_total <= 11)
{
tmp += ["exit"];
} else {
tmp += ["<<"]+["exit"]+[">>"];
}
tmp = order_buttons(tmp);
return tmp;
}
string parse(string a, integer b)
{
list a = llParseString2List(a, ["|"],[]);
string cmd = llList2String(a, b);
return cmd;
}
integer i = 1;
integer dialog_page = 1;
integer dialog_count = 10;
integer count;
integer count_total = 0;
string myString; // items seperated by "|", 1|2|3|4|etc
string myText; // items seperated by "|", a|b|c|d|etc
default
{
state_entry()
{
llListen(dChannel, "", "", ""

}
link_message(integer sender_num, integer num, string str, key id)
{
proc = str;
if (parse(proc,0) == "start"

{
llDialog(usrNow,dialog_text(myText,i), dialog_menu(dialog_text,i), channel);
}
}
listen(integer channel, string name, key id, string mes)
{
if (mes == "<<"

{
if (dialog_page == 1)
{
dialog_page = 1 + llCeil(count_total/9);
dialog_count = count_total + 1;
i = 1 + (llCeil(count_total/9) * 9);
} else {
dialog_page = dialog_page - 1;
dialog_count = 1 + (dialog_page * 9);
i = i - 9;
}
llSetTimerEvent(60);
llDialog(usrNow,dialog_text("",i), dialog_menu(land_text,i), channel);
}
else if (mes == ">>"

{
if (dialog_page <= llCeil(count_total/9))
{
if (dialog_page == llFloor(count_total/9))
{
dialog_page = dialog_page + 1;
dialog_count = count_total + 1;
i = i + 9;
} else {
dialog_page = dialog_page + 1;
dialog_count = dialog_count + 9;
i = i + 9;
}
} else {
dialog_page = 1;
dialog_count = 10;
i = 1;
}
llSetTimerEvent(60);
llDialog(usrNow,dialog_text("",i), dialog_menu(myText,i), channel);
}
else if (mes == "exit"

{
llSetTimerEvent(1);
}
else
{
integer z = (integer)mes - 1;
if (parse(myList, z) != ""

{
llSay(0, "myString is: "+ parse(myList, z));
//do stuff here or LinkedMessage to a slave script
llSetTimerEvent(60);
} else {
llSay(0, "No such option."

llSetTimerEvent(1);
}
}
}
i make my text and button string by stroring it from multiple LinkedMessages and when getting a "done" message, execute the first dialog in the link_message so it might look abit strange
also must add that the count_total i get from the webserver with a check but that`s easilly done with llStringLength()

all i can say that for some reason it works flawlesly with just a handfull of options or +30 (test succeeded with 100 text entries and 100 options using only 11.02kb memory total(+some code)

