Jump to content

How to Make a Box Lid?


Prokofy Neva
 Share

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

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

Recommended Posts

I have a simple thing I want to do that always drives me crazy in SL.

I just want to put a lid on a box, and have it click to open and shut, to go up and down.

Why is this so hard? If I put a door script into it, it gets all messed up because of the way doors are in SL, which are really solids with half invisible with strange things going on with axis this and that.

I have one box I made someone helped me with where DoorAxisX worked. But now it won't on another box, possibly due to conflict with another script, or horrors, the way the prims are linked up. That is always confusing.

Can somebody just baby-step me through making a box lid with a script in it that works at any angle, i.e. wherever rezzed out.

 

 

Link to comment
Share on other sites

Darn, i thougt it was the solution here... not !

I did follow everything as i read. When i link it, the whole linked set moved no matter how i set it up, hing prim used et cetera.

Me too had a box made, 8 prims together with 4 bottles of wine. and i wanted to have the lid open/close upon touch. I can, but just not the lid linked :(

This should be made much more simple in SL instead of going through a whole lecture... pfew.

Well it was worth a try again.

 

 

 

Link to comment
Share on other sites

While Void's method is by far the best and simplest way of making a door or lid I know, I had a shot at writing a script for an uncut lid prim (which sometimes you need -- if, for example, the lid can't be cut because it's a sculpted prim and the axis is in the wrong place).

This makes the lid prim pivot on the bottom edge of its own side 4, the side the red arrow goes into in local ruler mode, no matter how the prim is rotated on the box.    The script can go in either the lid or the root prim; the lid must not be the root, though.   And the box will only open and close if you touch the lid.

Put the word "lid" (no quotes) in the description field of the prim, so the script knows which prim it's supposed to move.

 

//expects a single uncut box prim as the lid, pivoting on the bottom edge its side 4 (lesser x side)integer lidLink=-1;integer lidSwing =-90;rotation rotLidSwing;rotation lidRot;vector lidPos;vector lidSize;find_prims(){    integer max = llGetNumberOfPrims()+1;    while(max--){        string s = llToLower(llStringTrim((string)llGetLinkPrimitiveParams(max,[PRIM_DESC]),STRING_TRIM));        if(s=="lid"){            lidLink=max;            lidSize=llList2Vector(llGetLinkPrimitiveParams(lidLink,[PRIM_SIZE]),0);            return;        }    }    if(lidLink<0){        llOwnerSay("can't find a lid prim");    }}default{    state_entry()    {        find_prims();        rotLidSwing = llEuler2Rot( <0.0, (float)lidSwing * DEG_TO_RAD, 0.0> );    }    changed(integer change){        if(change & CHANGED_LINK || change & CHANGED_SCALE){            find_prims();        }    }    touch_start(integer total_number)    {        if(lidLink<0){//sanity check            find_prims();        }        if(llDetectedLinkNumber(0)==lidLink){            list params = llGetLinkPrimitiveParams(lidLink,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);            lidRot=llList2Rot(params,1);            lidPos=llList2Vector(params,0);            vector offset = <lidSize.x*0.5,0.0,lidSize.z*0.5>*lidRot;            vector pivot = lidPos-offset;            llSetLinkPrimitiveParamsFast(lidLink,[PRIM_ROT_LOCAL,rotLidSwing*lidRot,                PRIM_POS_LOCAL,pivot+<lidSize.x*0.5,0.0,lidSize.z*0.5>*rotLidSwing*lidRot]);            rotLidSwing= (ZERO_ROTATION / rotLidSwing);        }    }}

 

 

Link to comment
Share on other sites

Hi, thanks, I'll have to try this.

 

So far Void Singer's script is what is working for me because it enables the lid and box to be linked, which they need to be in a product like a box of cookies that would have to be moved around by the customer, without having to rez out aggregated prim batches every time.

But you do have to link it right, I believe you start with the bottom of the box, then link the link second -- or else the entire object moves up and down. When you see it doing that, you know you haven't linked in the right sequence.

Cutting prims is something that isn't an automatic easy thing to do for beginners or even people who are simply mathematically challenged like me. So I'd rather have a script that will move any object of any cut or type, prim or sculpty, so I will try this other script. But for now Void's is working because Osprey gave me a pre-cut prim -- she's the best!

Link to comment
Share on other sites

What is a linked prim, and what is a root? That is the question.

 

That is, sure, I know -- after 7 years in SL -- the theory of these things, and I know there are "root prims" that one must be careful to "link to right".


But in layman's terms, it's easier to explain it by the actual object. Like the bottom of the box is the root, the lid will be linked.

Link to comment
Share on other sites

the script could be much more complicated, but I kept it simple so that it could be easily integrated into other scripts...

and is why contains the exact cuts to use and two alternates which cover saloon hinges, and both interior and exterior door hinges.

as for linking woes... a person will have to figure out linking no matter what style of hinge script is used, because they simply can't work targeting the root of a linked object unless you plan to rotate the whole object. I suppose I should make that more clear though

Link to comment
Share on other sites

I now have about six different stories with six different scripts and cut prims and stuff -- it's like asking directions from 3 people in Maine you happen to see in a gas station.

Ayup...wull ya wanna go up to Rt. 96

No no no. What he wants to do is take the back road behind the Wal-Mart

Nope. I'll tellya whatcha gotta do. Whatcha wanna do, see, is you go up to the stoplight.

Etc.

Very confusing.

Second Life is too hard.

 

 

Link to comment
Share on other sites

A better analogy might be with asking several different people how to make a cheese omelette.   

All the recipes are going to involve beating eggs, grating cheese and using a frying pan, but are likely going to differ considerably in precise detail.  Following any one of them will probably give perfectly acceptable results, but mixing and matching probably won't.  Just pick one you find easy to follow and which gives results you like. 

Link to comment
Share on other sites

The root is the last prim you bring into a set of prims when you link them together as a single "multi-prim" object.

So if you want the lid to be the root prim then select the base first and lid last when you link them into a single object.

If you want the base to be the root prim, select the lid first and the base last when you link them into a single object.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4601 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...