Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sliding door

Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
04-30-2008 11:44
Hi everybody,

I am making a sliding door and the script works if i place the door on a z ax of
0, 90, 180, 270 degrees. Can someone tell me how or which function i have to use
to get it working at all angles?

this is the part of the script i have trouble with.

integer iNumber =0;
integer Steps=25; //the door opens in 25 steps
integer Direction=-1; //Moving direction of the door
integer Angle=0;

init()
{
Home=llGetPos(); //Home position (closed door)
Size=llGetScale(); //Get the size of the door
}


OpenDoor()
{
if (llGetPos() == Home) //Door ia already open
{
while(iNumber<Steps)
{
if(Angle==0) //0 and 180 degrees
{
llSetPos(llGetPos() + <0.0, Size.y/Steps, 0.0> * Direction);
++iNumber;
}
else //90 and 270 degrees
{
llSetPos(llGetPos() + <Size.y/Steps, 0.0, 0.0> * Direction);
++iNumber;
}
}

llSleep(5);
llSetPos(Home);
iNumber=0;
}
}
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
05-01-2008 09:33
Can't get inworld at the moment and don't have that script on my local drive. Will get it and post here later on and send you a copy in world as well
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
05-01-2008 10:29
Don't have the rest of the script so I can't test this:

CODE
init()
{
Home = llGetPos(); //Home position (closed door)
Size = llGetScale(); //Get the size of the door
}

OpenDoor()
{
if (llGetPos() == Home) //Door ia already open
{
while (iNumber < Steps) {
if(ANGLE >= 90 && ANGLE <= 270){
llSetPos(llGetPos() + <Size.y / Steps, 0.0, 0.0 > *Direction);
++iNumber;
}
else{
llSetPos(llGetPos() + <0.0, Size.y / Steps, 0.0 > *Direction);
++iNumber;
}
}
llSleep(5);
llSetPos(Home);
iNumber = 0;
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
05-01-2008 10:41
CODE
init()
{
Home = llGetPos(); //Home position (closed door)
Size = llGetScale(); //Get the size of the door
}

OpenDoor()
{
if (llGetPos() == Home) //Door ia already open
{
while (iNumber < Steps) {
if((ANGLE >= 45 && ANGLE <= 135) || (ANGLE >= 225 && ANGLE <= 315))
llSetPos(llGetPos() + <Size.y / Steps, 0.0, 0.0 > *Direction);
++iNumber;
}
else{
llSetPos(llGetPos() + <0.0, Size.y / Steps, 0.0 > *Direction);
++iNumber;
}
}
llSleep(5);
llSetPos(Home);
iNumber = 0;
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
Different approach
05-01-2008 11:08
If your door always opens in its local X direction, you can rotate the door to whatever angle you like and it will still work.

However, in that case you also need to convert the local direction into a global directions, that is, a direction relative the the sim coordinates. Y9ou do that by post-multiplying by your local rotation.
_____________________
So many monkeys, so little Shakespeare.
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
05-02-2008 02:26
Thanks guys,

Jesse if i understand your code correct it will work but the door will move sideways or at least in an angle.
(I can't try it, can't get in world now.)

I make this script for a friend who want to use it for her house but don't know yet in which angle the door/house will be placed.

I think i have to add the angle somehow to the llSetPos but don't know how:(

The door is a single prim of x=0.25, y=4 and z=4
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
05-02-2008 04:24
Have absolutely no idea what mine does because I haven't seen all of your script and don't know what the values are. I do know that if your's that you posted does work then mine will work the same but for the total range of ANGLE as your requested.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
05-04-2008 11:21
hi everybody,

Thanks for all your sugestion and i will look in it.
I am now on holiday but if i am back i will try to solve it and if i don´t succeed
it will post all my code so you have a better ideaa what i am trying to do.

I appocieed all your help very much:)

All big kisses for your help.

Kaylan
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
05-04-2008 11:58
Not sure where I got this one...I didn't write it.
Make the door a child prim. I have two linked to a whole home and they still work fine. You can spin the home to any position and the door will still open right.

CODE


float delay = 10.0; // time to wait before automatically closing door
vector delta = <1.4, 0.0, 0.0>; // amount to move door when we open it

// Variables you will most likely leave the same

vector closed_position; // original position of the door when closed


// Processing for the script when it first starts up

default {
// What we do when we first enter this state

state_entry() {
closed_position = llGetPos(); // Save position when door is closed
state closed; // Move to the closed state
}
}

// Processing for the script when it is in the closed state

state closed {
// What we do when we first enter this state

state_entry() {
//llTriggerSound(close_sound, volume); // Trigger the sound of the door closing
llSetPos(llGetLocalPos() + <1.4, 0, 0>*llGetLocalRot()); // Move door to closed position
}

// What we do when the door is clicked (”touched”) with the mouse

touch_start(integer total_number) {
state open; // Move to the open state
}

// What to do when something hits the door

collision_start(integer total_number)
{
state open; // Move to the open state
}

// What to do when the timer goes off

timer()
{
llSetTimerEvent(0.0); // Set the timer to 0.0 to turn it off
}
}

// Processing for the script when it is in the open state

state open {
// What we do when we first enter this state

state_entry() {
//llTriggerSound(open_sound, volume);// Trigger the sound of the door opening
llSetPos(llGetLocalPos() + <-1.4, 0, 0>*llGetLocalRot());// Move door to open position
llSetTimerEvent(delay); // Set the timer to automatically close it
}

// What we do when the door is clicked (”touched”) with the mouse

touch_start(integer total_number) {
state closed; // Move to the closed state
}

// What to do when something hits the door

collision_start(integer total_number)
{
// Do nothing, the door is already open
}

// What to do when the timer goes off

timer()
{
llSetTimerEvent(0.0); // Set the timer to 0.0 to turn it off
state closed; // Move to the closed state
}
}
Johnathon Seetan
Registered User
Join date: 18 Sep 2008
Posts: 11
Max's code.....
12-17-2008 20:54
Hi Max... I tried this code you gave on a sample prim.... before the actual door I want to use......
it didn't work..

BUT... I only want one door..... this may be the problem.

I am looking for a sliding door script.... BUT I saw this REALLY cool door ... well WINDOW that when you touched it it DROPPED to below the floor, just enough to see of course, then when you wanted it back up again you clicked it and hey presto.... it was closed....

Actually, it was a window on an angle, you clicked and it dropped to the floor to open..... then close upwards.

I have a gallery and I would LOVE to use this script on the door to go UP then once in close DOWN..... any ideas please... should be a sliding door script naturally... don't need sound or super speed, or even to zap an intruder with xrays.... just a little bit of code that says.... UP and DOWN.... smile!!!!