Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Simple Sliding Door

Gene Jacobs
Who? Me?
Join date: 30 Jul 2004
Posts: 127
09-12-2004 07:20
Help, I hit a rut.

I got this sliding door kit with a control panel (it is over kill for what i want, but hey it was free), but i cannot get it to work. All I really want is a basic sliding door script that will slide to a new position when someone touches it (and maybe returns after so many seconds, but i can close a door myself). If anyone has a simple script that a non script guru can use, i would appreciate a copy.
Merana Levy
Ooo.. shiny!
Join date: 10 Aug 2004
Posts: 6
ditto
09-12-2004 08:01
Dont have the nifty remote control and door script package, but I've got a script I snagged off the forums..
Stone cold dead.
I'd love a copy too, Thanks!
Toy LaFollette
I eat paintchips
Join date: 11 Feb 2004
Posts: 2,359
09-12-2004 08:12
this is a simple touch control for a sliding door.
-----------------------------------


// how fast the door opens

float gOpenTime = 1.0;

// global variables that aren#t exposed

float gSteps = 2.0;
vector gOffset = <1.0, 0.0, 0.0>; // 2 meters of total motion

default
{
state_entry()
{
}
touch_start(integer total_number)
{
integer i;
vector localpos = llGetLocalPos();
//llWhisper(0, "localpos = " + (string)localpos);
for (i = 0; i < gSteps; i++)

{

// set the object's position

llSetPos(localpos + i*gOffset);
llSleep(0.1);


-------------------------------------
_____________________
"So you see, my loyalty lies with Second Life, not with Linden Lab. Where I perceive the actions of Linden Lab to be in conflict with the best interests of Second Life, I side with Second Life."-Jacek
Gene Jacobs
Who? Me?
Join date: 30 Jul 2004
Posts: 127
Sliding door
09-12-2004 12:08
it slides one direction, but will not return

am i doing something wrong?
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
09-12-2004 20:16
Here is a sliding door script that I wrote, but have not tested in world, if there are any problems (shouldn't be, but might be a syntax error) just let me know.

It will open when touched, close when touched if open, and automatically close if left open for a set amount of time.

CODE

//Sliding Door Script
//by Rysidian Rubio

//Please feel free to redistribute but DO NOT SELL this script.
//place your door where you want it to be closed, and then put this script into it.

//******Feel free to change the variables between here...

//Globals
float distance = 3;
//this is the total distance you want the door to open in metres.

integer direction = 1;
//use 1 to move along the x axis
//-1 to move in the opposite direction.
//2 to move along the y axis
//-2 to move the opposite direction.
//any other number will make the door inoperable.

float close_time = 20;
//time in seconds before the door automatically closes.
//use 0 to disable auto closing.

//******And here.


vector start_pos;
//this is to eliminate prim drift caused by the distance being a float.

open()
{
//function opens the door in 10 steps to simulate smooth movement.
integer i = 10;
integer j;
vector step;
if (direction == 1)
{
step = <(distance/i),0,0>;
}
else if (direction == 2)
{
step = <0,(distance/i),0>;
}
else if (direction == -1)
{
step = <-(distance/i),0,0>;
}
else if (direction == -2)
{
step = <0,-(distance/i),0>;
}

for (j= 0; j < i; j++)
{
llSetPos(llGetPos() + step);
}

}

close()
{
//function closes the door in 10 steps to simulate smooth movement.
integer i = 10;
integer j;
vector step;
if (direction == 1)
{
step = <(distance/i),0,0>;
}
else if (direction == 2)
{
step = <0,(distance/i),0>;
}
else if (direction == -1)
{
step = <-(distance/i),0,0>;
}
else if (direction == -2)
{
step = <0,-(distance/i),0>;
}

for (j = 0; j < i; j++)
{
llSetPos(llGetPos() - step);
}
llSetPos(start_pos);
}

default
{
state_entry()
{
start_pos = llGetPos();
state closed.
}
}

state Opened
{
state_entry()
{
llSetTimerEvent(close_time);
}

touch_start(integer num_detected)
{
llSetTimerEvent(0);
closed();
state Closed;
}

timer()
{
llSetTimerEvent(0);
close();
state Closed;
}
}

state Closed
{
state_entry()
{
llSetTimerEvent(0);
}

touch_start(integer num_detected)
{
open();
state Opened;
}
}
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
09-12-2004 21:30
OMG! For the LOVE OF GOD, don't use a STEP script! Can you tell I really hate those? I don't think they are wrotht he ressources that they take to operate! Just make them slide in one movement! It's a little fast but you still get teh effect of the sliding door!
_____________________
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
09-12-2004 22:54
Nexus are you serious???
You make it sound like this script is going to serously lag the server, it's not. There are no listens, one timer which turns off after 20 seconds, and a touch event, nothing heavy on the server.
The stepping doesn't do much to the server at all, only takes a few seconds and looks much better than the door "popping" from one position to another. If you believe the contrary then please feel free to prove me wrong with some testing and statistics, or I can do so if you REEEEEALLY think it's necessary.

Or you could just post a script yourself.
Gene Jacobs
Who? Me?
Join date: 30 Jul 2004
Posts: 127
09-13-2004 09:50
From: someone
Originally posted by Rysidian Rubio
Nexus are you serious???
You make it sound like this script is going to serously lag the server, it's not. There are no listens, one timer which turns off after 20 seconds, and a touch event, nothing heavy on the server.
The stepping doesn't do much to the server at all, only takes a few seconds and looks much better than the door "popping" from one position to another. If you believe the contrary then please feel free to prove me wrong with some testing and statistics, or I can do so if you REEEEEALLY think it's necessary.

Or you could just post a script yourself.


Rysidian - thanks very much, i do not care if it is a step (or whatever)

I fixed only 3 typos (which because of your excellent references to the code, was easy for me)

I added a say command and a sound, and I am very happy.... thanks again very much....

Below is the code I used and modified... tested and working in world

-----------------------------------------------


//Sliding Door Script
//by Rysidian Rubio

//Edited by Gene Jacobs - Thanks Rysidian for original script

//Please feel free to redistribute but DO NOT SELL this script.
//place your door where you want it to be closed, and then put this script into it.

//******Feel free to change the variables between here...

//Globals
float distance = 2;
//this is the total distance you want the door to open in metres.

integer direction = 1;
//use 1 to move along the x axis
//-1 to move in the opposite direction.
//2 to move along the y axis
//-2 to move the opposite direction.
//any other number will make the door inoperable.

float close_time = 0;
//time in seconds before the door automatically closes.
//use 0 to disable auto closing.

//******And here.


vector start_pos;
//this is to eliminate prim drift caused by the distance being a float.

open()
{
//function opens the door in 10 steps to simulate smooth movement.
//Gene - I changed to 2 to make it quicker and smother for me
integer i = 2;
integer j;
vector step;
//Gene - I added the sound and speak options below
llSay(0, "Open";);
llTriggerSound("space_door", 2.3);
//Gene - Sound and Speak above
if (direction == 1)
{
step = <;(distance/i),0,0>;
}
else if (direction == 2)
{
step = <0,(distance/i),0>;
}
else if (direction == -1)
{
step = <;-(distance/i),0,0>;
}
else if (direction == -2)
{
step = <0,-(distance/i),0>;
}

for (j= 0; j < i; j++)
{
llSetPos(llGetPos() + step);
}

}

close()
{
//function closes the door in 10 steps to simulate smooth movement.
//Gene - I changed to 2 to make it quicker and smother for me
integer i = 2;
integer j;
vector step;
//Gene - I added the sound and speak options below
llSay(0, "Close";);
llTriggerSound("space_door", 2.3);
//Gene - Sound and Speak above
if (direction == 1)
{
step = <;(distance/i),0,0>;
}
else if (direction == 2)
{
step = <0,(distance/i),0>;
}
else if (direction == -1)
{
step = <;-(distance/i),0,0>;
}
else if (direction == -2)
{
step = <0,-(distance/i),0>;
}

for (j = 0; j < i; j++)
{
llSetPos(llGetPos() - step);
}
llSetPos(start_pos);
}

default
{
state_entry()
{
start_pos = llGetPos();
state Closed;
}
}

state Opened
{
state_entry()
{
llSetTimerEvent(close_time);
}

touch_start(integer num_detected)
{
llSetTimerEvent(0);
close();
state Closed;

}

timer()
{
llSetTimerEvent(0);
close();
state Closed;
}
}

state Closed
{
state_entry()
{
llSetTimerEvent(0);
}

touch_start(integer num_detected)
{
open();
state Opened;

}
}
Gene Jacobs
Who? Me?
Join date: 30 Jul 2004
Posts: 127
Sliding door script
09-13-2004 10:01
Rysidian Rubio,

I noticed that when I move the door, and open then close the door... after the close, it pops back to the origional position.

If I move the door, open the script in the contents folder save it again, it does not do that...


Why does it do that? Just my curious mind thinking...
Gene

PS - is there a way to turn the door on its side and make an elevador?
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
Re: Sliding door script
09-13-2004 20:01
From: someone
Originally posted by Gene Jacobs
Rysidian Rubio,

I noticed that when I move the door, and open then close the door... after the close, it pops back to the origional position.

If I move the door, open the script in the contents folder save it again, it does not do that...


Why does it do that? Just my curious mind thinking...
Gene

PS - is there a way to turn the door on its side and make an elevador?

Gene, I made the script remember it's starting position, and reset to that position when it closes to stop prim drift. When the door moves in steps it divides the total distance you want it to move by the number of steps, the result it a number that is rounded. Due to the rounding over and over again as the door opens and closes you may find that the door has started to 'drift' and doesn't line up when in it's original position.

This door script WON'T work as an elevator because it isn't physical, however you could modify the script to make it an elevator if you wanted.
Zarah Dawn
Adorned Owner & SL Model
Join date: 3 Feb 2004
Posts: 284
11-20-2004 10:15
I got the same free sliding door ... it doesn't work right and I'd love to be able to use it. Cutter & I have played with it and it seems the door( script?) isn't "hearing", but the control is sending. anyhow... if anyone knows about this we'd be very appreciative.

Z (one half of C & Z )
_____________________
Zarah Dawn
Cutter Rubio
Hopeless Romantic
Join date: 7 Feb 2004
Posts: 264
11-21-2004 17:03
I've managed to fix the steel sliding door script. I need to clean up my editing some and I'll be happy to post it. It was relatively easy once I stumbled on a hint on the Wiki. The Listen filters are apparently now cleared on every state change, so all that was necessary was to duplicate the listen filters in each state. Works great now...

Cutter


From: Zarah Dawn
I got the same free sliding door ... it doesn't work right and I'd love to be able to use it. Cutter & I have played with it and it seems the door( script?) isn't "hearing", but the control is sending. anyhow... if anyone knows about this we'd be very appreciative.

Z (one half of C & Z )
_____________________
The early bird may get the worm, but the second mouse gets the cheese.
Patrick Playfair
Registered User
Join date: 19 Jul 2004
Posts: 328
Sliding door
11-22-2004 08:05
From: Cutter Rubio
I've managed to fix the steel sliding door script. I need to clean up my editing some and I'll be happy to post it. It was relatively easy once I stumbled on a hint on the Wiki. The Listen filters are apparently now cleared on every state change, so all that was necessary was to duplicate the listen filters in each state. Works great now...

Cutter


If you have a fix for the free sliding door, I would love to see it.

Patrick Playfair
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
11-22-2004 11:48
From: Rysidian Rubio
Nexus are you serious???
You make it sound like this script is going to serously lag the server, it's not. There are no listens, one timer which turns off after 20 seconds, and a touch event, nothing heavy on the server.
The stepping doesn't do much to the server at all, only takes a few seconds and looks much better than the door "popping" from one position to another. If you believe the contrary then please feel free to prove me wrong with some testing and statistics, or I can do so if you REEEEEALLY think it's necessary.

Or you could just post a script yourself.


Post back form the dead! Actually it's true! I REALLY hate seeing step scripts (i'm tlaking like 20+ steps. And yes it does something to the server! Mind you not one script in a totally empty server. I find that steps simply misused the limited ressources of a certain server! Ie if you have a club and it's loaded with people, why the hell would you put all your doors as steps?! The sim is straining enough as it is to hold all these people why put 50 more doors around your club with steps?! Don't get me wrong... it does look "better" and it's totally ok for like your house or something! But i've seen retarded stuff, such as a certain club that I will not mention, complaning on how they had soo much server lag!!! I went aroudnt he place and found things such as 50+ step doors, particles that went off every 0.01 secs instead of like 0.1 (would have the close to the same effect + easing server strain by 10 times!!!)

I guess my point is that it all adds up! And why add stuff that will only make a minor difference compaired to the visual impact it gives on the world?

P.S. sorry for the delayed response!
_____________________
Artillo Fredericks
Friendly Orange Demon
Join date: 1 Jun 2004
Posts: 1,327
11-22-2004 12:55
thanx I been looking for these too :) And a password lock one too :P

Arti
_____________________
"I, for one, am thouroughly entertained by the mass freakout." - Nephilaine Protagonist

--== www.artillodesign.com ==--
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
11-22-2004 16:10
Tonight when i get home I'll post a sliding door script that contains the following which can be turned on/off depending on what u want.

Sliding in steps/without steps
Password lock
User access list
Listens for multiple doors to synchronize
and the same thing for a rotating door.

If anyone wants anything else in a door reply and I'll try to add it in.
Cutter Rubio
Hopeless Romantic
Join date: 7 Feb 2004
Posts: 264
Scripts posted to Library
11-22-2004 17:38
I've posted the fixed scripts for the Steel Door Kit in the library. I don't see the post right now, but perhaps that forum is moderated. I hope it appears shortly...

Cutter
_____________________
The early bird may get the worm, but the second mouse gets the cheese.
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
11-22-2004 18:26
Go the Rubios!!
lol
nonnux white
NN Dez!gns
Join date: 8 Oct 2004
Posts: 90
02-10-2005 08:57
i would like to know if there is a way to build a sliding door, that slides on the local axys of the door.

imagine u got a wall, that is 45º, or worst, imagine u have to change the door position and angle... it will not slide correctly
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
02-10-2005 09:40
I don't see why that would be a problem. Most adaptable sliding door scripts include a call to llGetRot().

Edit: Oh, and please write like a grown up would. Linden Labs disable accounts if they find that the user is not of legal age.
nonnux white
NN Dez!gns
Join date: 8 Oct 2004
Posts: 90
02-10-2005 11:29
From: Rhombur Volos
I don't see why that would be a problem. Most adaptable sliding door scripts include a call to llGetRot().

Edit: Oh, and please write like a grown up would. Linden Labs disable accounts if they find that the user is not of legal age.


llGetRot() is my problem. i can't get it working correctly. but it is good to me to find that iºm in the good way.

about legal age:
are u trying to offend me? is my question so stupid?
i'm don't live in a native english country, so it is very hard to me to exprime myself. if u think i'm a child, good for u. i wish i could talk clear.

and btw, i'm 29...
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
02-10-2005 11:50
Ah well.
Anyways, i don't know how your script looks at the moment, but if you script it to work while it's aligned with the global axis, using llGetRot() will solve the problem, as far as i recall.

CODE


integer open;

default
{
touch_start(integer touchees)
{
open = !open;
if(open) llSetPos(llGetPos() + (<0,2,0> * llGetRot());
else llSetPos(llGetPos() + (<0,-2,0> * llGetRot());
}
}



Not sure if this will work tho.. Not able to test it out at the moment.

Edit:

You could also just use an almost similar function in a child object:
CODE

integer open;

default
{
touch_start(integer touchees)
{
open = !open;
if(open) llSetPos(<0,2,0>);
else llSetPos(<0,0,0>);
}
}
nonnux white
NN Dez!gns
Join date: 8 Oct 2004
Posts: 90
02-10-2005 13:06
oh fantastic!

Rhombur Volos u can't imagine how many lines of code i got to do this, and is not working!!!
your script is so simple and clear, that i really feal shame on me

gonna past your script again here, since is missing 2 parentisis:

integer open;

default
{
touch_start(integer touchees)
{
open = !open;
if(open) llSetPos(llGetPos() + (<0,2,0> * llGetRot() ) );
else llSetPos(llGetPos() + (<0,-2,0> * llGetRot() ) );
}
}

thanks again!
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
02-10-2005 13:15
Whoops, didn't notice that. Thanks :)

Oh, and the variable declaration should have been different:

CODE

integer open = 0;

default
{
touch_start(integer touchees)
{
open = !open;
if(open) llSetPos(llGetPos() + (<0,2,0> * llGetRot()));
else llSetPos(llGetPos() + (<0,-2,0> * llGetRot()));
}
}



Since i'm not really sure whether integers are set to 0 when a value isn't specified in declaration, or some other value.
Nexeus Fatale
DJ Nexeus
Join date: 28 Aug 2004
Posts: 128
03-18-2005 08:28
Saw this door script, I like it a ton more than the step wise. I made some revisions to it (for anyone interested), more of a check to see if the door is open or closed, and a way to deal with the vector of sliding the door open and close a lot easier.

The idea is that someone who wants to add say, a permission script (as I want to do) to the door could without any problem.

CODE
//Door Script - Nexeus Fatale
//Idea originally made by Rhombur Volos


//A variable that is set to 0, indicates if the door is open (1) or closed (0)
integer dHandle = 0;

//This is the control for your door to slide open or close
vector dSlide = <0,2.5,0>;

//Opens the door, set the handle to 1
doorOpen()
{
llSetPos(llGetPos() + ((dSlide *-1) *llGetRot()));
dHandle = 1;
}

//Closes the door, set the handle to 0
doorClose()
{
llSetPos (llGetPos() + (dSlide * llGetRot()));
dHandle = 0;
}

default
{

touch_start(integer touches)
{
if (dHandle == 0)
{
doorOpen();
}
else if (dHandle == 1)
{
doorClose();
}

}
}
_____________________
Website: www.nexeusfatale.com
[nf_d]: nfd.nexeusfatale.com
1 2