Sliding Door script
Code: Select all
// Script Name: Basic_sliding_doorscript.lsl
// Author: Kyrah Abbattoir
//The miost basic of all doors, but still very useful
// Downloaded from : http://www.free-lsl-scripts.com/freescripts.plx?ID=790
// This program is free software; you can redistribute it and/or modify it.
// License information must be included in any script you give out or use.
// This script is licensed under the Creative Commons Attribution-Share Alike 3.0 License
// from http://creativecommons.org/licenses/by-sa/3.0 unless licenses are
// included in the script or comments by the original author,in which case
// the authors license must be followed.
// Please leave any authors credits intact in any script you use or publish.
////////////////////////////////////////////////////////////////////
// CATEGORY:Door
// DESCRIPTION:The miost basic of all doors, but still very useful
// ARCHIVED BY:Ferd Frederix
/////////////////////////////////
//ultra basic sliding door script
//by Kyrah Abattoir
/////////////////////////////////
vector closed = <38,79,26.2>;//XYZ coordinates of the door when closed
vector open = <38,80,26.2>;//XYZ coordinates of the door when closed
float time = .1;//time before the door close itself
default
{
state_entry()
{
llSetPos(closed);
llSetText("",<1,1,1>,1.0);//REMOVE THIS LINE
}
touch_start(integer total_number)
{
llSetPos(open);
llSleep(time);
llSetPos(closed);
}
}
// END //
Code: Select all
//
// Script Name: Door.lsl
// Author: Ezhar Fairlight
//improved door script
// Downloaded from : http://www.free-lsl-scripts.com/freescripts.plx?ID=887
// This program is free software; you can redistribute it and/or modify it.
// License information must be included in any script you give out or use.
// This script is licensed under the Creative Commons Attribution-Share Alike 3.0 License
// from http://creativecommons.org/licenses/by-sa/3.0 unless licenses are
// included in the script or comments by the original author,in which case
// the authors license must be followed.
// Please leave any authors credits intact in any script you use or publish.
////////////////////////////////////////////////////////////////////
// CATEGORY:Door
// DESCRIPTION:improved door script
// ARCHIVED BY:Ferd Frederix
// improved door script by Ezhar Fairlight
// features: automatic closing, workaround for rotating out of position,
// doesn't mess up when moved, adjustable direction (inwards/outwards)
// updated for SL 1.1 damped rotations, small bugfix
// ********** USER SETTINGS HERE **********
float TIMER_CLOSE = 7; // 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(<-DIRECTION * PI_BY_TWO,0,0>);
rot = delta * rot; // rotate by -45 degree
llSetRot(rot);
}
else if ( what == DOOR_CLOSE)
{
rot = llGetRot();
delta = llEuler2Rot(<DIRECTION * PI_BY_TWO,0,0>); // rotate by 45 degree
rot = delta * rot;
llSetRot(rot);
llTriggerSound("Door close", 0.8);
}
}
default
{ // is closed
on_rez(integer start_param)
{ // reset, so we store the new position
llResetScript();
}
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;
}
}
// END //