|
Aargle Zymurgy
Registered User
Join date: 10 Feb 2007
Posts: 5
|
03-14-2007 08:46
I was hours last night tracing an inexplicable bug. Because of the system down for maintainance, I can't write a simple test to demonstrate the problem, but I'll describe it and see if anyone knows a solution.
Script A is responding to a message sent via "llMessageLinked( LINK_THIS" from Script B and works flawlessly. Script B sent the message under conditions arising from a timer event. Script B was expanded to respond to a link message from script C that triggered the message to A (hence over-riding the timer). And at this point, things got very weird.
It seems that, when processing the message in script A, the script would do a 'return' at an arbitrary point in the code. In sheer frustration, I put in: llOwnerSay( "A" ); llOwnerSay( "B" ); llOwnerSay( "C" ); llOwnerSay( "D" ); llOwnerSay( "E" );
And as out put, I would get A,B,C and nothing further. Sometimes A. Or A,B,C,D.
As far as I could tell (before I dragged my weary ass to bed), if one script sends a link message to second, and the second in turn sends a message to a third, then the third script is forced to return at the same time the second script returns.
In anyone's experience, is this correct? Is this a bug? Is this by design? Is there a sensible workaround?
|
|
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
|
03-14-2007 09:21
The problem is that all scripts will respond to all link messages. So when the first script sends a message to the second, the third gets this also. The only way to avoid this is to put each script into seperate prims of a linked set, set send your link messages explicitly to the prim containing the script desired. I ran into this myself recently.
|
|
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
|
03-14-2007 12:10
Something that might help make your life a little easier is identifying all of your link messages with a 'key' of sorts... ...if I have a one-prim object with multiple scripts (I have a couple items I sell that have between 2 and 6 scripts in a prim), then I'll do something like the following: Script 1: integer SEND = 23; integer RECEIVE = 24;
default { touch_start(integer num) { llMessageLinked(0, SEND, "Hello Script 2", NULL_KEY); } link_message(integer sender, integer int, string str, key id) { if(int == RECEIVE) //do stuff } }
Script 2: integer SEND = 24; integer RECEIVE = 23;
default { touch_start(integer num) { llMessageLinked(0, SEND, "Hello Script 1", NULL_KEY); } link_message(integer sender, integer int, string str, key id) { if(int == RECEIVE) //do stuff } }
_____________________
--AeonVox--Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
|