Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Data Server

Lazersam Hax
Registered User
Join date: 2 Jun 2007
Posts: 9
10-25-2008 04:31
CODE

default
{
touch_start(integer num_detected)
{
llRequestAgentData(llDetectedKey(0), DATA_ONLINE);
}
dataserver(key queryid, string data)
{
llSay(0, "DATA_ONLINE: " + data);
}
}


I have a script similar to this running in SL.. thing is, it is resulting in "1" even when the avartar is offline! Anyone know why? How can I check for this error?

Cheers

P.S. This is not the actual script that is erroring - how could I touch the object whilst being offline lol.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-25-2008 06:34
it's requesting the data of the avatar that touches it, there's no way an avatar can touch something if they're not online. are you trying to get the status of the owner? trry changing llDetectedKey to llGetOwner, and then use an alt or ask a friend to touch the box when you are both offline and online to see what it says
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
10-25-2008 07:43
It's hard to suggest why a different script "similar" to that one might not be working right, as there's any number of potential problems. Could you post the original? Or at least a snippet of it?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-25-2008 13:01
A couple of things that might be relevant.

It takes some time after an agent logs out before llRequestAgentData() returns false for DATA_ONLINE. The amount of time varies at random, so far as I can tell, but I've seen it lag update to the friends list by several minutes.

The other thing is that the dataserver event is triggered for every script in the prim, so if there's another script also doing dataserver stuff, the event will be raised in this script, too, so if you don't test for matching queryid, you can't tell whose request is being answered. (This wouldn't make llRequestAgentData() behave any worse than normal w.r.t. lagging logoff, but it might cause the script to observe it when you didn't intend for it to be triggered.)

But, yeah, without seeing the code, this is a pretty tough guessing game. ;)
_____________________
Archived for Your Protection
Lazersam Hax
Registered User
Join date: 2 Jun 2007
Posts: 9
10-29-2008 09:54
Thank you everybody :)

I think the problem had something to do with the fact I was looping through a list of av keys and then calling the dataserver to see who was online. The thing was.. The loop completed before the results of the dataserver came back (??) Very strange. All I have to do now is to marry up the dataserver results with the av keys in my list.
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
10-29-2008 11:01
From: Lazersam Hax
I think the problem had something to do with the fact I was looping through a list of av keys and then calling the dataserver to see who was online. The thing was.. The loop completed before the results of the dataserver came back (??) Very strange. All I have to do now is to marry up the dataserver results with the av keys in my list.


Welcome to the wonderful world of asynchronous communication ;)

SL is not multi threaded. If you have a loop in one of your event handlers that makes dataserver requests, it will ALWAYS complete before the dataserver events occur, because the dataserver events _can't_ occur while the loop is running - your script only has one thread, and it's busy running the loop.

There are two ways to deal with it. One is to proceed with the loop anyway, and just be prepared for a barrage of dataserver events to come from the event queue after the loop is finished. The other way is to "unwind" the loop across multiple events, as in:

From: someone

int loopCounter;

startScan() {
loopCounter = 0;
requestDataForListMember(loopCounter);
}

default {
dataserver ( ... ) {
storeDataForListMember(loopCounter);
loopCounter++;
if (loopCounter > endOfLoop) return;
requestDataForListMember(loopCounter);
}
}


I've been trying to think of a way of making this easier to enter, but it's hard, and has largely involved a few confusing conversations with a friend who knows OCCAM...
Lazersam Hax
Registered User
Join date: 2 Jun 2007
Posts: 9
10-31-2008 07:14
From: Yumi Murakami
Welcome to the wonderful world of asynchronous communication ;)

SL is not multi threaded. If you have a loop in one of your event handlers that makes dataserver requests, it will ALWAYS complete before the dataserver events occur, because the dataserver events _can't_ occur while the loop is running - your script only has one thread, and it's busy running the loop.

There are two ways to deal with it. One is to proceed with the loop anyway, and just be prepared for a barrage of dataserver events to come from the event queue after the loop is finished. The other way is to "unwind" the loop across multiple events, as in:



I've been trying to think of a way of making this easier to enter, but it's hard, and has largely involved a few confusing conversations with a friend who knows OCCAM...


Thanks Yumi - that's a real eye opener! I have to rewrite the script using a loop control similar to your example.