//* llSetLinkPrimitiveParams(this_link,[PRIM_POSITION,new_position]); is borken
//-----Demonstrate non-movement of child prim in LinkSet ------------------/
// Object of script is to find position of child, add 5 meters to X-axis,
// store that position, then toggle between the original and original+5m
// positions when child is touched.
//*----- Create two prims, link them, place this script into root,
// get some coffee, then touch the child prim a few times.
list pos_list=[];
integer position=0;
//-----------------------/
default {
//-----------------------/
// get key for child to setup details call
// retrieve position of child into temp list
// retrieve position of child from temp list
// set new position same as original
// add 5 meters to the x axis
// store both positions for later.
state_entry() {
key child_key;
list details;
vector org_pos;
vector new_pos;
child_key=llGetLinkKey(2);
details=llGetObjectDetails(child_key,[OBJECT_POS]);
org_pos=llList2Vector(details,0);
new_pos=org_pos;
new_pos.x+=5.0;
pos_list=[org_pos]+[new_pos];
}
//----------------------/
// for each touch
// retrieve the link number touched
// if it was the child then...
// toggle the position list index
// retrieve the new position from storage
// announce the move
// change the child position to that vector
touch_start(integer num) {
integer w;
integer this_link;
vector new_position;
for(w=0; w<num; w++) {
this_link=llDetectedLinkNumber(w);
if (this_link==2) {
position=1-position;
new_position=llList2Vector(pos_list,position);
llSay(0,"Moving to "+(string)new_position);
llSetLinkPrimitiveParams(this_link,
[PRIM_POSITION,new_position]);
}
}
}
}
Your example code uses an absolute position.
Say your prim was at <128, 128, 30>... your call to llSetLinkPrimitiveParams is attempting to move the child prim to a position 183m from the root!
This is larger than the distance allowed between linked prims, so the call silently fails.
In your code, change
org_pos=llList2Vector(details,0);
to
org_pos=llList2Vector(details,0) - llGetPos();
If this still fails, your prims may be too small to be linked at the distance specified. Try increasing the size of the prims, or decreasing the value in new_pos.x+=5.0; (see http://wiki.secondlife.com/wiki/Linkability_Rules
)