Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Simple but fun "door" scripts

Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
09-16-2006 14:06
These are very basic scripts to anyone with scripting skills, but since at least one person liked the “Phantom Alpha Door or Wall” that ArchTx posted I thought I would throw these out. They are “door” type scripts that work in different ways.

I made these one day just screwing around with llSetPrimativeParam commands and didn't think much of it at the time. But I suppose they might be useful to those that can't write scripts but know how to use ones that are already created. Anyway, here they are for what they are worth. :)


The first one will open a hole in a cube on command. To use it you rez a cube and them make it hollow so you can see where the opening will be. Then position it so that the opening is facing the direction you want, such as a tunnel through a wall or maybe a trap door through a floor/ceiling . Once you have it set, set the hollow back to zero and put this script in it. The owner can give it commands on channel 10. A simple open and close command is what I have put in, but you can change the activation words to whatever you like. On command the hole will open or close to give you the effect of a secret door. This script is set to work with a cube right now, but could easily be adapted to different prim shapes.

CODE
 
default
{
state_entry()
{
llOwnerSay("ready");
llListen(10,"","","");
}

listen( integer channel, string name, key id, string message )
{
key owner = llGetOwner();
if(message == "open" & id == owner | message == "open" & name == "switch")
{
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 16, <0.0, 1.0, 0.0>, 0.95, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
}
if( message == "close" & id == owner | message == "close" & name == "switch" )
{
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>]);
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
}
}
}




The second script will make the cube shrink down and vanish on command, giving you the effect of the door shrinking to nothing. Just plonk in into a cube and position it where you like. It works on the same channel and is set to the same activation words, both of which you can change of course. You can make variations on this as well, such as one I did where I played with the Alpha settings in the PRIM_COLOR line to make it partially trans and then added a PRIM_POINT_LIGHT, TRUE, to the close part to make it glow to give the effect of a force field barrier (and of course a PRIM_POINT_LIGHT, FALSE line to the open part to make it not glow when open/off).

CODE

default
{
state_entry()
{

llOwnerSay("ready");
llListen(10,"","","");
}

listen( integer channel, string name, key id, string message )
{
key owner = llGetOwner();
if(message == "close" & id == owner | message == "close" & name == "switch")
{
// llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); // uncomment out this line for force field effect
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <1, 0, 0>, 1.00]); // change the 1.00 to 0.75 for the force field effect.
llSetPrimitiveParams([PRIM_SIZE, <4, 4, 0.1>]); // change this vector to whatever size you want the door to be when closed.
//llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 0, 0>, 1.0, 10.0, 0.75]); // uncomment out this line for force field effect
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
//llSay(0,"Access now restricted"); // uncomment out this line for force field effect
}
if(message == "open" & id == owner | message == "open" & name == "switch")
{

llSetPrimitiveParams([PRIM_SIZE, <0.01, 0.01, 0.01>]);
//llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <1, 0, 0>, 1.0, 10.0, 0.75]); // uncomment out this line for force field effect
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <1, 1, 1>, 0.0]);
//llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); // uncomment out this line for force field effect
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
//llSay(0,"You may enter"); //// uncomment out this line for force field effect
}
}
}



Here is a simple script you can put in a prim to act as a switch for the doors, so that persons other than the owner can use them:

CODE
 default
{
state_entry()
{
llSay(0, "switch ready");
llSetObjectName("switch");// the object must be named "switch" for the door to listen to it, this renames it automatically for you.
}

touch_start(integer total_number)
{
llShout(10, "open"); // change "open" to "close" for the switch that will close the door
//llSleep(15); // Uncomment this line and the next line if you want the door to close automatically after 15 seconds
//llShout(10, "close");
}
}



Edit 17Sept06 - I tightened up the listen functions to make them more efficient because I saw this in the wiki:

From: LSL Wiki
To listen on a single channel, for both chat from the owner and from an object with a certain name, (or any other combination of logic) the best option is to use a single llListen function and an if-else in the listen event.
_____________________
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
09-16-2006 14:38
/54/c7/137951/1.html
_____________________
i've got nothing. ;)
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
09-17-2006 12:09
I just wanted to point out that I edited the script a bit to tighten up the llListen functions because of something I saw in the wiki.
_____________________