- Joined
- Oct 23, 2018
- Messages
- 149

I've been away from lsl for to long. Well, okay, I was never good at rotations anyway. The issue is this: I have a gear like assembly that needs to make a full revolution on it's z axis. This is a child prim. So far so good. It needs to do it's spin even if the child prim is rotated, with the relative z axis. Still okay... Where my brain utterly burns out and crashes is that it needs to do all this no matter what the root's global rotation is. I'll include the relevant chunks of the script below as I currently have it. Please don't laugh to hard!
rotation g_rXYZS; // The adjustment value
integer g_iPrimGearOpen; // link number of this prim
integer g_iPrimGearRest; // link number of this prim
default {
state_entry() {
vector vXYZ_Angles = <0,0,3.0>; // This defines a 3 degree change on the Z axis
vector vAngles_In_Radians = vXYZ_Angles*DEG_TO_RAD; // Change to radians
g_rXYZS = llEuler2Rot(vAngles_In_Radians); // Convert to a rotation
integer n; // Initialize the counter
integer iLinkCount = llGetNumberOfPrims(); // How many items in the link set?
for (n = 2; n <= iLinkCount; n++) { // Cycle through, skipping root
string sThisElement = llGetLinkName
; // Get the prim name
if (sThisElement == "Gear_Swing_Low") g_iPrimGearOpen = n; // this link number is this item:
} // End if
} // end state_entry
touch_start(integer s) {
integer x; // set up counter var
rotation rGearCurrentRot; // set up rotation var
for (x = 1; x <= 120; x++) {
rGearCurrentRot = llList2Rot( llGetLinkPrimitiveParams(g_iPrimGearOpen,[PRIM_ROT_LOCAL]), 0 );
llSetLinkPrimitiveParamsFast(g_iPrimGearOpen, [PRIM_ROTATION,g_rXYZS*rGearCurrentRot] );
} // end for
} // end touch_start
} // end default
rotation g_rXYZS; // The adjustment value
integer g_iPrimGearOpen; // link number of this prim
integer g_iPrimGearRest; // link number of this prim
default {
state_entry() {
vector vXYZ_Angles = <0,0,3.0>; // This defines a 3 degree change on the Z axis
vector vAngles_In_Radians = vXYZ_Angles*DEG_TO_RAD; // Change to radians
g_rXYZS = llEuler2Rot(vAngles_In_Radians); // Convert to a rotation
integer n; // Initialize the counter
integer iLinkCount = llGetNumberOfPrims(); // How many items in the link set?
for (n = 2; n <= iLinkCount; n++) { // Cycle through, skipping root
string sThisElement = llGetLinkName
if (sThisElement == "Gear_Swing_Low") g_iPrimGearOpen = n; // this link number is this item:
} // End if
} // end state_entry
touch_start(integer s) {
integer x; // set up counter var
rotation rGearCurrentRot; // set up rotation var
for (x = 1; x <= 120; x++) {
rGearCurrentRot = llList2Rot( llGetLinkPrimitiveParams(g_iPrimGearOpen,[PRIM_ROT_LOCAL]), 0 );
llSetLinkPrimitiveParamsFast(g_iPrimGearOpen, [PRIM_ROTATION,g_rXYZS*rGearCurrentRot] );
} // end for
} // end touch_start
} // end default