Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

hi, can anyone help me with the door script?

WindFairie Rosencrans
Registered User
Join date: 4 Feb 2005
Posts: 72
04-11-2005 05:15
I made a flung open door to the sauna chamber and I want to link the door prim to the sauna so I can keep it as One object.
I been trying to edit the script myself but ended up having the ehadache only, heh.
Can anyone help me with this?

TIA!
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
04-11-2005 05:46
Try this script...

CODE

vector gOpenPos;
vector gClosePos;
rotation gOpenRot;
rotation gCloseRot;

integer gIsOpen = FALSE;

default
{
state_entry()
{
llListen(0, "", llGetOwner(), "open");
llListen(0, "", llGetOwner(), "close");
}

listen(integer chan, string who, key id, string msg)
{
if ( msg == "open" )
{
gOpenPos = llGetLocalPos();
gOpenRot = llGetLocalRot();
gIsOpen = TRUE;
}
else if ( msg == "close" )
{
gClosePos = llGetLocalPos();
gCloseRot = llGetLocalRot();
gIsOpen = FALSE;
}
}

touch(integer num_detected)
{
if ( gIsOpen )
{
llSetLocalPos(gClosePos);
llSetLocalRot(gCloseRot);
gIsOpen = FALSE;
}
else
{
llSetLocalPos(gOpenPos);
llSetLocalRot(gOpenRot);
gIsOpen = TRUE;
}
}
}


Place this script in the prim you want as your door, position the prim to its closed position, link it to the rest of your structure, and say "close". Edit the individual prim again (keeping it linked to the rest of your structure) position it in its opened position, and say "open".

Now, whenever the door is touched, it will toggle between opened and closed.

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
WindFairie Rosencrans
Registered User
Join date: 4 Feb 2005
Posts: 72
thnx much, will try it:)
04-11-2005 07:14
:)
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
04-11-2005 08:18
I'm not sure that llGetLocalPos() exists... would be nice if it did.

Essentially you have to resort to llBreakLink()/llCreateLink()... It may be simpler just to use a separate door...

/esc
_____________________
http://slurl.com/secondlife/Together
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
04-11-2005 09:16
From: Escort DeFarge
I'm not sure that llGetLocalPos() exists... would be nice if it did.

Essentially you have to resort to llBreakLink()/llCreateLink()... It may be simpler just to use a separate door...

/esc

llGetLocalPos
llGetLocalRot
_____________________
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
04-11-2005 09:23
Just be sure to do the "open" and "close" voice commands before you touch the prim, otherwise your door will go flying off to the <0,0,0> coordinates of your sim.

- Ace

P.S. (added via Edit) My bad... since you're setting the local position, it won't send your door to the corner of the sim, it will send it to the center of your root prim.
_____________________
"Free your mind, and your ass will follow" - George Clinton
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
04-11-2005 16:39

Well there's a thing. Typosis struck me, I meant to say llSetLocalPos(). In any case, the script does not compile and therefore does not work.

/esc
_____________________
http://slurl.com/secondlife/Together