Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with Door Script

Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
02-10-2008 18:38
Hello everyone, well I need the help of all you great script masters out there. I am building a bookshelf with doors on the bottom. I found a door script at the free script shop inworld, however i'm very LSL illiterate and need to know is how can have the script open the door like a door and not on it z axis. This is the script I am using … any help would be greatly appreciated.

// Swinging door LSL script #1
// Handles the touch event.
// Handles the collision event.
// Handles closing the door automatically via a timer event.
// Triggers sounds when the door opens or closes.
// Parameters you might want to change

float delay = 3.0; // time to wait before automatically closing door
// set to 0.0 to not automatically close
float direction = 1.0; // set to 1.0 or -1.0 to control direction the door swings
float volume = 0.0; // 0.0 is off, 1.0 is loudest

// Variables you will most likely leave the same

key open_sound = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
key close_sound = "e7ff1054-003d-d134-66be-207573f2b535";

// Processing for the script when it first starts up

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

state_entry() {
state open; // Move to the open 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
llSetRot(llEuler2Rot(<0, 0, direction * PI_BY_TWO>;) * llGetRot());

}

// 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
llSetRot(llEuler2Rot(<0, 0, -direction * PI_BY_TWO>;) * llGetRot());

llSetTimerEvent(delay); // Set the timer to automatically close it
}

// What do do when pulling the door from Inventory if it was saved while open

on_rez(integer start_param) {
state closed;
}

// 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
}
}
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
02-10-2008 22:34
Easiest way is to modify the door prims. Do a path cut with beginning .125 and end .625, this will cut away half the door so the remaining half will appear to rotate at the edge.
_____________________
Designer of sensual, tasteful couple's animations - for residents who take their leisure time seriously. ;)

http://slurl.com/secondlife/Brownlee/203/110/109/

Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
02-11-2008 05:47
From: Anti Antonelli
Easiest way is to modify the door prims. Do a path cut with beginning .125 and end .625, this will cut away half the door so the remaining half will appear to rotate at the edge.



hey that sounds easy enough, i'll give it a try tonight when i go home. Thanks for the reply!!!!
Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
02-11-2008 17:05
From: Dick Spad
hey that sounds easy enough, i'll give it a try tonight when i go home. Thanks for the reply!!!!


Well this didnt do the trick either, i made a prim. Did the path cut with beginning .125 and end .625 .... applied the script and the door still opens/rotates on it's Z-Axis and not the a hined door.
Gonzo Joubert
Registered User
Join date: 22 Dec 2007
Posts: 2
02-12-2008 04:01
I believe that that script is written to work on Z axis by the following statement:

llSetRot(llEuler2Rot(<0, 0, -direction * PI_BY_TWO>;) * llGetRot());

you'll need to change that line in the 2 places it appears to rotate it on a different axis
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-12-2008 06:23
or just rotate it on it's side in edit, since it's using local rotation.

the door shape for a properly hinged style door (rotating from the edge, not a side) requires 2 cuts, usually dimple and then cut, and I believe because of that uses a different axis, either x or y (because dimple reduces the z axis, and the cut will reduce either x or y).

excerpted from my simple door script found at

to create realistic hinge action:
-in object edit:
create sphere,
dimple end = .5
change to box
path-cut start = .125, end = .625
rotation(degrees) x = 90, y = 0, z = 0

-in the script, change
vgRotDoorSwing = llEuler2Rot( <.0, .0, (float)vgIntDoorSwing * DEG_TO_RAD> );
to
vgRotDoorSwing = llEuler2Rot( <.0, (float)vgIntDoorSwing * DEG_TO_RAD, .0> );

(or in your case)
-change
llSetRot(llEuler2Rot(<0, 0, -direction * PI_BY_TWO>;) * llGetRot());
to
llSetRot(llEuler2Rot(<0, -direction * PI_BY_TWO, 0>;) * llGetRot());

as it now uses the y axis to rotate on and edge (the z and x axis having been halved to place the y axis on the edge)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -