Jump to content
You are about to reply to a thread that has been inactive for 134 days.

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

Recommended Posts

Posted (edited)

Whenever I try to mess with positions and rotations, it just never seems to go right. I'm trying to only move the linked part in a 2-part linkset.

Specifically what I'm trying to do is make a pizza box that opens and closes, with the lid and base being separate parts. The lid is link 2 but if I put in link 2 it does nothing, and if i put link 1 it moves the whole object. The plan is the get the size of the box itself on the x axis, divide that by half, move the lid back by that much then rotate and move it upwards... and figure out the little adjustments from there to get it all to line up right. But right now I'm stuck on getting a linked prim to move at all! ;A;

This is actually an issue I've had whenever I've tried, no matter what tutorial or thread I follow. It's kind of frustrating to be able to program a clock and stuff but as soon as moving things around in the actual game comes into play I'm absolutely useless, lol. 
Here's what I have at the moment. I realize I'll probably have to add a lot to this to make it work perfectly (ie, detecting resizing, stuff like that) but for now I need help just with this. Save me, heroes!

vector pos;
vector size;

default
{
    on_rez(integer start_param)
    {
        pos=llGetLocalPos();
        size=llGetScale();
    }
    
    touch_start(integer num_detected)
    {
        float x = size.x;
        float newx = x/2;
        vector newpos = <newx,pos.y,pos.z>;
        llSetLinkPrimitiveParams(2,[PRIM_POS_LOCAL,newpos]);
    }
}

 

Edited by Mellorious
Trying to add a bit of clarity to my scatterbrained typing style don't mind me
Posted

I would try putting the statements that set pos and size into state_entry. I note that your posted script doesn't have a state entry, but I don't know if this has a bearing on the issues you saw.

There is a second way to do this, and that is to get the local pos (and rot) of the lid when it is closed, by just chatting out those values, then edit the box and move the lid to where it should be when open, and again use a script to chat out the values (typically you would have a script that does this in response to a touch). This allows you more variation than just trying to offset the lid by half the size.

Having got two sets of local pos values, you then create a final script that has these values in a pair of vectors and then sets one or the other for the lid according to whatever your chosen command sequence is.

  • Like 3
Posted
16 hours ago, Mellorious said:
pos=llGetLocalPos();

if this script is in the root prim of your object, its "local position" will always be <0,0,0>, but if this script is in the linked prim, then

16 hours ago, Mellorious said:
        llSetLinkPrimitiveParams(2,[PRIM_POS_LOCAL,newpos]);

would be better off using LINK_THIS rather than explicitly link 2.

 

Whenever I've had prims not moving problems, it was either because I was using local instead of global or vice-vera, or just not getting numbers right somewhere. It can be really helpful to calculate by hand what you expect the numbers to be, and then llOwnerSay() what numbers actually are when the script is actually running. "What is the local position of the linked prim before I try and move it?" (llGetLinkedPrimParams) "What is the local position I'm trying to set the linked prim to?" "after I set the new position, did the measured position actually change?"

  • Like 1
Posted
8 hours ago, Profaitchikenz Haiku said:

I would try putting the statements that set pos and size into state_entry. I note that your posted script doesn't have a state entry, but I don't know if this has a bearing on the issues you saw.

There is a second way to do this, and that is to get the local pos (and rot) of the lid when it is closed, by just chatting out those values, then edit the box and move the lid to where it should be when open, and again use a script to chat out the values (typically you would have a script that does this in response to a touch). This allows you more variation than just trying to offset the lid by half the size.

Having got two sets of local pos values, you then create a final script that has these values in a pair of vectors and then sets one or the other for the lid according to whatever your chosen command sequence is.

I was wondering if this would be better with on_rez or state_entry. This is a really good idea and really simplifies what I was trying to do! :P

7 hours ago, Quistess Alpha said:

if this script is in the root prim of your object, its "local position" will always be <0,0,0>, but if this script is in the linked prim, then

would be better off using LINK_THIS rather than explicitly link 2.

 

Whenever I've had prims not moving problems, it was either because I was using local instead of global or vice-vera, or just not getting numbers right somewhere. It can be really helpful to calculate by hand what you expect the numbers to be, and then llOwnerSay() what numbers actually are when the script is actually running. "What is the local position of the linked prim before I try and move it?" (llGetLinkedPrimParams) "What is the local position I'm trying to set the linked prim to?" "after I set the new position, did the measured position actually change?"

OH that explains a lot, the script was in the root prim. I'll keep this in mind and give LINK_THIS a try, ty! 

10 hours ago, Xiija said:

it's a lil extreme, but this door script shows one way to do  this...

https://wiki.secondlife.com/wiki/Smooth_Rotating_Linked_Door_With_Hinge

Godspeed, snippets like this save lives. If I don't use it now I will be later, lol.

You are about to reply to a thread that has been inactive for 134 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
×
×
  • Create New...