Sliding door that glides smoothly from closed to open and back with an auto timer.
- DO NOT LINK TO HOUSE (even though it is quite funny).
// V1 //
vector target = <1.5, 0.1, 0.0>; // Play about to get the result you want.
// Each of the 3 floats represents X, Y, Z region axis in meters.
float time = 10.0; // Time for auto close. Set to zero to disable.
//////////////////////////////////////////////////////////////////
integer t;
integer open;
vector pos;
Door()
{
vector targ;
if(!open)
{
targ = (pos + target);
llSetTimerEvent(time);
}
else
{
llSetTimerEvent(0.0);
targ = (pos);
}
open = (!open);
t = llTarget(targ, 0.04);
llMoveToTarget(targ, 0.75);
llSetStatus(STATUS_PHYSICS |
STATUS_PHANTOM, TRUE);
}
default
{
on_rez(integer param)
{
llResetScript();
}
state_entry()
{
llSetStatus(STATUS_BLOCK_GRAB, TRUE);
llSetStatus(STATUS_PHYSICS |
STATUS_ROTATE_X |
STATUS_ROTATE_Y |
STATUS_ROTATE_Z |
STATUS_PHANTOM, FALSE);
pos = llGetPos();
}
touch_start(integer nd)
{
Door();
}
at_target(integer num, vector tpos, vector opos)
{
llTargetRemove(t);
llSetStatus(STATUS_PHYSICS |
STATUS_PHANTOM, FALSE);
llSetPos(tpos);
}
timer()
{
llSetTimerEvent(0.0);
Door();
}
}