Difference between revisions of "Sliding Door"
Jump to navigation
Jump to search
(New page: <lsl> // Set at closed position, then reset script. vector pos; // closed position when script is reset vector opos; // open position rotation rot; float amt = 1.8;...) |
|||
Line 1: | Line 1: | ||
<lsl> | <lsl> | ||
// Set at closed position, then reset script. | // Create door. X is up/down, Y is open close. | ||
// Put script in door. | |||
// Set door at closed position, then reset script. | |||
// Touch to open or close, or closes on timer | |||
vector pos; // closed position when script is reset | vector pos; // closed position when script is reset |
Latest revision as of 14:46, 13 January 2008
<lsl> // Create door. X is up/down, Y is open close. // Put script in door. // Set door at closed position, then reset script.
// Touch to open or close, or closes on timer
vector pos; // closed position when script is reset vector opos; // open position rotation rot; float amt = 1.8; // how far to slide, in meters integer dir = -1; // direction to slide. change sign to switch float offset = 0.1; // a little in or out as opposed to left right. integer open; // TRUE is open. float delay = 20; // seconds to stay open integer slice = 4; // how many steps during open and close
slide( vector tgt ) {
vector npos = llGetPos(); vector delta = (tgt - npos)/slice; integer s; for( s=1; s < slice; ++s ) { npos += delta; llSetPos( npos ); } llSetPos(tgt);
}
close() {
llSetTimerEvent(0); slide(pos); llSetPos(pos); llSetRot(rot); open = FALSE;
}
default
{
state_entry() { pos = llGetPos(); rot = llGetRot(); opos = pos + dir*(<0,amt,offset>*rot); // assumes x axis is UP open = FALSE; } on_rez(integer n) { llResetScript(); }
touch_start(integer total_number) { if( open ) { close(); } else { slide(opos); llSetTimerEvent(delay); open = TRUE; } } timer() { close(); }
} </lsl>