|
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
|
10-29-2008 01:33
Can you use more that one dataserver( key, string) in a script? - possibly possibly by placing them in different States.
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
10-29-2008 04:07
You just have to check if the key of the answer is the same as the key of the request. Example: key request; key request2;
default { state_entry() { request = llRequestAgentData(llGetOwner(), DATA_BORN); // request your SL creation date request2 = llRequestAgentData(llGetOwner(), DATA_ONLINE); // request your online status. Just an example. I know i'm online. } dataserver(key queryid, string data) { if( request == queryid ) llSay(0, "You were born on " + data); else if( request2 == queryid ) if(data) llSay(0, "You're online."); } }
|
|
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
|
10-29-2008 04:55
I often put them in different states. Usually, what I'm trying to accomplish, like reading two different notecards, logically lends itself to different states. I does add extra code to the script, but if you can afford it, it makes it logically cleaner.
|
|
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
|
10-29-2008 07:25
Thanks people - that is a great help
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-29-2008 10:22
Here is a more complete/complex example of a script that requests both a resident's name and online status given the resident's key. The name is requested only once, but the online status is requested once initially and then every time the prim/object is touched. This script has not been compiled or tested, but it should give you the basic idea. key RESIDENT_ID = "12341234-1234-1234-1234-123412341234";
string residentName = ""; integer onlineStatus = FALSE; integer onlineStatusChecked = FALSE;
key nameRequestId = NULL_KEY; key onlineRequestId = NULL_KEY;
reportOnlineStatus() { string statusString; if (onlineStatus) { statusString = "online"; } else { statusString = "offline"; }
llSay(0, residentName+" is "+statusString); }
default { state_entry() { nameRequestId = llRequestAgentData(RESIDENT_ID, DATA_NAME) onlineRequestId = llRequestAgentData(RESIDENT_ID, DATA_ONLINE) }
touch_start(integer nDetected) { if (onlineRequestId == NULL_KEY) { onlineRequestId = llRequestAgentData(RESIDENT_ID, DATA_ONLINE) } }
dataserver(key requestId, string data) { if (requestId == nameRequestId) { residentName = data; nameRequestId = NULL_KEY;
if (onlineStatusChecked) { reportOnlineStatus(); onlineStatusChecked = FALSE; } } else if (requestId == onlineRequestId) { onlineStatus = (integer)data; onlineRequestId = NULL_KEY;
if (nameRequestId == NULL_KEY) { reportOnlineStatus(); } else { onlineStatusChecked = TRUE; } } } }
|
|
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
|
10-29-2008 14:45
Good one Hewee - helps a lot
|