Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Iris opening door script, using a torus

Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
07-24-2006 14:32
This script enables you to use a torus as a simple touch-activated iris door, for science fiction or organic building projects. It uses a torus as the prim for the door, and opens or closes the hole in the torus to operate it.

To use, make a flattened torus, the height and width you need for your door, and about 0.1M to 0.05M thick. The 'door frame' for this can be another torus, or an oval or round hole in another prim.

CODE
// Iris Open Script by Cera Murakami - 7/21/2006
// Touch-sensitive iris opening door
// Toggles open and closed state for a hole in a torus as an iris door
// Put this script into a flattened torus.


// ----- Global Variables ------------------
integer g_OpenNow; // True (1) if iris is 'open' now

default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // Iris is Open, and waiting to close
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // Iris is closed, and waiting to open
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = TRUE;
state WaitToClose;
}
}

Note that the same script should also be able to be used with a different prim shape for the iris door prim, by changing the specifications in the two llSetPrimitiveParams statements to suit the other prim shape. I'll experiment some more with that soon, and will offer some variations here later.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
07-25-2006 14:16
/15/ff/123927/1.html
_____________________
i've got nothing. ;)
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
07-25-2006 14:33
My initial discussion on this script is in this thread. Now that the script is in the library, further discussion will be here, instead.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
07-25-2006 14:42
I see one small issue, I wouldn't even call it a problem. If the script is reset, g_OpenNow will go back to being 0, but the prim will stay in whatever shape it's currently in. So you then execute state_entry in the default state, and g_OpenNow is false, so you go to WaitToOpen. However, the door may already be open. So the first time someone touches it, nothing will happen. After that, it'll close on the next touch, and everything will be in sync again. So, it's not really a problem. But say you were triggering something else based on whether the door was open or closed, then that would be off after a reset until someone clicked on it.

I hope that makes sense :)
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
07-25-2006 18:43
Yes Ziggy, that makes perfect sense. The workaround would be to use llGetPrimitiveParams in the handler for reset condition, to check the state of the holesize parameter. Haven't tried to do that at all yet, but that would also be a necessary step in having the script auto-detect the type of prim that it was in, if dropped into a default prim. I may play with that on an advanced version, but for now, I'll not worry if it 'ignores' a first touch after a reset, if the door is already open.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
07-27-2006 10:14
I tried adding 5 more iterations of the llSetPrimitiveParams statement in the open and close event handlers, and using six inctemental holesize values, to more smoothly move from one state to the other. The result worked, but the timing was still pretty jerky and uneven. Not sure it was at all worth it.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
07-28-2006 03:23
From: Ceera Murakami
I tried adding 5 more iterations of the llSetPrimitiveParams statement in the open and close event handlers, and using six inctemental holesize values, to more smoothly move from one state to the other. The result worked, but the timing was still pretty jerky and uneven. Not sure it was at all worth it.

That is down to the 0.2 second delay.

To make is smoother, you would need to have (for example) 6 separate scripts, each of which listened for a link message, and then changed to the messaged size, then send out the 6 link messages in rapid succession.

That way, each of the daughter scripts get delayed, and your main one doesn't.
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
08-05-2006 19:09
That makes a pretty cool door Ceera, thanks for sharing it.

Here is a similar door using a cube and voice.chat commands to activate it. This just opens or closes in one step.

CODE
//this script is changes the paramaters of a cube to make the hollow function as a door.  
// it can be activated by a switch or voice commands on private channel 5


default
{
state_entry()
{
//llListen(5,"",llGetOwner(),""); //only owner can change it.
llListen(5,"","",""); //anyone can change it.
}
listen(integer chan, string name, key id, string msg)
{
//------------------------------------------------------
if(msg=="open")//hollow opens
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 16, <0.0, 1.0, 0.0>, 0.9, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
}
//------------------------------------------------------
if(msg=="close")//hollow closes
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 16, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
}
//etcetera for other settings

}
}
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
08-05-2006 23:33
I did this a while back using a flattened box with a circular hollow applied. A FOR loop continuously changed the hollow amount until it was fully opened, slept, then closed it again. The delay between changes was slight, and created a pretty nice effect.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
09-24-2006 12:42
Thanks for the cool script Ceera. Not only did I learn a bit about the llSetPrimativeParams command, but this script is a nice clear example of how to use states which was very helpful to me as well.

It has inspired me to write several new scripts, two of which I posted here :)
_____________________
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
SnapHatch Door
09-25-2006 08:08
I use a similar technique for my SnapHatch Door. My script will work with ANY suitable prim type and ANY hole shape, without modification, and deals with the syncronization issue by explicitly closing the door on script reset.

My door also remembers WHO last operated it, and when operated, tells the OWNER of the door who LAST operated the door. This way, if I come home and find my door OPEN, when I close it, it tells me who last opened it. Vice-versa as well: when I open it, it tells me who last closed it. I get the message regardless of who operates the door, provided I`m in the same sim at the time. The operator of the door gets no such message, unless that`s me. Of course, if the door in question was yours instead of mine, YOU would get the messages. :)
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
09-25-2006 12:36
Does it tell you everytime? Like if you were to close it, and then open it again, it will tell you that you were the last person to close it and vice versa?

I could see it being usefull to poll who when through your door, but you could also set this to save in a script in another prim to a list of people who went through it/etc, and add a touch even to that 'security prim' that could do all kinds of neat things with the information, or just give you a list of all of the people who went through the door since the last reset.
Drizzt Naumova
Teh Foxeh DJ
Join date: 9 Oct 2005
Posts: 116
10-04-2006 14:51
hmm trying to figure out how to add a timer to the iris open door so that it closes back in X seconds or minutes. any ideas?
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
10-04-2006 15:13
From: Tiarnalalon Sismondi
Does it tell you everytime?
If I`m in the same sim, yes.
From: Tiarnalalon Sismondi
Like if you were to close it, and then open it again, it will tell you that you were the last person to close it and vice versa?
Yup.