Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

movin doors/closset draws

melissa Tracer
Registered User
Join date: 2 Dec 2006
Posts: 14
10-20-2008 10:49
Hi

I was playin arround with some movin doors.
Didn't wanna use doors but a closset with 2 draws.

Some strange thing happend ,both draws work fine, except when
i close the last one ,the upper wil fall in the lower draw????

Script im using is.(from this forum.from Rysidian Rubio,ty so much)

Slightly modified by me ,kept the sound away.

script:

//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 = 0.5;
//this is the total distance you want the door to open in metres.

integer direction = -2;
//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
//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
//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;

}
}



pic01 both closed
02- bottom open
03- both open
04- bottom closed ,upper close good ,but drops down???
05-afterwards

Pics will follow as soon as possible ,forum will not allow my pics to upload

grts Melissa
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-20-2008 14:40
This is non-physical movement and the movement is along the x axis IF "direction" is defined as "-2" . If your upper drawer is moving up/down instead then check the orientation of it and try defining "direction" as "1" or "-1" instead.
_____________________
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
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-20-2008 14:46
hmm, it looks like she's saying it's opening correctly, but when it closes it move to the same position as the closed bottom drawer, moving on 2 axises at once.
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-20-2008 15:24
Try this one:

CODE

float distance = 0.5; //total distance to move the drawer
string axis = "x"; //declare which axis here; "x", "y" or "z"
integer steps = 2; //how many steps to close
integer reverse = FALSE; //TRUE or FALSE, change to reverse direction drawer moves
integer j;
vector pos = <0,0,0>;

default {
state_entry() {
distance = distance / steps;
if (axis == "x") pos.x = distance;
else if (axis == "y") pos.y = distance;
else if (axis == "z") pos.z = distance;
}
touch_start(integer num_detected) {
if(reverse){
for (j = 0; j < steps; j++) llSetPos(llGetPos() - pos);
}
else{
for (j = 0; j < steps; j++) llSetPos(llGetPos() + pos);
}
reverse = !reverse;
}
}
_____________________
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
10-20-2008 15:52
Almost forgot, if you chest of drawers are all linked, then make sure that the drawers are selected first when you link it together and use this script in the drawers instead:

CODE

float distance = 0.5; //total distance to move the drawer
string axis = "x"; //declare which axis here
integer steps = 2; //how many steps to close
integer reverse = FALSE; //TRUE or FALSE, change to reverse direction drawer moves
integer j;
vector pos = <0, 0, 0 >;

default {
state_entry() {
distance = distance / steps;
if (axis == "x")
pos.x = distance;
else if (axis == "y")
pos.y = distance;
else if (axis == "z")
pos.z = distance;
}
touch_start(integer num_detected) {
if (reverse) {
for (j = 0; j < steps; j++)
llSetPos(llGetLocalPos() - pos);
}
else {
for (j = 0; j < steps; j++)
llSetPos(llGetLocalPos() + pos);
}
reverse = !reverse;
}
}

I tested this in Aditi and it works no matter what the orientation of the drawer is.
_____________________
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
melissa Tracer
Registered User
Join date: 2 Dec 2006
Posts: 14
10-21-2008 12:01
Hi

@Jess Barnett/Ruthven Willenov :
The last move was all perfect but when it stops movin.
THAN, it fall in to the other prim.

@Jesse Barnett: ,no link parts ,just single prims (playin around).

This evening playin around with, youre script(Jess Barnett).
Worked perfect!!

Than the original script(perfect) ????


Mmmm ,startin to blaim myself now.

Secuance of buildin the closset.
Made a copy of the drawer.THAT WAS WRONG!!!!

Then i took a look at my closset again.
I clict my prim(upper drawer) to EDIT.
Then i chuse from the menu/Tools/reset scripts in Selection.

IT WORKED!!!!
Bloody HELL, so simple!

So sorry you guys ,bangin my head to the keyboard.



Whell i really apprisiade youre answers,thrully

Much abley Melissa
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-21-2008 12:08
ahha, you must have shift-dragged to copy it. when you do that, the new one is left in place and the old one is what is moved. so in the new one the script recompiles obviously, but in the old one, it still remembers the original position. so yeah, reseting is what it needed
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369