Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

My script needs constant resetting

Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
06-24-2009 08:11
Hello,
I have this script I wrote that is used to contact greeters at a SIM. The greeter UUIDs are stored in a notecard. It seems that the script keeps freezing and i need to reset it manually about 4 times a week. I am trying to figure out where this might be locking up. One odd thing. I also have a few llSetPrimitiveParams in the script but somehow if I include them here, I get an HTTP 404 error when I post the thread, so I removed the instances (but I indicated where they are with //llSetPrimitiveParams ). I wonder if that is what is causing the problem since they are not happing inside this box. Thank you for having a look.

Dmitriy


CODE

//menu variables
integer menu_channel = -65877;
float seconds2wait;
string menu_message;
list menu_buttons;

//initialization variables
key caller_key;
string caller_name;
string config_notecard = "Greeters";
integer nLine;
key loadUUIDS;
key callGreeters;
integer count;

//dataserver variables
list temp;
string greeter_key;
string greeter_name;
list greeterUUIDS;
list greeterNames;


default
{
changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llOwnerSay("Greeter Notecard Updated");
llResetScript();
}
}


on_rez(integer start_param)
{
llOwnerSay("Greeter Data Loaded");
llResetScript();
}

state_entry()
{
if (llGetInventoryType(config_notecard) == INVENTORY_NOTECARD)
{
llOwnerSay("Notecard Data Loaded");
loadUUIDS = llGetNotecardLine(config_notecard, nLine );
}
else
{
llOwnerSay("Configuration notecard not found!");
}
llSetTouchText("Call");
menu_message = "Hi,\nYou are about to call for a Greeter.\n";
menu_message += "Are you sure you want to send this to all available Greeters?";
menu_buttons = ["YES", "NO"];
seconds2wait = 10.0;
}

touch_start(integer num_detected)
{
//llSetPrimitiveParams - I set this so the greeter call button is not full bright
caller_name = llDetectedName(0);
caller_key = llDetectedKey(0);
llSetTimerEvent(seconds2wait);
llListen(menu_channel, caller_name, caller_key, "");
llDialog(caller_key, "\n" + menu_message, menu_buttons, menu_channel);
}

listen(integer channel, string name, key ID, string message)
{
if (message == "NO")
{
llSetTimerEvent(0.0);
state default;
}
else if (message == "YES")
{
llSetTimerEvent(0.0);
llSetTimerEvent(seconds2wait);
//llSetPrimitiveParams - I set this so the greeter call button IS full bright
count = 0;
callGreeters = llRequestAgentData(llList2Key(greeterUUIDS, count), DATA_ONLINE);
llInstantMessage(caller_key, "Your call has been sent to the greeter group. If one is available, they will come shortly. Please be patient.");
}
}
dataserver( key queryid, string data )
{
if (queryid == loadUUIDS)
{
if (data != EOF)
{
temp = llCSV2List(data);
greeter_key = llList2String(temp,1);
greeter_name = llList2String(temp,0);
++nLine;
greeterUUIDS += greeter_key;
greeterNames += greeter_name;
loadUUIDS = llGetNotecardLine(config_notecard, nLine); //here.
}
}
if (queryid == callGreeters)
{
if (data == "1")
{
greeter_key = llList2String(greeterUUIDS,count);
llInstantMessage(greeter_key,caller_name + " requires assistance");
}
else
{
//llSay(0,(llList2String(greeterNames,count) + " is offline"));
}
if (count < llGetListLength(greeterUUIDS) - 1)
{
++count;
callGreeters = llRequestAgentData(llList2Key(greeterUUIDS, count), DATA_ONLINE);
}
else
{
//llSetPrimitiveParams - I set this so the greeter call button is not full bright
}
}
}
}
CODE
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
06-24-2009 08:36
You're probably trying to load too much data. Have you ever used llGetFreeMemory() to see how much you have left after loading your card?
_____________________
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
06-24-2009 10:16
Here is a revision using states; Not inworld to test it so I might have missed a bracket.
Got in-world and tested the script. I introduced some new errors. The removing the listen is the easiest solution.
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
06-24-2009 10:34
It appears you are opening a new listen with every touch event, there is a limit to the number of open listens a script can handle. You should close the old listen before opening the new one.

//declare variable
integer listen_handle;


llListenRemove(listen_handle);
listen_handle = llListen(menu_channel, caller_name, caller_key, "";);
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
06-24-2009 12:01
Insert some programmer style complaint here.
_____________________
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
06-24-2009 12:39
From: Darien Caldwell
Insert some programmer style complaint here.

/me was thinking along the same lines at first, but gave in and conformed.
For example the constants should be in the declaration and not the state_entry, was what I noticed at first, but it really didn't effect the script.
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
06-26-2009 08:16
Thank you very much. I added the llListenRemove and so far so good. I appreciate all the help. And any complaints I will gladly take as a learning experience while keeping the shame and embarrasment to myself :)