Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

discussion: 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
Original Thread
11-23-2006 09:56
/15/2d/150602/1.html
_____________________
i've got nothing. ;)
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
11-24-2006 15:40
THis is crazy cool.

Question though. I notice that the action is kinda "steppy"... is there any hope of making it more smooth?
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
Good one
11-24-2006 16:01
But is it open sourced and free to use and give away?
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Oliva Delvecchio
*
Join date: 23 Jul 2004
Posts: 45
11-27-2006 23:08
From: Winter Ventura


Question though. I notice that the action is kinda "steppy"... is there any hope of making it more smooth?


Att: Winter
I am not a pro but i know one way...
At the very top / first line in the script ( integer pitch = 5; )
If the number was 1 the door opens in one instance
If the number was 10+ the door opens to your liking :)

btw...Second line ( float TimeInterval = 3.0; ) Is how many seconds the door stays open.

Change that and Save, the door will reset itselt to an original state :rolleyes:


Seagel, Thanks a bunch for your script!
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
11-28-2006 08:56
From: Winter Ventura
Question though. I notice that the action is kinda "steppy"... is there any hope of making it more smooth?
Ouch, you hit the week point. :o The pitch's value is involved with speed. Please try changing it. I wish it could be smooth.
From: Kornscope Komachi
But is it open sourced and free to use and give away?
Aha, Yes. I forgot putting down comments. I fix it.

And thank you, Oliva, you're right.
_____________________
:) Seagel Neville :)
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
Should have waited :)
12-01-2006 12:18
Seagel -- this is great! I made the exact same thing, using another technique, about a month ago.

It took me a while to figure out how to do this -- if I had known you were doing this, I would have spent more time on my other scripts ;)

Your technique for opening and closing the door is very interesting - had not thought about using steps. My technique steps the prim's size and checks if it has reached a limit (open or closed). I did this thinking that it would make the movement more consistent for different size doors; however, it does not make much of a difference.

Thank you for posting this!

-2fast
Caedmon Quinn
Registered User
Join date: 13 Jun 2005
Posts: 7
12-21-2006 08:53
This was almost Exactly what I was looking for! Very COOL. I tweaked the X Top Shear and dropped a transparent texture on two faces and Poof. Standard sliding glass door. Now I just need to figure out how to add the transparent faces to your script and add a sliding glass door sound and eh who am I kidding that will never happen LMAO. Thanks again :-)

/me never finishes anything lol
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
12-21-2006 15:08
Heh?
llTriggerSound("de7ac1a3-f31b-e1a4-5a21-5b9907921bf1", 1.0);
and
llTriggerSound("44f32d82-8604-1f29-37c9-a35baec646ee", 1.0)
are sound lines. If you have some sound file(full permissions are required), you can right click on it and select "Copy Asset UUID". Then, paste it into "".

To add transparency, find the line, "PRIM_COLOR, ALL_SIDES, <0.0, 0.0, 0.5>, 0.5" in init() section. The last float, "0.5" is what you want. But I recommend you change it by prim edit texture manually. When you change it in the script, the scale also turns back to the default.

If you don't want to change to the defaut when you change something in the script, comment out init() function under the state_entry event.
From: someone
state_entry()
{
// Init();
}
_____________________
:) Seagel Neville :)
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-21-2006 18:42
Nice script. :)


I love these kind of scripts, fun and different. Thanks for posting it.
_____________________
Vitruvius Digital
Registered User
Join date: 31 Oct 2006
Posts: 2
Locking the door
01-11-2007 13:44
Fantastic script! I have been looking for this for a couple of weeks inworld before I checked the forum. ...I should have known better. :-)

Just one question. I don't understand how to make the doors lock and/or unlock. Now bear with me, because I am not a scripter, but I read though it and thought I had to chat/say the statement which you have in the script ("Secured mode has been ON";), but that didn't work.

What am I doing wrong?
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
01-11-2007 17:01
From: Vitruvius Digital
Just one question. I don't understand how to make the doors lock and/or unlock. Now bear with me, because I am not a scripter, but I read though it and thought I had to chat/say the statement which you have in the script ("Secured mode has been ON";), but that didn't work.
Hello. What did I say?
CODE
For security, it is locked when you keep touching for a while. Just the owner can open it. It toggles.
I expected that you clicked on the door and didn't release the mouse button soon. When you place the cursor on the door and press the left mouse button, the door script starts counting. And when the counter gets to 50, the lock goes ON/OFF. Of course you can't see the numbers of counter themselves. It may take around 5 to 30 seconds depending upon the server status.
_____________________
:) Seagel Neville :)
Vitruvius Digital
Registered User
Join date: 31 Oct 2006
Posts: 2
locking doors success
01-11-2007 21:42
Thanks! This happened to be the first object that used a touch timer to do something, so that was new for me. I appreciate the help!
Gareee Taov
Registered User
Join date: 8 Jan 2007
Posts: 117
02-05-2007 11:33
Hmmm I get an error message when trying to save the script in the prim.. is there some editing that needs to be done for this to work properly?

the error message is:

errror, (137,14) : Error : syntax error

wonder if one of the updates broke this?
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
02-05-2007 14:34
I counted those lines and found 137 be llSleep(5.0); but it was used up to 12 letter fields. So it was impossible for me to get the (137, 14) error.
Tell me where the cursor was located when you get such an error.
_____________________
:) Seagel Neville :)
Gareee Taov
Registered User
Join date: 8 Jan 2007
Posts: 117
02-05-2007 15:05
all I did was copy the text from here, and then pasted it in the script field
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
02-05-2007 18:45
Click the save button, just add a letter in a comment and click save. If there is an error, common if you copy/paste from forums, there will be extra spaces which must be removed. The cursor will appear at the first space. Remove spaces, click save again. The cursor will move to the next error/space. Repeat.

On another issue concerning this door. I had to remove it from my builds as when I sell a build, the new owner rezzes it and the door reverts to original leaving them blue and unsized.
When I rez them they are fine.
I tried to fix it but couldn't. So went back to the black lockable doors. More prims but less hassle.
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
02-05-2007 21:40
From: Kornscope Komachi
Click the save button, just add a letter in a comment and click save. If there is an error, common if you copy/paste from forums, there will be extra spaces which must be removed. The cursor will appear at the first space. Remove spaces, click save again. The cursor will move to the next error/space. Repeat.
Yes, the cursor indicates what is wrong.
From: Kornscope Komachi
On another issue concerning this door. I had to remove it from my builds as when I sell a build, the new owner rezzes it and the door reverts to original leaving them blue and unsized.
When I rez them they are fine.
I tried to fix it but couldn't. So went back to the black lockable doors. More prims but less hassle.
As I told in #9 response, once you made the door shape, you need to comment out the Init() function.

From: someone
If you don't want to change to the defaut when you change something in the script, comment out init() function under the state_entry event.
Quote:
state_entry()
{
// Init();
}
_____________________
:) Seagel Neville :)
Venusvelvet Cazalet
Registered User
Join date: 22 Feb 2007
Posts: 16
03-09-2007 17:30
thank you for such a prim saver code :)

btw, the UUID key you put in the triggersound line, is there a way we can use other sound in the UUID key without uploading a new sound? like is there in fact a table of all those values? thanks. :)
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
03-09-2007 17:51
The UUID is decided exact when you upload a new texture in world, and you can't use the UUID even uploaded in beta grid, either. If you'd not like to upload any texture by yourself, you have to know the UUID which someone else released as public domain.
I don't know where and who released them, but there are lists that Wiki people shared.
_____________________
:) Seagel Neville :)
Venusvelvet Cazalet
Registered User
Join date: 22 Feb 2007
Posts: 16
03-09-2007 20:17
oh cool seagel, i'll check it out, thanks :)
Learjeff Innis
musician & coder
Join date: 27 Nov 2006
Posts: 817
04-04-2007 06:51
A better way to detect "long touch" is to record the time on touch_start, and on touch_end find out how much time elapsed. This avoids the script hogging the CPU when holding the mouse button down. Things like this are not very important for unusual and rarely used objects, but if this script is used in a large number of doors on a busy sim it will really bring script response to its knees on that sim.

Another approach is to start a timer on touch_start, and lock or unlock on timer elapsed event. Simply stop the timer on touch_end. However, that only works if you're not using the timer for other things.

Since this script is rather hoggy when touched, it should not be used for heavy traffic areas.
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
04-04-2007 08:28
From: Learjeff Innis
Since this script is rather hoggy when touched, it should not be used for heavy traffic areas.


Scripts get executed on a best effort basis. This means that they get CPU time when the sim does not have anything else to do.

As a result, this script -- and all others -- can only use as much CPU time as it is given.

The end result is that the user will have to touch and hold for a little longer becasue it will take longer for the script to get to the final counter value.

So, in the end, this script is not any better or worse - in terms of performance - than most other scripts.

-2fast
Learjeff Innis
musician & coder
Join date: 27 Nov 2006
Posts: 817
04-04-2007 08:56
Scripts get a certain amount of CPU time to run in the sim. The amount of time depends on the conditions in the sim, but let's ignore that since it isn't significant here. Suffice it to say that the amount of CPU time available to run scripts is limited: it's not infinite.

Of the time allotted to scripts, if lots of scripts are wasting time doing nothing useful, all scripts run slower. This is what I call "script lag". It doesn't cause movement lag or physics lag, and doesn't slow down the frame rate for server or client. But it does slow down response on all scripts.

Ever been to a sim where things seem to be working fine in that you can move and the frame rate looks fine, but when you push a button, sit on a poseball, or use your HUD, it takes a long time for the script to react? This is script lag. It's caused by running too many scripts or inefficient scripts.

The more work scripts give the server to do, the less often each script gets a chance to run when it needs to (when there's an event pending). Therefore, any time a script takes more instructions to do a given job, it's by definition less efficient, and will contribute to script lag.

Why do you think scripters pay attention to efficiency and performance?

The general rules for evalutating script efficiency are these:

1) The frequency of events handled -- how often does the script need to be awakened?
2) For each event, how much processing does the script do?

Item 1 is generally the most important, and it's why "open listens" are so nasty.

The script above is only inefficient when it's touched, and more so for a long touch. That's far better than open listens. However, whenever it is being touched, it will receive a number of events rather than simply one touch_start() or touch_end(). My suggestion limits the number of events to 2 per touch.

Furthermore, one never knows how long 50 touch events might take, because no doubt they come more slowly on a lagged sim. Use of a timer is much clearer. I find that a 1 or 2 second time for the long touch is reliable. Of course, that might cause unintended lock/unlock triggers in a very laggy sim, but it would be a rare case. And since the script wisely notifies the user when locking or unlocking, this wouldn't be much of a problem.

Bottom line: CPU time is limited, so don't waste it.
sirhc DeSantis
Registered User
Join date: 8 Jan 2007
Posts: 60
still...
04-04-2007 16:37
I just tried this and as new to scripts will try to take it apart to learn. awesome example though and thx for posting it. question for previous poster Learjeff - just how bad are open listens in terms of performance?
1 2 3