|
Ephraim Kappler
Reprobate
Join date: 9 Jul 2007
Posts: 1,946
|
06-29-2009 11:50
The snippet of code below is from a script in the root prim. The 'if' statement is supposed to determine if one of two child prims (6 or 7) has been touched. The code block is supposed to pass the message to a script in each of them, which will activate a function to make them move. if (llDetectedLinkNumber(0) == (6 || 7)) { llMessageLinked(LINK_ALL_CHILDREN, (6 && 7), "Down", ""); }
The script in the child prims is a simple listen with no touch event or llPassTouches function because, as I understand it, the child prims automatically pass the touch to the root prim. As it happens, the only way I can get the function in the child prims to execute is (would you Adam 'n' Eve it?) by touching the root prim itself. Should I mention that the snippet is followed by an 'else if' and 'else' controls for other child prims that steadfastly refuse to do anything regardless of where I click? Should I go back to bricklaying?
|
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
06-29-2009 12:01
The trouble with these damned computers is that they go and do exactly what you tell them, never mind what you mean. Both (6 || 7) and (6 && 7) always evaluate to 1, you have to split things up a little for the compiler to do what you mean. if (llDetectedLinkNumber(0) == 6 || llDetectedLinkNumber(0) == 7) { llMessageLinked(LINK_ALL_CHILDREN, something_else, "Down", ""); }
You will need to think of a different encoding for that integer part, or you'll need to encode it as a string. Or you could send two linked messages, one each for prims 6 and 7 instead of all children.
|
|
Ephraim Kappler
Reprobate
Join date: 9 Jul 2007
Posts: 1,946
|
06-29-2009 13:05
Thanks Viktoria, it works now.
As for that "something_else", I dropped in a '0' which works but any integer I could think of seemed to work there. I tried sending the message individually to prims 6 and 7 but that just resulted in the function executing twice.
I'll take a closer look at it tomorrow and see if I can do something honest with your suggestion about using a string.
|
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
06-30-2009 05:48
Yeah, sorry I'm being vague about how to pass the values, but it's not really clear what you're doing with those messages. if two link messages, one sent to each prim, is making stuff happen twice, there may be something funky with the scripts in the child prims too. (when trying two link messages, you were using a specific link number and not LINK_ALL_CHILDREN, right?)
|
|
Ephraim Kappler
Reprobate
Join date: 9 Jul 2007
Posts: 1,946
|
06-30-2009 07:39
For what it's worth, prims 6 and 7 are an upper window panel, 4 and 5 are a lower panel and 2 and 3 are curtains. I suppose the messages "Up", "Down" and "Draw" are self-explanatory in this context. "Low" and "High" adjust the flexi parameters of the curtains to make them float or billow depending on which window panel is opened. I got the thing to work both ways: else { if (llDetectedLinkNumber(0) == 6 || llDetectedLinkNumber(0) == 7) { llMessageLinked(LINK_ALL_CHILDREN, 0, "Down", ""); llMessageLinked(LINK_ALL_CHILDREN, 0, "High", ""); } if (llDetectedLinkNumber(0) == 4 || llDetectedLinkNumber(0) == 5) { llMessageLinked(LINK_ALL_CHILDREN, 0, "Up", ""); llMessageLinked(LINK_ALL_CHILDREN, 0, "Low", ""); } if (llDetectedLinkNumber(0) == 2 || llDetectedLinkNumber(0) == 3) { llMessageLinked(LINK_ALL_CHILDREN, 0, "Draw", ""); } }
But the longer version below with explicit listing of the child prims by link numbers seems to work faster. However, the network connection is a little slack today so it's hard to say for sure. else { if (llDetectedLinkNumber(0) == 6 || llDetectedLinkNumber(0) == 7) { llMessageLinked(6, 0, "Down", ""); llMessageLinked(7, 0, "Down", ""); llMessageLinked(2, 0, "High", ""); llMessageLinked(3, 0, "High", ""); } if (llDetectedLinkNumber(0) == 4 || llDetectedLinkNumber(0) == 5) { llMessageLinked(4, 0, "Up", ""); llMessageLinked(5, 0, "Up", ""); llMessageLinked(2, 0, "Low", ""); llMessageLinked(3, 0, "Low", ""); } if (llDetectedLinkNumber(0) == 2 || llDetectedLinkNumber(0) == 3) { llMessageLinked(2, 0, "Draw", ""); llMessageLinked(3, 0, "Draw", ""); } }
The currently working version uses a script in each prim (a total of seven including the controller in the root) but there's a note by Void on the LSL Wiki for llMessageLinked that suggests it may be better to use llSetLinkPrimitiveParams so I'm looking into that to see if I can get it all to work from 3 scripts in the root prim. If I can do that, I'd like to see if I can trim some fat off the code blocks above.
|