When an if statement is met it uses the integer as a string (I think) to do a simple llOwnerSay to announce the current value of the integer.
It then increments the integer in that block of the code with ++.
It works fine,
except I also need to set the number value of the integer from a captured listen (said by the owner only) in open chat so that the increment begins from that number from there on.
My problem I think is not knowing how to convert the string from open chat back into the integer. Whichever way I try I get a type mismatch error.
I thought I had it solved several times. I tried to use the prim description to capture the value, using llSetObjectDesc & llGetObjectDesc, but I kept getting the mismatch errors when I tried to llGetObjectDesc() into the new integer value.
I thought about using a list, but I need a few hundred possible numbers and I'm not even sure if that would solve the problem.
I have got the block of code that I want to use to change the integer value in a different state at the moment (not sure if it is necessary) but I still have the problem of how to set the value of the integer from the captured value from open chat.
This is the framework for it below. This works, but the resume only captures the open chat. So from that point, how do I set the numerical whole number value said by the user in open chat to the new value of the integer k so that the increment starts from the new value when k++ is triggered ?
CODE
integer menu_channel = -8925;
integer k =1;
integer listenkey;
list menu_main = ["Say","Reset","Cancel","Resume"];
default
{
state_entry()
{
llListen(menu_channel, "", llGetOwner(), "");
}
touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "Choose a button", menu_main, menu_channel);
}
changed(integer change)
{
if ( change & CHANGED_INVENTORY )
{
state default;
}
}
listen(integer channel, string name,key id, string message)
{
if (id == llGetOwner())
if (message == "Reset")
{
llOwnerSay("Reseting script...");
llDialog(id, "Choose a button", menu_main, menu_channel);
k= 1;
}
{
if (message == "Say")
{
llOwnerSay( "Number " + (string)k);
k++;
llDialog(id, "Choose a button", menu_main, menu_channel);
}
}
{
if (message == "Cancel")
{
llListenRemove(-8925);
}
}
{
if (message == "Resume")
{
state resume;
}
}
}
}
state resume
{
state_entry()
{
llOwnerSay( "What number do you want to resume from?");
listenkey = llListen(0,"",llGetOwner(),"");
}
listen(integer chatnel,string name,key id, string k)
{
if(ZERO_VECTOR != llGetAgentSize(id))
{
llOwnerSay("Number " + (string)k);
}
llDialog(id, "Choose a button", menu_main, menu_channel);
llListenRemove(listenkey);
state default;
}
}CODE
