// Dialog Menu for User's and Owner (Lock/Unlock Door script v2.0.1 (Fix Version)
// By BigJohn Jade (FREE FOR ALL TO MESS WITH)
// 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.
// Things i will add later. (access list for ppl to work new door code that is not the owner for lock and unlock).
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"],93

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"

{
Door_Lock = FALSE;
open_Door();
return;
}
if(message == "Close Door"

{
Door_Lock = FALSE;
Close_Door();
return;
}
if(message == "Lock Door"

{
Door_Lock = TRUE;
DOOR_OPEN = FALSE;
llDialog(id,"The Door is now Lock",["Ok"],93

return;
}
if(message == "Unlock Door"

{
Door_Lock = FALSE;
DOOR_OPEN = FALSE;
llDialog(id,"The Door is now unLock",["Ok"],93

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"],93

SoundConfig(id);
return;
}
else
PlaySounds = TRUE;
llDialog(id,"Sound is now turn on",["Ok"],93

SoundConfig(id);
return;
}
if(message == "Sound off"

{
if (PlaySounds == FALSE)
{
llDialog(id,"Sound already off",["Ok"],93

SoundConfig(id);
return;
}
else
PlaySounds = FALSE;
llDialog(id,"Sound is now turn off",["Ok"],93

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
}
}
}