//How far in meters to travel in each direction. Two or all three can be used for angled movement
//NOTE: when linked, this is relative to the root prim
//Positive = move north, negative = move south
float NorthSouth = 0.5;
//Positive = move east, negative = move west
float EastWest = -0.0;
//Positive = move up, negative = move down
float UpDown = 0.0;
//The amount in seconds to stay open, set to 0 to not autoclose
//-- delete next line if not using autoclose
float Timer = 0.0;
//-- begin sound section: delete to 'end sound section' if not using sounds
//Sound to play on open, either a UUID or a name in the door contents
// in quotation marks. if a name, it must be exact.
string OpenSound = "";
//Volume to play open sound, 0.0 is same as no sound, 1.0 is max
//-- setting this to 0.0 turns off open sounds
float OpenVol = 0.0;
//Sound to play on close, either a UUID or a name in the door contents
// in quotation marks. if a name, it must be exact.
string CloseSound = "";
//Volume to play close sound, 0.0 is same as no sound, 1.0 is max
//-- setting this to 0.0 turns off close sounds
float CloseVol = 0.0;
//-- end sound section
//misc variables
vector Offset;
integer Open;
//-- begin sound trigger: delete to 'end sound trigger' if not using sounds
//-- included to trap errors triggering sounds which delay the script firing
fTriggerSound(string sound, float volume)
//Written by Strife Onizuka
//-- tweaked by Void Singer
{
if (volume){
//-- makes sure sound is valid before playing
if ((key)sound);
else if (INVENTORY_SOUND == llGetInventoryType( sound ) );
else{
return;
}
llTriggerSound(sound, volume);
}
}
//-- end sound trigger
fTriggerSlide(){
//-- begin sound trip: delete to 'end sound trip' if not using sounds
if (Open)
{
fTriggerSound( CloseSound, CloseVol );
}else
{
fTriggerSound( OpenSound, OpenVol );
}
//-- end sound trip
llSetPos( llGetLocalPos() + Offset );
//-- reverse offset so next time it goes the opposite direction
Offset = -Offset;
//-- reverse open state tracking
Open = !Open;
//-- delete next line if not using autoclose
llSetTimerEvent( Timer * Open); //-- if closed timer is turned off
}
default
{
state_entry()
{
Offset = <EastWest, NorthSouth, UpDown>;
}
touch_start( integer vIntNull )
{
//-- safer to ignore simultaneaous touches in doors,
//-- so we dont bother processing more than the first
fTriggerSlide();
}
//-- removed on rez reset because it could reverse the open logic and break the offset.
//-- begin timer: delete to 'end timer' end if not using autoclose
timer()
{
//-- test if it's open so queued timer events don't accidently fire movement code
if (Open)
{
fTriggerSlide();
}
}
//-- end timer
}[/php]
edit:
if only using movement, no autoclose, no sounds all you need is
CODE
//Sliding Door v4
//Works when linked
//by Kayla Stonecutter
//-- tweaked heavily by Void Singer Mar 10, 2008
//How far in meters to travel in each direction. Two or all three can be used for angled movement
//NOTE: when linked, this is relative to the root prim
//Positive = move north, negative = move south
float NorthSouth = 0.5;
//Positive = move east, negative = move west
float EastWest = -0.0;
//Positive = move up, negative = move down
float UpDown = 0.0;
//misc variables
vector Offset;
default
{
state_entry()
{
Offset = <EastWest, NorthSouth, UpDown>;
}
touch_start( integer vIntNull )
{
llSetPos( llGetLocalPos() + Offset );
//-- reverse offset so next time it goes the opposite direction
Offset = -Offset;
}
}
;