Jump to content

Issue with script using PRIM_POS_LOCAL and PRIM_ROT_LOCAL and initial positions at rez ...


Miguelito Shilova
 Share

You are about to reply to a thread that has been inactive for 714 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello!

I have made an attachment comprised of two mesh prims. I attach it to my left hand, and when I click the attachment, the child prim moves down and rotates slightly ... if I click it again, the child prim moves up/rotates back to the initial position. This works just fine as long as I rez the attachment with the child prim in the initial position. If I detach the primset, with the child in the down position, then re-attach it and click the primset, the child prim just moves further down. I think the problem is that there's nothing in the script to distinguish between 'down' and 'up' states, even though I call a llResetScript() on rez.

Can someone please suggest a revision that can resolve this problem? Here is the script in question  ... thanks!

integer is_closed = FALSE;
integer link_slider = 2;
vector pos;
rotation rot;

default
{
touch_start(integer num)
{
  if(is_closed = !is_closed)
  {
    rot = llEuler2Rot(<0, 0, 2>*DEG_TO_RAD);
    llSetLinkPrimitiveParamsFast(link_slider, [PRIM_POS_LOCAL, llList2Vector(        llGetLinkPrimitiveParams(2, [PRIM_POS_LOCAL]), 0) + <0.01, -0.07, 0.0>]);
    llSetLinkPrimitiveParamsFast(link_slider, [PRIM_ROT_LOCAL, rot]);
    llPlaySound("Switch #1", 1.0);
    
  }
  else
  {
    rot = llEuler2Rot(<0, 0, 350>*DEG_TO_RAD);
    llSetLinkPrimitiveParamsFast(link_slider, [PRIM_ROT_LOCAL, rot]);
    llSetLinkPrimitiveParamsFast(link_slider, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(2, [PRIM_POS_LOCAL]), 0) + <-0.01, 0.07, 0.0>]);
    llPlaySound("Switch #2", 1.0);
  }
}
on_rez(integer start_param)
    {
        llResetScript();
    }
}

 

Link to comment
Share on other sites

save the start position and rotation in global variables.  In state_entry event apply the start saved position and rotation

edit: or just hardcode the start position and rotation in state_entry

Edited by Mollymews
  • Thanks 1
Link to comment
Share on other sites

On 5/23/2022 at 6:48 AM, Miguelito Shilova said:

 All I needed to do was remove the on_rez event

you will find that if the script is reset manually when the prim is in the open position then is_closed flag will be the opposite (closed) on start up

if is for our use then is not a biggie. If we transfer it to another person then is best that prim and flag are aligned should they ever reset the script

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 714 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...