Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

dataserver and reading config files question

Gwylym Loon
Registered User
Join date: 6 Jun 2007
Posts: 81
01-10-2008 13:50
I want to make sure that all of the notecards for configuration are read before proceeding on to the execution of the main script.

For example:
state_entry()
{
owner = llGetOwner();

ownerLine=llGetNotecardLine("owner_responses",0);
randomLine=llGetNotecardLine("randoms",0);
optionLine=llGetNotecardLine("Options",0);
llListen(1, "", owner, "";);
max_subs = 60 / interval;
if(hours == 0)
{
llDialog(llGetOwner(), "Please chose how long", ["4 Weeks", "6 Weeks"], 1);
}
llOwnerSay("The agent is "+llList2String(options,0));
}


I don't want it to go on to the listen until the 3 notecards are fully read in. Is this possible? I have seen what appears to be objects that do this when you wear them or first rez them.

Thanks.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
01-10-2008 13:57
The llGetNotecardLine function does not itself return a line of data, but rather it arranges for that line to get delivered as a dataserver event. So, after you do the first llGetNotecardLine (which returns a queryID that you can then match with the resulting dataserver event) you want to read subsequent lines, and do subsequent processing (like the dialog) from within the dataserver event handler.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
01-10-2008 14:47
Like Qie said . . . then in the dataserver() event, check to see if all the data has been read (there are probably different ways to do this).

Then, when you are sure all the data is read, move to a new state that has the listen. I often do this in my notecard reading scripts. I have a default state that reads the notecards, then it moves to the "ready" state or something like that. Only returns to the default state if it needs to re-read the data, ie reset, inventory change, attach, etc.

Hope that helps a little
Gwylym Loon
Registered User
Join date: 6 Jun 2007
Posts: 81
01-10-2008 14:49
Yes, I know that the dataserver event needs to be called for subsequent lines. I gave just the code necessary to show how it was started.

So, is there a way to make sure that eveything is read in via dataserver before anything else is processed by the script?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-10-2008 15:21
From: Gwylym Loon
So, is there a way to make sure that eveything is read in via dataserver before anything else is processed by the script?

yes, have the notecard reading function contained within it's own state, then when EOF == data, change to your running state.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
01-12-2008 07:31
Since it appears that you are reading from more than one notecard, you somehow need to know that you've read *all* of the notecards. Perhaps you could have a variable keeping track of EOF on each notecard. Then, when it "senses" that the EOF of the last notecard has been reached, then move on to the next state, or initiate a listen.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-12-2008 17:55
a list of card names, and a counter... increment the counter each eof and read the next indexed card in the list... if the next card is "" (past the end of the list) goto the next state... or you could divide each card into it's own state but that's alot of overhead
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
01-12-2008 18:18
memory?
_____________________