|
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
|
05-18-2008 03:06
Have a question about the mechanics of script execution in SL. This is purely theoretical so no code examples  Suppose I have a script, 'Reader', that readfs in a bunch of data from a notecard, and the any number of other scripts that, in their default.state_entry send a llMessageLinked to the Reader script requesting portions of the data. My questions is .. do scripts in the same prim execute in parallel of in sequence? ... If in the Reader script I control that it reads in the data when it is first called, will the calls from the other scripts arrive after it is done loading? ... hmmm ok maybe a simple code example will show what I mean (ha ha ha)
default { link_message(integer sender, integer channel, string message, key id) { //Here start the load of data fron the note card } dataserver(key requested, string data) { //Load the data //When complete change to the running state state running; } }
state running { link_message(integer sender, integer channel, string message, key id) { //Here respond to requests from other scripts for data } }
So (based on the above) my question is what happens if in the default.state_entry of Scripts A, B, and C I have a link message call that the Reader script would respond to? Obviously the first would get the default.link_message ... would the others then occur after the above was done or, since these are a number of datasercver calls and thus waiting for responses, could the other script calls come in and start another default.link_message?
|
|
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
|
05-18-2008 03:10
Basically, you have to assume that every script runs at the same time. So if you read a notecard and the data is needed by other scripts, you better read the notecard first and then issue a llMessageLinked to the other scripts when the reading has finished. Thus you will know for sure that the data is complete and the other scripts cann access it.
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
05-18-2008 03:13
Scripts run in parallel. If I understand what you are trying to do here, if you have one script that loads data from a notecard into a list (or whatever), and three scripts which ask it for data from that list, and they all start at once, the three scripts will be asking before the data has been loaded, since this will take a lot more time than sending a link message. And since your reader script has no link_message event in the default state, it will ignore the link messages, so the three scripts will not receive anything.
I would probably have the reader script send out a "loading" link message at the start, to tell other scripts not to ask for data, then a "ready" link message once it is done, so that they then know that they can request data and be given it. Or, you could have a link_message() event in the default state which replies to data requests with "still loading data, try again in a bit".
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
|
05-18-2008 08:28
Thanks ... thats what I needed to know. Appreciate the help!
|