Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

1 prim double sliding glass door

Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
11-23-2006 05:47
Hello there,

This is 1 prim double sliding glass door. :D
Just put this script into a prim.
You can open it by touching or bumping.
For security, it is locked when you keep touching for a while. Just the owner can open it. It toggles.
After being rezzed, you can modify scale, color, and alpha. I don't recommend you post a texture on it because it has complicated faces.

OK, here we go.
CODE
//1 prim double sliding glass door was made by Seagel Neville as public domain, Nov 2006
integer pitch = 5;
float TimeInterval = 3.0;
integer TouchFlag;
integer Holding;
integer SecureFlag;

Open()
{
TouchFlag = TRUE;
llTriggerSound("de7ac1a3-f31b-e1a4-5a21-5b9907921bf1", 1.0);
integer i;
for(i = 0; i < pitch + 1; i++)
{
llSetPrimitiveParams([PRIM_TYPE, 0, 0, <0.000000, 1.000000, 0.000000>,
0.949000, <0.000000, 0.000000, 0.000000>, <(float)i/pitch, 1.000000, 0.000000>,
<0.000000, 0.000000, 0.000000>]);
}
llSetTimerEvent(TimeInterval);
}

Close()
{
llSetTimerEvent(0);
TouchFlag = FALSE;
llTriggerSound("44f32d82-8604-1f29-37c9-a35baec646ee", 1.0);
integer i;
for(i = pitch - 1; i >= 0 ; i--)
{
llSetPrimitiveParams([PRIM_TYPE, 0, 0, <0.000000, 1.000000, 0.000000>,
0.949000, <0.000000, 0.000000, 0.000000>, <(float)i/pitch, 1.000000, 0.000000>,
<0.000000, 0.000000, 0.000000>]);
}
}

TouchOpen()
{
if(TouchFlag == FALSE)
{
Open();
}
else
{
Close();
}
}

CollideOpen()
{
if(TouchFlag == FALSE)
{
Open();
}
else
{
llSetTimerEvent(TimeInterval);
}
}

Init()
{
llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_GLASS, PRIM_SIZE, <2.0, 2.7, 0.01>,
PRIM_TYPE, 0, 0, <0.0, 1.0, 0.0>, 0.949, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>,
PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_ROTATION, <0.7, 0, 0, 0.7>,
PRIM_COLOR, ALL_SIDES, <0.0, 0.0, 0.5>, 0.5, PRIM_POSITION, llGetPos() + (<0, 0, 1.1> * llGetRot()),
PRIM_TEXTURE, ALL_SIDES, "5748decc-f629-461c-9a36-a35a221fe21f",
<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0]);
}

default
{
state_entry()
{
Init();
}
changed(integer change)
{
if(change & CHANGED_OWNER)
{
llResetScript();
}
}
touch(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
Holding++;
if(Holding == 50)
{
if(SecureFlag == FALSE)
{
llOwnerSay("Secured mode has been ON");
SecureFlag = TRUE;
}
else
{
llOwnerSay("Secured mode has been OFF");
SecureFlag = FALSE;
}
}
}
}
touch_end(integer total_number)
{
Holding = 0;
if(SecureFlag == FALSE)
{
TouchOpen();
}
else
{
if(llDetectedKey(0) == llGetOwner())
{
TouchOpen();
}
else
{
llWhisper(0, "Sorry, this door is beeing locked.");
}
}
}
collision_start(integer num_detected)
{
if(SecureFlag == FALSE)
{
CollideOpen();
}
else
{
if(llDetectedKey(0) == llGetOwner())
{
CollideOpen();
}
else
{
llWhisper(0, "Sorry, this door is beeing locked.");
llSleep(5.0);
}
}
}
timer()
{
Close();
}
}
_____________________
:) Seagel Neville :)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
11-23-2006 09:56
/54/53/150641/1.html
_____________________
i've got nothing. ;)
LemonYellow Oxide
Registered User
Join date: 1 Oct 2006
Posts: 33
11-29-2006 01:24
Nice creation - many thanks Seagal
Alley McNally
Registered User
Join date: 17 Jun 2006
Posts: 19
You underestimate the value of this script . . .
12-22-2006 18:22
You underestimate the vale of this script. Yes texturing of the object would be tricky but not impossible. It would take a little playing around and maybe a touch of experience doing this kind of complicated texturing. Still, it could be a useful tool in building to make low prim doors.
Kevin Ballinger
Registered User
Join date: 4 Feb 2007
Posts: 1
A Small Fix...
03-08-2007 15:14
When the script was reset, the object returned to a pre-defined position,scale and rotation. I changed a couple of stuff to fix it that resetting the script will keep the object as last edited by the user.

Simple reason being that if Linden Labs decided to Reset All Scripts because of a server crash it would probably break the door, and the user would have to re-edit it's position etc.

I also added a few more comments to help you understand the code a bit more.

I am still a beginner at scripting SL objects, so any additions from my end to the script will take quite a while :)

I have to thank you, Seagel Neville for such a script! :)

CODE

//Original 1 prim double sliding glass door was made by Seagel Neville as public domain, Nov 2006
//Modified by Kevin Carbonaro (SL: Kevin Ballinger) 8 March 2007
//
//Fixes:
//-FIX - Now resetting the script will not re-position, scale, and rotate the object to some pre-defined numbers.
//
//To Do:
//-Improve Smoothness of Door Opening and Closing Animation.
//-Use a Dialog to Code Lock the door.

integer pitch = 5; //Steps for the door to take to open and close. More Steps will make the door open and close more slowly.
float TimeInterval = 6.0; //Seconds to keep the door open.
integer TouchFlag;
integer Holding;
integer SecureFlag;

Open()
{
TouchFlag = TRUE;
llTriggerSound("de7ac1a3-f31b-e1a4-5a21-5b9907921bf1", 1.0);
integer i;
for(i = 0; i < pitch + .5; i++)
{
llSetPrimitiveParams([PRIM_TYPE, 0, 0, <0.000000, 1.000000, 0.000000>,
0.949000, <0.000000, 0.000000, 0.000000>, <(float)i/pitch, 1.000000, 0.000000>,
<0.000000, 0.000000, 0.000000>]);
}
llSetTimerEvent(TimeInterval);
}

Close()
{
llSetTimerEvent(0);
TouchFlag = FALSE;
llTriggerSound("44f32d82-8604-1f29-37c9-a35baec646ee", 1.0);
integer i;
for(i = pitch - 1; i >= 0 ; i--)
{
llSetPrimitiveParams([PRIM_TYPE, 0, 0, <0.000000, 1.000000, 0.000000>,
0.949000, <0.000000, 0.000000, 0.000000>, <(float)i/pitch, 1.000000, 0.000000>,
<0.000000, 0.000000, 0.000000>]);
}
}

TouchOpen()
{
if(TouchFlag == FALSE)
{
Open();
}
else
{
Close();
}
}

CollideOpen()
{
if(TouchFlag == FALSE)
{
Open();
}
else
{
llSetTimerEvent(TimeInterval);
}
}

Init()
{
llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_GLASS, PRIM_SIZE, llGetScale(),
PRIM_TYPE, 0, 0, <0.0, 1.0, 0.0>, 0.949, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>,
PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_ROTATION, llGetRot(),
PRIM_COLOR, ALL_SIDES, <0.0, 0.0, 0.5>, 0.5, PRIM_POSITION, llGetPos() + (<0, 0, 0> * llGetRot()),
PRIM_TEXTURE, ALL_SIDES, "5748decc-f629-461c-9a36-a35a221fe21f",
<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0]);
}

default
{
state_entry()
{
Init();
}
changed(integer change)
{
if(change & CHANGED_OWNER)
{
llResetScript();
}
}
touch(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
Holding++;
if(Holding == 50)
{
if(SecureFlag == FALSE)
{
llOwnerSay("Door Locked");
SecureFlag = TRUE;
}
else
{
llOwnerSay("Door Unlocked");
SecureFlag = FALSE;
}
}
}
}
touch_end(integer total_number)
{
Holding = 0;
if(SecureFlag == FALSE)
{
TouchOpen();
}
else
{
if(llDetectedKey(0) == llGetOwner())
{
TouchOpen();
}
else
{
llWhisper(0, "Sorry, this door is locked.");
}
}
}
collision_start(integer num_detected)
{
if(SecureFlag == FALSE)
{
CollideOpen();
}
else
{
if(llDetectedKey(0) == llGetOwner())
{
CollideOpen();
}
else
{
llWhisper(0, "Sorry, this door is locked.");
llSleep(5.0);
}
}
}
timer()
{
Close();
}
}
Gina Jacks
Registered User
Join date: 20 Dec 2006
Posts: 181
04-16-2007 17:00
Aw, the first version works fine, I am very grateful, what a nice script.

The second version... Well, it rezzes a triangle, and open as a rectangle lol,
is it me or did I do anything wrong?
Evelynn McGinnis
Registered User
Join date: 13 Dec 2007
Posts: 0
Great! Thanks a bunch!
02-21-2008 00:18
I really, really, really, reallllllllllly appreciate this. Long script, but well worth the work. I'm just learning, I've been through college of scripting beginner course and have not tried creating my own script. I did this one (had many typos but eventually worked it out-and used your fixxed version too) and it took a while, but it helped me understand the scripting language better as I had to keep using it so much for one script. I still don't know the long sets of numbers and such, but I'll get it later, I guess. All that matters to me now is-
Success! haven't built with the doors yet, but I used them on an existing house to try them out. One thing, is there a way to manually lock and unlock the door? I'd appreciate if you would tell me. I though it was all ready in the script...but I don't see it if it is!

Not complaining...its great! thanks so much for sharing!

Oh...and if you have a script for a dresser with drawers that open and close and hold stuff.....I'd love to have it! thanks a bunch again!

Keep up the good scripting!
canis Oh
Registered User
Join date: 30 Mar 2007
Posts: 33
opening prism (not door?)
05-15-2008 05:06
Ummm ... am I the only one who sees a triangular prism opening and closing (at the top on command) with the new improved version?