Void Singer Posted May 16, 2011 Share Posted May 16, 2011 Doors, Gates, Lids, anything with a simple hinge/*//( v7-D Simple Hinge Action )--//*/ /*//-- Works At ANY Angle --//*/ /*//-- NOTES: works in ANY single prim door, linked or un-linked works in multi-prim doors NOT linked to a larger structure Never needs reset (even after moving/rotating)//*/ /*//-- REQUIREMENTS: Root should either be a cylinder (to represent a hinge) or half cut prim; I suggest Box, pathcut start=.125, end=.625//*/ /*//-- CAVEAT: Single prim doors are limited to 5m width Treats current position as closed when reset//*/ /*//-- USERS MODIFY HERE v --//*/ integer gIntSwing = 90; /*//-- use -# to reverse the direction of swing, eg. -90; --//*/ rotation gRotSwing; default{ state_entry(){ gRotSwing = llEuler2Rot( <0.0, 0.0, (float)gIntSwing * DEG_TO_RAD> ); } touch_end( integer vIntNul ){ llSetLocalRot( (gRotSwing = (ZERO_ROTATION / gRotSwing)) * llGetLocalRot() ); } } /*//-- IF Redistributing as-is:Please leave script full permissions & include all comments so that others may learn and use//*/ to use in lids, create lid as above, move/rotate (via object edit) into place, done.to create realistic hinge action: path-cut start = .375, end = .625 (preferred) OR path-cut start = .125, end = .375(remove gIntSwing and state_entry if you pre-calculate and assign the value of gRotSwing) 5 1 Link to comment Share on other sites More sharing options...
Luc Starsider Posted May 16, 2011 Share Posted May 16, 2011 That's great Void. A question: Why do you recommend that the root prim is a pathcut cube? Or why is it important what type/shape the root is? - Luc - Link to comment Share on other sites More sharing options...
Void Singer Posted May 16, 2011 Author Share Posted May 16, 2011 Ya know, that a very good question and it's actually based on a bit of experience.... the cube (should read box, will edit that) because it's a flat surface on all sides, even after it's cut, so that it retains it's basic shape. the path cuts suggested allow the inside/outside (top/bottom for lids) to face along the x axis which makes modifications like automatic opening and direction of swing for reversible doors a little easy to code for...and because some users are unfamiliar with the build tools so may not know what to modify to get a "half-cut" that the code requires, and because cuts start from the corner not the side as some might expect (so it helps counteract the non obvious nature) ETA: the inworld build tools actually conflict on cube vs box, the create tab tooltip calls it a cube, and the edit tab prim type refers to it as a box. however all the scripting commands also refer to it as a box, so that's what I'm going to go with. 1 Link to comment Share on other sites More sharing options...
Luc Starsider Posted May 16, 2011 Share Posted May 16, 2011 That just said 'wosh' as it flew past me... Gonna have to get out my hammer and do some building this evening to see if I can comprehend what you are saying by actually trying it out.... Thanks, tough. - Luc - Link to comment Share on other sites More sharing options...
PeterCanessa Oh Posted May 16, 2011 Share Posted May 16, 2011 ... the simple answer ... Prims rotate around their centre, which would be a very strange thing for a door to do. When a box is cut in half like this the centre 'looks' as if it is at the side (because you can't see the rest which has been cut away). So the door 'looks' like it is rotating around the edge, on a hinge. 1 Link to comment Share on other sites More sharing options...
Luc Starsider Posted May 16, 2011 Share Posted May 16, 2011 Ahhhh. Now I get it! Thanks Peter! I read it as if the path cut prim was the hinge (root prim) to which you attached the actual door (a second prim linked to the root prim). Duh!!!! (I actually know about the rotating around the centre in a one prim door. I just didn't connect the dots properly) - Luc - Link to comment Share on other sites More sharing options...
Void Singer Posted May 16, 2011 Author Share Posted May 16, 2011 heh, and I totally misread your meaning just goes to show that sometimes a lot more thought goes into some things that appear simple, and sometimes even simpler things get completely overlooked Link to comment Share on other sites More sharing options...
Luc Starsider Posted May 16, 2011 Share Posted May 16, 2011 Lol. True. - Luc - Link to comment Share on other sites More sharing options...
Darkness Anubis Posted May 16, 2011 Share Posted May 16, 2011 Actually the beauty of this sort of "door" is that it IS only one prim. No need for a hinge prim. For many folks prim pinching is a way of life so every prim you can cut out of the equation is a very good thing. 1 Link to comment Share on other sites More sharing options...
ThomasG81 Posted March 5, 2012 Share Posted March 5, 2012 So what should the code look like in order to get the 'hinge' action? Where do the alternative path-cut values go? Sorry total noob here Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 7, 2012 Share Posted March 7, 2012 The code looks exactly like it is now. No change whatsoever. Path cut values are used for shaping your door, using your Build/Edit tool in world. The whole idea of this door script and others built on this theme is that you create a door by cutting a rectangular prim in half, so that its hinge is along the cut edge. Otherwise, since a prim always rotates around its central axis (in this case, its Z-axis), you'd have a door that looks like a butterfly valve instead of a normal door. Link to comment Share on other sites More sharing options...
Sweetcandylove14 Posted February 21, 2015 Share Posted February 21, 2015 thank finally some one who can make a good easy sc ript for an easy object i have been looking for months thank you sooooo much Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 12, 2015 Share Posted March 12, 2015 Several people have asked if there is a way to reduce the number of scripts in a building by controlling all doors centrally from a single script. Rather than write a new script to do that, I have modified Void's simple hinge script as an example of how it might be done. // Control many doors in the same linkset -- Rolig Loon -- March 2015// Application of Void Singer's SImple Hinge Action to control several doors// in the same building independently from a single script.// All doors must be named "door"./*//( v7-D Simple Hinge Action )--//*//*//-- Works At ANY Angle --//*//*//-- NOTES: works in ANY single prim door Never needs reset (even after rotating)//*//*//-- REQUIREMENTS: Root must either be a cylinder (to represent a hinge) or cut prim; I suggest cube, pathcut start=.125, end=.625//*//*//-- CAVEAT: Single prim doors are limited to 5m width Treats current position as closed when reset//*/ /*//-- USERS MODIFY HERE v --//*/integer gIntSwing = -90;/*//-- use -# to reverse the direction of swing, eg. -90; --//*/rotation gRotSwing;integer gDoor;list gDoors;default{ state_entry() { gDoors = []; integer i = llGetNumberOfPrims(); while(i) { if (llStringTrim(llToLower(llGetLinkName(i)),STRING_TRIM) == "door") { gDoors += [i]; } --i; } gRotSwing = llEuler2Rot( <0.0, 0.0, (float)gIntSwing * DEG_TO_RAD> ); state running; }}state running{ touch_end( integer num ) { gDoor = llDetectedLinkNumber(0); if (~llListFindList(gDoors,[gDoor])) { state active; } }}state active{ state_entry() { llSetTimerEvent(5.0); // Set timer to close the door in 5 seconds rotation RotLocal = llList2Rot(llGetLinkPrimitiveParams(gDoor,[PRIM_ROT_LOCAL]),0); llSetLinkPrimitiveParamsFast(gDoor,[PRIM_ROT_LOCAL,(gRotSwing = (ZERO_ROTATION / gRotSwing)) * RotLocal] ); } touch_end(integer num) { if (~llListFindList(gDoors,[llDetectedLinkNumber(0)])) { rotation RotLocal = llList2Rot(llGetLinkPrimitiveParams(gDoor,[PRIM_ROT_LOCAL]),0); llSetLinkPrimitiveParamsFast(gDoor,[PRIM_ROT_LOCAL,(gRotSwing = (ZERO_ROTATION / gRotSwing)) * RotLocal] ); llSetTimerEvent(0.0); state running; } } timer() { rotation RotLocal = llList2Rot(llGetLinkPrimitiveParams(gDoor,[PRIM_ROT_LOCAL]),0); llSetLinkPrimitiveParamsFast(gDoor,[PRIM_ROT_LOCAL,(gRotSwing = (ZERO_ROTATION / gRotSwing)) * RotLocal] ); llSetTimerEvent(0.0); state running; } } 1 Link to comment Share on other sites More sharing options...
richardsinclair3666 Posted September 11, 2016 Share Posted September 11, 2016 Hi, I wish for a ramp that is slow in rasing like a draw bridge or Millennium falcon ramp.. I will use a door script but I need in the script, a section for speed of opening and closing please Link to comment Share on other sites More sharing options...
richardsinclair3666 Posted September 11, 2016 Share Posted September 11, 2016 hello I wish for a section in the script to control the speed of the opening and closing pluss sound section, can you help please Link to comment Share on other sites More sharing options...
Rolig Loon Posted September 11, 2016 Share Posted September 11, 2016 You could certainly add code to the script to give doors speed control, but I would not recommend it. As you can see, the doors move with llSetLinkPrimitiveParams, which is not designed to have a native speed control. You would need to contrive an iterative sequence with a timer event. In my opinion, that's more trouble than it's worth. If I were faced with a similar problem, I would use a completely different system. The old Toy Wylie Smooth Door script is one possible model, but I would probably use Keyframed Motion, which is designed for exactly that sort of control. You could not link the doors, of course, but you could certainly control several doors from the same remote trigger. As interesting as those alternatives are, this is not really the place to discuss them. Link to comment Share on other sites More sharing options...
Fennet Posted October 10, 2016 Share Posted October 10, 2016 This post might be an oldie, but the script works like a charm and was exactly what I needed for my gate. Thanks! (The root prim should be apparent in the picture. No modification needed; I just copied and pasted the script as written into a new script and it worked perfectly the first time.) Link to comment Share on other sites More sharing options...
Recommended Posts
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