Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Cannot get PRIM_POSITION working with llSetLinkPrimitiveParams()

WickedTribe Woodget
Registered User
Join date: 12 Apr 2007
Posts: 15
06-21-2007 14:23
Create two arbitrary prims and link them. Insert the following script into the parent prim. Now touching the parent prim will trigger changes in the child prim. This successfully works for all parameteres I have tried EXCEPT for changing its position. Any ideas of what is wrong here?


CODE

integer switch = 1;

default
{
state_entry()
{
llSay(0, "Test llSetLinkPrimitiveParams");
}

touch_start(integer total_number)
{
if (switch)
{
llSetLinkPrimitiveParams(2, [PRIM_SIZE, < 0.1, 0.01, 0.05>]);
llSetLinkPrimitiveParams(2, [PRIM_ROTATION, llEuler2Rot( <90 * DEG_TO_RAD, 0 * DEG_TO_RAD, 270 * DEG_TO_RAD> )]);
llSetLinkPrimitiveParams(2, [PRIM_POSITION, llGetLocalPos() + <3, 4, 5>] );
switch = 0;
}
else
{
llSetLinkPrimitiveParams(2, [PRIM_SIZE, < 0.15, 0.15, 0.15>]);
llSetLinkPrimitiveParams(2, [PRIM_ROTATION, llEuler2Rot( <0, 0, 0> )]);
llSetLinkPrimitiveParams(2, [PRIM_POSITION, llGetLocalPos() + <0, 0, 0>] );
switch = 1;
}

}
}
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
06-21-2007 15:15
In the first set prim param for position, you are trying to move it ~7.07 meters from the root prim.

Because of how tiny the prims are, you are probably exceeding the allowed link distance between root and child, and if so, it will fail _SILENTLY_.

Try increasing the sizes of all prims involved, to test that, or decrease the move distance.

Incidentally, because of the built-in delay with the function, you will get faster script execution if you chain the prim params into ONE call, instead of 3 sequential calls. For example, with the second one, use:

llSetLinkPrimitiveParams(2, [PRIM_SIZE, < 0.15, 0.15, 0.15>, PRIM_ROTATION, llEuler2Rot( <0.0, 0.0, 0.0>, PRIM_POSITION, llGetLocalPos() ] );
_____________________
- LoopRez, flexi prim skirt generating tool
- LinkRez, a necklace chain generator
WickedTribe Woodget
Registered User
Join date: 12 Apr 2007
Posts: 15
06-21-2007 15:52
I have tried with various size prims and different distances, but all with the same no go results.

I also separated the prim param calls for clarity rather than efficiency for this example.

I also tried using llGetPos() instead of llGetLocalPos() but makes no difference.

This seems simple, it is just not working...?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-21-2007 16:45
Well, llGetLocalPos() is getting the local pos of the prim where it's executing, presumably the root prim... in which case it will return the same as llGetPos(), which is the global coordinates of that root prim. Now, when you try to set the position of the child prim to that value, you're actually setting its *local* position--i.e., its offset from the root prim. So you're probably telling it to go halfway across the sim.

This is another time when llGetLinkPrimitiveParams() would be very handy.
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
06-21-2007 18:24
It seems to me that linking limits are still your most likely problem. I have operated the Timeless Prototype door and that manages to change size, rotation and position wrt the root prim with few problems, but then doors are usually a few meters in at least two dimensions. I don't think it uses llSetLinkPrimitiveParams () though.

This is a rather technical discussion on linking prim limiting parameters.
/111/62/11883/1.html

This explains that if the vector distance is less than 1m, link should be ok.
http://rpgstats.com/wiki/index.php?title=Link

llSetPos is explained here:
http://rpgstats.com/wiki/index.php?title=LlSetPos
When applied to a child prim, it moves the child prim wrt root prim.
eg: llSetPos(llGetLocalPos() + <0, 0, 1>;);
to move the child prim up one meter (might be on the boundary for very small prims)
Tetria Watts
Registered User
Join date: 15 Aug 2006
Posts: 5
06-22-2007 12:06
I read over the OP and finally noticed that the OP is calling localpos from the parent prim, I'm fairly sure that returns the global coordiante in parent/root prim, and unless the function acts differently than what I think, it'd most likely return values beyond the 30m linking distance rather than getting the real localpos of the object. I don't know any function that'll allow you to get the linked prim's position when not inside that prim so sorry.
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
06-22-2007 19:39
Sorry I missed that.

Here is a bit of code I lashed up to find a way around the problem.

You activate this by clicking the root, and the touch_start gets the process going, but all your other code should in the root's link message. One way to show event processing!

The "if" statements are not strictly necessary, but it could be the basis for more link messages by changing their nums for other purposes.

You could get the child to respond its rotation in the key field of messagelinked.

In the root object:
CODE

vector childPos;
integer debug = TRUE;// set this to FALSE when you happy it all works

default
{

link_message (integer sender_num, integer num, string str, key id ) {
if (debug)
llOwnerSay ("root got link message - num = " + (string) num + "/ str = " + str);
if (num == 1) {
childPos = (vector) str;
llSay(0, (string) childPos);
}
}


touch_start(integer total_number)
{
llMessageLinked (LINK_ALL_CHILDREN, 0, "", "");
}
}



In the child object:
CODE

integer debug = TRUE;

default
{

link_message (integer sender_num, integer num, string str, key id ) {
if (debug)
llOwnerSay ("child got link message - num = " + (string) num + "/ str = " + str);

if (num == 0)
llMessageLinked (LINK_ROOT, 1, (string) llGetLocalPos (), "");
}
}