Angus Kuhr
Dwarf with a Hammer
Join date: 17 Jul 2005
Posts: 43
|
07-27-2005 21:26
OK, I'm entirely new to LSL, and admittedly a mediocre programmer at best. Time might fix this, but in the mean time, I'm going to ask goofy questions.
The first thing I want to do is make a door open and close when you touch it. I have the Touch set up, but I'm not 100% about just what rotation thing to use, and how I should set it to stop where I want it to.
Any advice?
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
07-28-2005 01:12
You'll want one of these: http://secondlife.com/badgeo/wakka.php?wakka=llSetRothttp://secondlife.com/badgeo/wakka.php?wakka=llSetLocalRotdepending on how you've made your door and probably one of these: http://secondlife.com/badgeo/wakka.php?wakka=llGetRothttp://secondlife.com/badgeo/wakka.php?wakka=llGetLocalRotIf you want to make it smart. You may also want a bit of: http://secondlife.com/badgeo/wakka.php?wakka=llGetPos or http://secondlife.com/badgeo/wakka.php?wakka=llGetLocalPoshttp://secondlife.com/badgeo/wakka.php?wakka=llSetPos and If you set up the rotation up in and euler (rotation around x, y, z axes) you'll also need some of: http://secondlife.com/badgeo/wakka.php?wakka=llEuler2RotTo convert it to the system that the various rots use. There are several ways, but your touch_start() event needs to know whether the door is open or closed (can do this with states or with a boolean) and apply the opposite rotation. The get and set pos commands help with drift, which does tend to happen a little.
|
Angus Kuhr
Dwarf with a Hammer
Join date: 17 Jul 2005
Posts: 43
|
07-28-2005 20:20
Ah, thanks. I already have the states set up. Now it's just a matter of figuring out exactly which one of those to use.
Also, how much of a problem can prim drift become?
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
07-29-2005 04:15
For a door a moderately large one, on the assumption people will use it a fair bit.
I made a fancy box with a fancy lid on it for someone. The trials and tribulations involved don't really matter, but at one point the lid was 'ever opening' so four clicks would bring it back to 'closed' (I claim it was a prototype, honest!). Anyway, those four clicks had the lid drift noticeably, maybe only a millimetre or two, I don't remember now, but still a noticeable move.
In a door a millimetre or two isn't too bad but 10 of them and most people will notice the door doesn't fit it's jams quite right, 100 of them and it's not in the door frame any more...
I do remember someone suggesting it had got better since 1.6 somewhere, but I've not tested it I must admit.
|
Thili Playfair
Registered User
Join date: 18 Aug 2004
Posts: 2,417
|
07-30-2005 09:26
Im not really any good at scripting this is one of the scripts i use on doors,i need a autoclose tho, trying to figure out how ,,People always click on doors and leave them open ~.~ integer on=FALSE; default { touch_start(integer total_number) { if(on==TRUE) { rotation rot = llGetRot(); rotation delta = llEuler2Rot(<0,0,PI/4>); rot = delta * rot; llSetRot(rot); llSleep(0.25); rot = delta * rot; llSetRot(rot); on=FALSE; } else { rotation rot = llGetRot(); rotation delta = llEuler2Rot(<0,0,-PI/4>); rot = delta * rot; llSetRot(rot); llSleep(0.25); rot = delta * rot; llSetRot(rot); on=TRUE; } } }
Slide door exsample, if anyone know how to kill this from being active please let me know, i always try to find and use script that are not active all the time integer gSteps = 7; vector gOpenOffset = <-0.25, 0.0, 0.0>; vector gCloseOffset = <0.25, -0.0, 0.0>; default { state_entry() { state closed; } } state closed { touch_start(integer total_number) { integer i; vector basepos = llGetPos(); for (i=0; i <= gSteps; i++) { llSetPos(basepos + i*gOpenOffset); //llSleep(0.05); } state open; } } state open { touch_start(integer num) { integer i; vector basepos = llGetPos(); for (i=0; i <= gSteps; i++) { llSetPos(basepos + i*gCloseOffset); // llSleep(0.1); } state closed; } }
|
ramon Kothari
FIC
Join date: 9 Dec 2002
Posts: 249
|
07-30-2005 10:03
here is one that works to close doors automatically // features: automatic closing, workaround for rotating out of position, // doesn't mess up when moved, adjustable direction (inwards/outwards)
// ********** USER SETTINGS HERE ********** float TIMER_CLOSE = 5.0; // automatically close the door after this many seconds, // set to 0 to disable
integer DIRECTION = 1; // direction door opens in. Either 1 (outwards) or -1 (inwards); // ********** END OF USER SETTINGS **********
integer DOOR_OPEN = 1; integer DOOR_CLOSE = 2;
vector mypos; // door position (objects move a tiny amount // away from their position each time they are rotated, // thus we need to workaround this by resetting // the position after rotating) door(integer what) { rotation rot; rotation delta; llSetTimerEvent(0); // kill any running timers if ( what == DOOR_OPEN ) { // llTriggerSound("Door open", 0.8); rot = llGetRot(); delta = llEuler2Rot(<0, 0, -DIRECTION * (PI / 4)>); rot = delta * rot; // rotate by -45 degree llSetRot(rot); llSleep(0.25); rot = delta * rot; // again llSetRot(rot); } else if ( what == DOOR_CLOSE) { rot = llGetRot(); delta = llEuler2Rot(<0, 0, DIRECTION * (PI / 4)>); // rotate by 45 degree rot = delta * rot; llSetRot(rot);
llSleep(0.25); rot = delta * rot; // again llSetRot(rot); // llTriggerSound("Door close", 0.8); } }
default { // is closed state_entry() { mypos = llGetPos(); // remember where we're supposed to be } touch_start(integer total_number) { door(DOOR_OPEN); state is_open; } moving_end() { // done moving me around, store new position mypos = llGetPos(); } }
state is_open { state_entry() { llSetTimerEvent(TIMER_CLOSE); } touch_start(integer num) { door(DOOR_CLOSE); llSetPos(mypos); // workaround for tiny movements during rotation state default; } timer() { // it's time to close the door door(DOOR_CLOSE); llSetPos(mypos); // workaround for tiny movements during rotation state default; } moving_start() { // close door when door is being moved door(DOOR_CLOSE); state default; } }
_____________________
"Life should not be a journey to the grave with the intention of arriving safely in an attractive and well preserved body,but rather skid in sideways, beer in one hand, body thoroughly used up,totaly worn out and screaming....Damn, what a ride!!"
|