Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Understanding Dataserver

Denrael Leandros
90 Degrees From Everythin
Join date: 21 May 2005
Posts: 103
03-17-2006 10:07
I'm writing an application where I need to read some configuration in from a notecard. Once I have the configuration loaded, I need to change states. I'm assuming the dataserver event is state specific, so I'm looking for ideas on how to insure that I have my full configuration loaded prior to a state change.

Specifically, if I issue a query does the data server event run concurrent with other code in the mainline script, or does mainline script processing stop at the point the dataserver script is invoked? I'm assuming it's the former, which means that I could set up an until condition to wait for all the configuration information to load prior to invoking the state change.

Any and all ideas, comments, thoughts and snide remarks welcome.

Thanks
Den
Newfie Pendragon
Crusty and proud of it
Join date: 19 Dec 2003
Posts: 1,025
03-17-2006 10:12
In essence you're correct. The dataserver runs as an event triggered in your script by SL as data arrives, so you can collect the info and switch state when you've completed the load condition.

One word of caution though - always assign the query id to a variable, and check it in the dataserver event to make sure it matches. Even though the read call might come from a single script, the dataserver event is triggered on all scripts in the object. There's no 100% guarantee that the data you receive is actually the data you request.

- Newfie
_____________________
Kisiri Mfume
Registered User
Join date: 28 Aug 2005
Posts: 21
03-17-2006 11:29
There's actually a wonderful example in the LSL Wiki for llGetNotecardLine that I've pretty much copied wholesale into any notecard configured item I've created.

http://secondlife.com/badgeo/wakka.php?wakka=llGetNotecardLine

Just use the code block in there, replacing the llSay with whatever you need to do with each line in the notecard (I -highly- suggest calling a seperate "processConfigLine" function passing the received line... it makes things -very- much more readable), and then add an 'else' to the EOF check that pushes you on to the next state.

Basically, you're reading from a notecard until you reach the end of the notecard, then you're changing state to your "configurationDone" state.

I'm not at home, otherwise I'd just copy in my "state readSettings" block from one of my scripts :)
Denrael Leandros
90 Degrees From Everythin
Join date: 21 May 2005
Posts: 103
03-17-2006 11:46
Thanks,

I hadn't thought about executing the state change out of the dataserver, but that makes sense. I can do all the configuration management from the dataserver event (in a seperate function, I agree about that), and then just execute the state change from there as needed.

Den