Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

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
Discussion Thread
07-25-2006 14:16
/54/04/124170/1.html
_____________________
i've got nothing. ;)
stuarttank4 Stuart
Registered User
Join date: 8 Jul 2006
Posts: 21
08-23-2006 00:36
first thing thanks.

second thing does it work with any other shape like a square?

Do you know how to make something be able to be carried by another object without it being linked to that object so it acts like a cargo?

bye