Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need Help adding users to Door Lock Script

Rex Riel
Registered User
Join date: 20 Apr 2006
Posts: 1
09-05-2006 07:28
I have the following script, and I need to know how to add a list of people to it so that they can unlock the door as well as myself (the owner). Here is the script, and any help anyone can give me would be appreciated (Esp since I am unlock it but my spouse cant). I did speak to the orgi creator, but he never forwarded me an updated one:

// *************************************************************************
// Open Source Dialogs Menu Door Script
// Script Name: Dialog Menu for User's and Owner (Lock/Unlock Door script
// Script Version: v2.0.2
// By BigJohn Jade (FREE FOR ALL TO MESS WITH)

// I added a fix so if menu is already in use and something change before owner or user pick something from menu it will check status first.

// Things i will add later. (access list for ppl to work new door code that is not the owner for lock and unlock).

// *************************************************************************

// Part of codes was took from FlipperPA Peregrine Door Script to help with this project

// Dialog Style using here is same as CrystalShard Foo made no need to change code style just love lag free way to script.

// *************************************************************************


integer lH = -1; // Dialog menu listen handler
integer lA = -1; // listen handler on channel 1
integer lT = -1; // remove listeners after 2 mins..
integer chan; // llDialog listen channel

integer DIRECTION = 1; // direction door opens in. Either 1 (outwards) or -1 (inwards);

integer DOOR_OPEN = FALSE; // door is close

rotation rot; // rotation type of 4 floats
rotation delta; // rotation type of 4 floats

integer PlaySounds = TRUE; // Play the open and close sounds for the door

integer Door_Lock = FALSE; // The door is not lock

string sound_open = "cb340647-9680-dd5e-49c0-86edfa01b3ac"; // Sound UUIDWave for door open

string sound_close = "cb340647-9680-dd5e-49c0-86edfa01b3ac"; // Sound UUIDWave for door close

et() // add 2 mins to the remove
{
if(lH == -1)
lH = llListen(chan,"","","";);
lT = (integer)llGetTime() + 120;
llSetTimerEvent(45);
}

Config(key id) // main config dialog for owner
{
llDialog(id,"Door Status: "+(string)Door_Lock+".",["Sounds","Menu"],chan);
}


SoundConfig(key id) // sound config dialog for owner
{
llDialog(id,"Current Sound Setting: "+(string)PlaySounds+" .",["Sound on","Sound off","Back"],chan);
}

menu(key id)
{
list buttons = [];
string title = "** Door System v2.0 Control **"; // Dialogs Menu for Owner

et();

title+="\n Owner Access mode";
if (Door_Lock == FALSE && DOOR_OPEN == FALSE)
{
buttons+=["Configure","Open Door","Lock Door"];
}
else
if (Door_Lock == TRUE && DOOR_OPEN == FALSE)
{
buttons+=["Configure","Unlock Door"];
}
else
if (Door_Lock == FALSE && DOOR_OPEN == TRUE)
{
buttons+=["Configure","Close Door"];
}
llDialog(id,title,buttons,chan);

}
menu2(key id)
{
list buttons = [];
string title = "** Door System v2.0 Control **"; // Dialogs Menu for user

et();

title+="\n User Access mode";
if (Door_Lock == TRUE && DOOR_OPEN == FALSE)
{
llDialog(id,"Door is lock no access!",["Ok"],938);
return;
}
else if (Door_Lock == FALSE && DOOR_OPEN == FALSE)
{
buttons+=["Open Door"];
}
else
if (Door_Lock == FALSE && DOOR_OPEN == TRUE)
{
buttons+=["Close Door"];
}
llDialog(id,title,buttons,chan);

}
Initialize_OpenSound() // Sound play is true then play open door UUIDwave
{
if (PlaySounds == FALSE)
{
return;
}
float volume = 10.0;
llStopSound();
llPreloadSound(sound_open);
llPlaySound(sound_open, volume);
}
Initialize_CloseSound() // Sound play is true then play close door UUIDwave
{
if (PlaySounds == FALSE)
{
return;
}
float volume = 10.0;
llStopSound();
llPreloadSound(sound_open);
llPlaySound(sound_open, volume);
}

open_Door()
{
DOOR_OPEN = TRUE; // open the door
Initialize_OpenSound();
rot = llGetRot();
delta = llEuler2Rot(<0, 0, -DIRECTION * PI_BY_TWO>;);
rot = delta * rot; // rotate by -45 degree
llSetRot(rot);
}

Close_Door()
{
DOOR_OPEN = FALSE; // close the door
Initialize_CloseSound();
rot = llGetRot();
delta = llEuler2Rot(<0, 0, DIRECTION * PI_BY_TWO>;);
rot = delta * rot; // rotate by 45 degree
llSetRot(rot);
}

default
{
state_entry()
{
chan = (integer)llFrand(1000) + 1000; // random listen channel
llListenRemove(lH);
lH = -1;

}
touch_start(integer count) // Lets check for user or owner access that clicks the object
{
integer CheckAccess;
for (CheckAccess=0;CheckAccess<count;CheckAccess++)
{
key person = llDetectedKey(CheckAccess);
string name = llDetectedName(CheckAccess); // For later access list

if (person == llGetOwner())
{
menu(llDetectedKey(0)); // owner dialog menu
return;
}
if (person != llGetOwner())
{
menu2(llDetectedKey(0)); // user dialog menu
}
}
}
listen(integer channel, string name, key id, string message)
{
if(lA != -1 && channel == 1) // For later access
{
llListenRemove(lA);
lA = -1;
}
if(message == "Open Door";)
{
if (DOOR_OPEN == TRUE)
{
llDialog(id,"The Door is already open",["Ok"],938);
return;
}
else
if (Door_Lock == TRUE)
{
llDialog(id,"The Door is lock no access!",["Ok"],938);
return;
}
else
Door_Lock = FALSE;
open_Door();
return;
}
if(message == "Close Door";)
{
if (DOOR_OPEN == FALSE)
{
llDialog(id,"The Door is already close",["Ok"],938);
return;
}
else
if (Door_Lock == TRUE)
{
llDialog(id,"The Door is lock no access!",["Ok"],938);
return;
}
else
Door_Lock = FALSE;
Close_Door();
return;
}
if(message == "Lock Door";)
{
if (Door_Lock == TRUE)
{
llDialog(id,"The Door is already Lock!",["Ok"],938);
return;
}
else
Door_Lock = TRUE;
DOOR_OPEN = FALSE;
llDialog(id,"The Door is now Lock",["Ok"],938);
return;
}
if(message == "Unlock Door";)
{
if (Door_Lock == FALSE)
{
llDialog(id,"The Door is already unlock!",["Ok"],938);
return;
}
else
Door_Lock = FALSE;
DOOR_OPEN = FALSE;
llDialog(id,"The Door is now unLock",["Ok"],938);
return;
}
if(message == "Configure";)
{
Config(id);
return;
}
if(message == "Menu";)
{
menu(id);
return;
}
if(message == "Sounds";)
{
SoundConfig(id);
return;
}
if(message == "Back";)
{
Config(id);
return;
}
if(message == "Sound on";)
{
if (PlaySounds == TRUE)
{
llDialog(id,"Sound already on",["Ok"],938);
SoundConfig(id);
return;
}
else
PlaySounds = TRUE;
llDialog(id,"Sound is now turn on",["Ok"],938);
SoundConfig(id);
return;
}
if(message == "Sound off";)
{
if (PlaySounds == FALSE)
{
llDialog(id,"Sound already off",["Ok"],938);
SoundConfig(id);
return;
}
else
PlaySounds = FALSE;
llDialog(id,"Sound is now turn off",["Ok"],938);
SoundConfig(id);
return;
}
}
timer()
{
if(llGetTime() > lT) // if listener time run out
{
llListenRemove(lH); // remove listen handler
llListenRemove(lA); // // remove listen handler on channel 1
lH = -1;
lA = -1;
lT = -1;
llSetTimerEvent(0.0); // remove timer
}
}
}
HtF Visconti
Registered User
Join date: 21 Jul 2006
Posts: 123
09-05-2006 07:35
I'd really like to examine the script but not at the price of getting new glasses. Please edit your post first and use the php tags to format it in a readable fashion.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
09-05-2006 08:05
To make this script more readable in this forum (and get more help!!!), please put

[ php ] before the script

and

[ /php ] after it

(without the spaces)

Baron H.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-06-2006 05:28
This is a very simple door lock I made a while back. It could easily be expanded to use a notecard, in fact I think i probably have just cant find it....

I cant remember where i picked the original door code from


CODE

// List of allowed users.
// using lowercase compares to avoid capitialisation problems
list names = ["newgate ludd","someones name"];


MoveDoor(integer Open)
{

llTriggerSound("Door", 0.5);

float angle;
if(Open == 1)
angle = (-PI/4);
else
angle = PI/4;

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,angle>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
}

default
{
state_entry()
{
llSay(0, "NL Door 1.0");
state open;
}
}

state open
{

touch_start(integer total_number)
{
// Use lowercase comparisons to avoid typing problems
string name = llToLower(llDetectedName(0));
integer iIndex = llListFindList(names, [ name ]);
if(iIndex >= 0)
{
MoveDoor(1);
state closed;
}
else
{
llTriggerSound("bell", 0.7);
llWhisper(0,"only the resident can open this door");
}
}
}

state closed
{
state_entry()
{
// Door auto closes after 20 seconds
llSleep(20.0);
MoveDoor(0);
state open;
}
}