clarashymonkey Posted November 25, 2019 Share Posted November 25, 2019 I am working on a door that concertinas along its x-axis in order to open and close and I have the concertina part working nicely. My problem is repositioning the door as it changes size so it remains butted up against the left-hand door post. It's refusing to reposition! It is part of a link-set (with link number 2) btw. And I am pretty sure I have the maths right. The trouble appears to be the line that should move the door prim but doesn't. I am sure that I am missing something blindingly obvious but I cannot for the life of me think what. Help? vector door_XYZ; // door position vector float door_LHS; // x co-ordinate of the left-hand doorpost float door_SIZ; // door width (variable) float door_MOD; // the amount by which the door shrinks/grows per iteration of the open/close routine door_operation(integer mode){ integer i; for(i = 0; i < 32; i++){ door_SIZ += (mode * door_MOD); // shrink/grow the door door_XYZ.x = door_LHS + (door_SIZ / 2); // recalcalculate the x co-ordinate relative to the doorpost llSetLinkPrimitiveParamsFast(2,[PRIM_SIZE,<door_SIZ, 0.01, 3.35>]); // resize the door prim llSetLinkPrimitiveParamsFast(2,[PRIM_POSITION,<door_XYZ.x, door_XYZ.y, door_XYZ.z>]); // THE BIT THAT DOESN'T SEEM TO WORK } } default{ state_entry(){ door_XYZ = llList2Vector(llGetLinkPrimitiveParams(2,[PRIM_POSITION]),0); door_SIZ = .15; // initial width of the door (open = 0.15; closed = 2.0) door_LHS = door_XYZ.x - (door_SIZ / 2); door_MOD = (2.0 - 0.15) / 32; } // there's a listen triggering the open/close routine with the appropriate open/close (-1 or +1) parameter } Link to comment Share on other sites More sharing options...
Qie Niangao Posted November 25, 2019 Share Posted November 25, 2019 (edited) At first glance, I'm nervous about the integer division in calculating door_LHS and door_XYZ.x -- I'd try switching the divisor to 2.0 instead of 2. I don't know the dimensions here but I'm guessing door_SIZ / 2 == 0. EDIT: Okay, that's wrong. Hmmm. Edited November 25, 2019 by Qie Niangao Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted November 25, 2019 Share Posted November 25, 2019 (edited) I see a couple problems (been ages since I've scripted, so take me with a grain of salt): 1) I think you are grabbing the LHS position from your door (link #2) not the post (link #1). 2) I think you must use PRIM_POS_LOCAL to move a child prim. That will change the math of your door_LHS assignment. Edited November 25, 2019 by Madelaine McMasters 1 Link to comment Share on other sites More sharing options...
Qie Niangao Posted November 25, 2019 Share Posted November 25, 2019 Yeah, I think @Madelaine McMasters' #2 is why it's not moving at all: when you get PRIM_POSITION of a child prim, it returns region coordinates, but if you set PRIM_POSITION of a child prim it expects local coordinates, and region coordinates are usually gonna be way beyond the link limits (as well as just wrong). So, yeah, PRIM_POS_LOCAL for both should help a lot. Link to comment Share on other sites More sharing options...
clarashymonkey Posted November 26, 2019 Author Share Posted November 26, 2019 (edited) Thank you so much everyone. I now have my door moving! Not moving as intended, I hasten to add. Something to do with the orientation of the door prim itself I think. It's actually wandering about all over the place at the moment so I do not recommend anyone using the script as it stands. But movement is good so I can work on the rest. [UPDATE: wandering door problem solved! And it wasn't the script. My door is actually for a lift (elevator?), parts of which had somehow got rotated when they were linked to form the whole. It now works perfectly so, once again, thank you *smacking head for not thinking of it myself*] Edited November 26, 2019 by clarashymonkey update 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