Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Note card not always being read?

Bartiloux Desmoulins
Think Kink? Think Bart!
Join date: 27 Sep 2005
Posts: 121
09-03-2007 11:37
I've been having a sporadic issue with a creation of mine. Most of the time it works just fine. Other times, perhaps during periods when SL is having problems with the asset server(s) or some other component of the environment, my script seems to be unable to read the note card which is placed in the object's inventory.

The value I am retrieving is ultimately going to be an integer used in calculations. If the read is unsuccessful the script tries to divide by the note card integer and gets a "divide by zero" math error. As I said, this doesn't happen always, but enough to really start getting on my nerves.

Is there anything I can do to "trap" this condition? Has anyone else run into this? Am I just running into slowness with regard to how fast the data on the note card is retrieved? Help!

Thank you,
Bartiloux Desmoulins
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
09-03-2007 12:34
If you use the dataserver Event Handler to not only retrieve the value but to instruct the script to proceed with its use of that value then you should never perform the calculations without having first acquired the value.

If, however, you proceed with your calculations using an event other than the dataserver Event then you can never guarantee that the Notecard has been read in a timely manner.

How are you controlling the flow between Notecard read and subsequent calculation?

For example, if the calculation is being triggered by the touch_start Event then you might consider something like this:

With the code that initiates reading the notecard:
status = "LOADING";
llOwnerSay("Reading Notecard... stand by!";);
queryId = llGetNotecardLine... etc.

touch_start Event Handler:
if (status == "LOADING";) llOwnerSay("Sorry, the Notecard is still being read... I'll tell you when it's ready. :-)";);

...and in the dataserver Event when EOF is read:
status = "READY";
llOwnerSay("...finished ready the Notecard.";);
llOwnerSay("I'm now ready for you to begin. :-)";);

Or some variation on that idea.