For Linked messages...
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
03-23-2005 13:19
Is it possible to have several pairs of linked objects, that will talk really only to each other by default, that can talk to a separate master prim (the root prim?).. for example..
========== <--master prim | | | <--prim 1a | | == | | | <--prim 1b | | ==
| | | <--prim 2a | | == | | | <--prim 2b | | ==
if prims 1a and 1b are linked to each other first making object 1, and prims 2a and 2b are linked to each other making object 2, THEN the two objects are linked to the master prim.
When prim1a talks via a linked message, will it talk to everything or can it JUST talk to prim1b?
Know what I mean? Sub-question, will 1a talk eaqually to 2b?
Sorry if this is not clear.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Talena Wallaby
Registered User
Join date: 20 Mar 2005
Posts: 19
|
03-23-2005 13:41
From my simple experimenting ingame from a building perspective it seems that the parent/child relationship between the two making up object 1 and the two making up object 2 gets broken when they're linked with the master prim. The reason I say this is that when you link two prims together, link another two prims together, then link those two objects with a fifth prim, then unlink all of them the whole thing separates into its component prims. Sorry about the incoherence of that, I've not been sleeping much since I found Second Life this past weekend.  Short answer: Pretty sure the answer is no. Long answer: While I am pretty sure the answer is no, I haven't done scripting testing of it to verify that the answer is no.
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
03-23-2005 13:43
Samhain, there are several "constants" for interprim locution in this manner. It also looks as though the wiki articles could use some additions. I'd appreciate it if someone that frequently revises the LSL Wiki do this, as I'm fairly sure the constants are buried somewhere in there. Can't find them, though. Basically, you can do this: llMessageLinked(3, 0, "", "" - send message to link 3. llMessageLinked(LINK_SET, 0, "", "" - broadcast message to entire set, including the prim invoking the command. llMessageLinked(LINK_ALL_OTHERS, 0, "", "" - broadcast message to entire set, not including the prim invoking the command. llMessageLinked(LINK_ALL_CHILDREN, 0, "", "" - broadcast message to all prims with higher link number. llMessageLinked(LINK_THIS, 0, "", "" - sends message to prim invoking script only. Useful for passing variables between two or more script buffers. Currently in Preview 1.6 only. Using the changed event and llGetLinkNumber or llGetLinkKey, then, it would be possible to formulate something like this using name values, object descriptions, lists... several ways I can think of off the top of my head.
_____________________
---
|
Zalandria Zaius
Registered User
Join date: 17 Jan 2004
Posts: 277
|
linked messages
03-24-2005 08:28
if you want prim 1a to talk to 1b, you can use the num parameter. It does slow the linked message down a little bit, but it may be what you're looking for. ex: 1a touch_start(integer touched) { llMessageLinked(LINK_SET,1, "Touched.", ""  ; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1b link_message(integer sender_num, integer num, string str, key id) { if(sender_num == 1) { llSay(0, str); } }
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
03-24-2005 10:29
Warning: impending weirdo math trick. Alright, so if you want just prim 1a and 1b to talk between each other, and just 2a and 2b, you can make 1a send link messages only to 1b, and 1b send only to 1a, by passing the appropriate link numbers in the first argument of llMessageLinked(). Here's the fun part: // in 1a, 1b, 2a, or 2b, this will always send the message to the prim's "counterpart" llMessageLinked(llGetLinkNumber() ^ 1, num_arg, str_arg, key_arg);
That ^ is a bitwise XOR. Bitwise XOR with 1 basically flips the least significant bit, leaving the rest of the bits unaffected. In english, that just magically turns 3 into 2, 2 into 3, 4 into 5, and 5 into 4, all in one tidy little operation. You can use that line above to communicate with the other prim in those pairings, or just use LINK_ROOT to communicate directly with the root prim. Not sure if this helps, but it's a neat little trick ;)
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
03-24-2005 12:58
I'd forgotten about the XOR trick and have had good success with it in the past, thanks for the reminder.
Thanks for the code examples, I'm sure I use them, (as soon as I get home)... and I knew those basic pieces. But my problem here is really that I am planning to build a unit as a single one, then I want to gang this unit to three other identical units, and did not want to have to do a boatload of tedious code changing when I go to link the other units together.
Is there a way I can make a variable variable? Hmmm, how do I say this without being confusing, and in fact without it even sounding confusing to myself.
OH... I think I might have stumbled on the answer, but now I need an opinion... since each prim in SL has it's own key, can I key the 1a and 1b from unit one, to be unique to the other 3 units, by using their root prims's key?
That would be the varying variable, I want to be able to make ONE code that works for all 4 units. At the same time, I do not want so much interlink messaging going on in it so that it lags itself rignt into a hole.
Was that clear as mud or do you know what I mean?
In other words, if I build this, as a single unit, when I gang 4 of these units together, the same script will have the same problems only NOW it will be times 4.
Is there a way I can make a variable that is unitkey.1a and unitkey.1b so that any new unit will have a unique 1a address and 1b address? Maybe this is so simple I can't see it.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
03-24-2005 23:23
I am very happy to say that I am well on my way with my project now. Also many thanks for Jefferey Gomez for his ingame help!
I'll post more about this later.
As for the variable variable, I changed the design somewhat, and it will no longer be a problem. I hope this beast will not be a lag monster! =) At least there are very few (if any) llListen() calls. None so far!
Thanks again for all the help. I still cannot get over all the helpful people in here! SL'ers are the best!
Thanks!
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
03-25-2005 03:06
Can someone explain the XOR trick to me please, or point me to somewhere that does?
I think you're talking binary and swapping the units digit, and although the maths works out I'm not quite sure.
Also, could you do it on higher places with ^ 10 and flip the 2's column?, ^11 and flip both the last digits etc.?
|
Talena Wallaby
Registered User
Join date: 20 Mar 2005
Posts: 19
|
03-25-2005 04:45
From: Eloise Pasteur Can someone explain the XOR trick to me please, or point me to somewhere that does?
I think you're talking binary and swapping the units digit, and although the maths works out I'm not quite sure.
Also, could you do it on higher places with ^ 10 and flip the 2's column?, ^11 and flip both the last digits etc.? 2: 00000010 3: 00000011 XOR 1 flips the last bit. If you have a 2 and XOR with 1 then you will get 3 (flip the last bit in 2 and you get 00000011, which is 3). You could use higher order bits, but then it starts getting weird. I'd only do it if I had larger sets of prims that I was going to use in weird combinations. Perhaps I'd have 4 groups of 2, or 2 groups of 4, depending on the situation. The only time it really makes sense is if your groups may change their sizes and such. Otherwise, it's a lot simpler to just have them in order.
|
Jonathan Shaftoe
... the titleless.
Join date: 11 Feb 2005
Posts: 44
|
03-26-2005 03:10
From: Eloise Pasteur Can someone explain the XOR trick to me please, or point me to somewhere that does?
I think you're talking binary and swapping the units digit, and although the maths works out I'm not quite sure.
Also, could you do it on higher places with ^ 10 and flip the 2's column?, ^11 and flip both the last digits etc.? Just to be clear, yes, you can flip any given bit with the XOR trick, and in a similar way can inspect any given bit using &, which is generally how you implement storing things in bitfields. Just bear in mind that you actually want to use ^2 to flip the second bit and ^4 to flip the third bit and ^8 .. etc as the operand on the right side of the ^ is still a normal decimal integer not binary  . Or a clearer way of writing it might be ^ (1 << x) where x is which bit you want to flip (starting at 0 rather than 1).
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
Binary math
03-26-2005 15:40
Let me take a stab at explaining XOR. First let me explain OR and AND. in OR, any 1 OR 1 will always be a 1. in OR, any 0 OR 1 will always be a 1. in OR, ONLY if both bits are ZERO will the result be a zero. in AND, any 1 AND 1 will always be 1. in AND, BOTH bits have to be a 1 for the result to be a 1. in AND if EITHER bit is a ZERO the result will be a ZERO. in XOR if the bits MATCH, the result is a 0. in XOR ONLY when the bits do NOT match, the result is a 1. XOR is short for Exclusive OR. so: 1 XOR 1 = 0 1 XOR 0 = 1 0 XOR 1 = 1 0 XOR 0 = 0 With the other explainations, I hope that helps. Also see this page that explains this maybe a little more: Deriving the XOR Function I hope that helps... as for the program, the reason it works... the XOR 1 does this... any binary number ends with a 0 or a 1. If you XOR with 1, ALL even numbers (which end in ZERO ) will be XOR'ed with a 1. Since 0 XOR 1 = 1, the binary number (remember even ends in zero) will effectively be incremented by 1. so let's say 4 decimal = 100 binary. If you XOR 4 with 1 you get 5 because: 100 XOR 001 = 101 See?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
03-26-2005 17:31
Thanks.
|