Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Want sliding door to close automatically

Nisa Maverick
Registered User
Join date: 3 Jun 2007
Posts: 224
12-06-2008 12:03
I have this script for sliding doors but it doesnt close automatically I'm not much good at scripting yet can anyone tell how to get the door to close without having to touch it again please.



//Movement Direction
float X = 0.0;
float Y = 0.8;
float Z = 0.0;

vector Slide = <X, Y, Z>;
vector Pos;

integer door_open = FALSE;

integer open(string av_name) // Opens the door.
{
llSetPos(llGetPos() + ((Slide * -1) * llGetRot()));
return TRUE;
}
//- - - - - - - - - - - - - - - -
integer close(string av_name) // Closes the door.
{
llSetPos (llGetPos() + (Slide * llGetRot()));
return FALSE;
}
//- - - - - - - - - - - - - - - -




default
{
touch_start(integer total_number)
{
if (!door_open){
door_open = open(llDetectedName(0));
} else {
door_open = close(llDetectedName(0));
}
}

}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
12-06-2008 14:40
Try replacing

CODE

if (!door_open){
door_open = open(llDetectedName(0));
}else {
door_open = close(llDetectedName(0));
}


with

CODE

{
door_open = open(llDetectedName(0));
llSleep(10.0); // Fiddle with the time in seconds to get a time that you like
door_open = close(llDetectedName(0));
}


You won't need the if test in touch_start any more, because the script will automatically put the door into its default closed position every time the touch_start event ends.