
I execute the following script to load in the settings in my notecard.
One of the lines is Avatar=<name>,<UUID>
The thing is I want to do a lookup if only the name is provided and no key.
Now I thought that would be easy, but it isn't working.... the llHttpRequest result isn't returned correctly if there are more than one Avatar= lines with only a name.. I assume because the code continues to execute while the httpRequest is being processed.
What should I do to correct this?
Thanks.
CODE
(Note: some of the variables referenced in this script are set outside this script, but they are set and are correct)
---------------------------
state readNotecard
{
state_entry()
{
llOwnerSay("Loading Configuration Notecard"
;llSetText("Loading",<1,1,1>, 1.0);
if (llGetInventoryType(sCONFIG_CARD) == INVENTORY_NOTECARD)
{
iLineCounter = 0;
lAvi_name=[];
lAvi_keyid=[];
lAvi_status=[];
kDataRequestID = llGetNotecardLine( sCONFIG_CARD, iLineCounter );
}
else
{
llOwnerSay("Configuration notecard missing, voice control only."
;iCard_loaded = FALSE;
state Running;
}
}
http_response(key kId, integer iStatus, list lMeta, string sBody)
{
if ( kId != kReqid )
{
return;
}
if ( iStatus == 499 )
{
llOwnerSay("name2key request timed out"
;}
else if ( iStatus != 200 )
{
llOwnerSay("the internet exploded!!"
;}
else if ( (key)sBody == NULL_KEY )
{
llOwnerSay("No key found for " + sAviName);
}
else
{
lAvi_keyid += [sBody];
return;
}
}
dataserver(key kQueryid, string sData)
{
if (kDataRequestID)
{
if (sData != EOF)
{
if( StringLeftICompare("PollInterval=", sData ) ){
iPollInterval = (integer)GetValue( sData );
llOwnerSay("Poll Interval set to " + (string)iPollInterval);
}
else if( StringLeftICompare( "Avatar=", sData ) ){
list lTemp = llParseString2List(sData,["Avatar","=",","],[]);
string sAviName=llStringTrim(llList2String(lTemp,0),STRING_TRIM);
lAvi_name += [sAviName];
sKeyID=llStringTrim(llList2String(lTemp,1),STRING_TRIM);
if (sKeyID==""
{kReqid = llHTTPRequest( sURL + "?terse=1&name="+llEscapeURL(sAviName), [], "" );
}
else {
lAvi_keyid += [sKeyID];
}
lAvi_status += ["OFFLINE"];
}
iLineCounter +=1;
kDataRequestID = llGetNotecardLine(sCONFIG_CARD, iLineCounter);
}
else
{
llOwnerSay("Loading Complete, " + (string)llGetListLength(lAvi_name) + " avatars loaded."
;llSetText("Config Loaded",<1,1,1>, 1.0);
iCard_loaded = TRUE;
state Running;
}
}
}
}