Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Attatchment messes up rotation script

Hplar Sapwood
Registered User
Join date: 11 Nov 2006
Posts: 3
12-10-2006 13:40
Hi,

I've got this script which will rotate and move a prim in relation to the root prim that it's linked to.

The script works perfectly most of the time. However as soon as I attach the object to an av's hand the rotation goes wierd .

Wasn't sure if this is in any way related to the targetomega bug or just something I'm doing wrong.

The script is below:




vector r_open = <210, 0, 0>; // Rotations in degrees relative to root prim
vector r_closed = <0, 0, 180>;

vector p_open = <0, 0.128, 00.038>; // Postition in meters relative to root prim
vector p_closed = <0, 0.03, 0.021>; // Postition in meters relative to root prim

key sound = "0a0b403e-7e30-a2b5-eb3b-bc1395402579"; // the UUID of the sound the wings will make opening or closing.

integer close_on_rez = FALSE; // Change to false to have it open on rez

// ======================================================= Nothing from here down needs modding (unless you're chaning the command this script responds to).

rotation LocalRot(rotation localrot)
{
rotation LocRot = localrot / ( (ZERO_ROTATION / llGetLocalRot()) * llGetRot());
return LocRot;
}

open()
{
llTriggerSound(sound,1.0);
llSetPrimitiveParams([PRIM_ROTATION, LocalRot(llEuler2Rot(r_open * DEG_TO_RAD)), PRIM_POSITION, p_open]);
}

close()
{
llTriggerSound(sound,1.0);
llSetPrimitiveParams([PRIM_ROTATION, LocalRot(llEuler2Rot(r_closed * DEG_TO_RAD)), PRIM_POSITION, p_closed]);
}

default
{
state_entry()
{
if (close_on_rez)
{
close();
}
else
{
open();
}
}

on_rez(integer rez)
{
llResetScript();
}

link_message(integer send, integer num, string msg, key id)
{
if ( msg == "tricorder_open" )
{
open();
}
else if ( msg == "tricorder_close" )
{
close();
}
}
}
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
12-10-2006 13:56
From: Hplar Sapwood
The script works perfectly most of the time. However as soon as I attach the object to an av's hand the rotation goes wierd.

It'd be probably because when the item is attached to AV, when you query for rotation of root prim, what you receive is actually rotation of the AV the item is attached to.

Not sure if there's easy way to work around it, other than having the root prim broadcast its own rotation when the item is attached/rotated, so the child prims can take advantage of that knowledge. o.O;