Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

no order in linked messages

Jade Bard
Registered User
Join date: 7 Jul 2004
Posts: 106
02-24-2005 20:52
I'm looking to have it so that it doesn't matter what order the links are, on my machine... As in my parent script can interact with all the child scripts without actually having to know the number... i.e. just send it to all the scripts, and the right one responds.

I don't want to do a for loop.
What would be a smart way of doing this?
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
02-24-2005 23:51
Parent:
CODE
llMessageLinked(LINK_SET,1,"message text","random key");
llMessageLinked(LINK_SET,2,"message text","random key");
llMessageLinked(LINK_SET,3,"message text","random key");


Sample Child:
CODE
link_message(integer sender, integer num, string str, key id)
{
if(num == 1) llSay(0,str);
}

The downside of this is both that you're broadcasting the message (laggier) as you're triggering events in every script in the object itself... which is pretty much unnecessary. You could also store a list of which link your children are on, via llGetLinkNumber, for your parent to send messages over without broadcasting, but I leave that to you to write.
_____________________
---
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
02-25-2005 00:14
use LINK_ALL_CHILDRENS
or LINK_ALL_OTHERS maybe, this will spare you to have the script broadcasting in the same prim and thus saving the message to be broadcasted in the same prim the script is (if you have multiple scripts here for example)
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
02-25-2005 19:56
If you don't mind getting a little involved, you could have an initial broadcast to all children from the root requesting an ID callback from all the children prims/scripts.

Each child would respond with 'I am <script> in <prim#>' and the master script would then parse that and store that info in global vars designated for each child.

After that, all calls to children could be targeted to specific prims with llMessageLink(<variable for specific target prim>, <number>, <string>, <key>;);

This would make coms a bit more efficient overall but I dunno how complex you want to make your scripting.

If you are willing to enforce a specific link oder when you build the object, you can assign specific IDs to each child and avoid the necessity for the initial broadcast and parsing of responses as well.

Racer P.
Jack Lambert
Registered User
Join date: 4 Jun 2004
Posts: 265
hehe
02-25-2005 23:47
Eek!

Whatever happened to good old fashioned llGetLinkNumber() :)

--Jack Lambert