Difference between revisions of "Key Pad Door"
Tdub Dowler (talk | contribs) |
Tdub Dowler (talk | contribs) |
||
Line 2: | Line 2: | ||
This keypad Door is composed of 3 scripts, one for the door, one for the keypad, and one for each keypad button. | This keypad Door is composed of 3 scripts, one for the door, one for the keypad, and one for each keypad button. | ||
Below is the script for the button: | Below is the script for the button: | ||
<br> | |||
Put this script in each button. Make 11 buttons and name them the following: "Reset","Enter",and the numbers 1-9. | |||
<pre> | <pre> | ||
//Button Script | |||
default | default | ||
{ | { | ||
touch_start(integer total_number) | |||
{ | { | ||
llMessageLinked(LINK_ROOT,1,llGetObjectName(),NULL_KEY); | |||
} | } | ||
} | |||
</pre> | |||
<br> | |||
Then mount the buttons on a root prim and call the root prim "Key Pad" (without quotes) and put the following script in it. On rez it will ask you what you want the code to be, say it in the form x,y,z with as many digits as desired. After 15 seconds of not anwsering, it we default to 1,2,3,4. | |||
<pre> | |||
integer channel = 3800; //If you change this remeber to change it in the door script as well | |||
list temp; | |||
list code = [1,2,3,4]; | |||
integer handle; | |||
default | |||
{ | |||
on_rez(integer param) | |||
{ | |||
handle = llListen(0,"",llGetOwner(),""); | |||
llOwnerSay("What do you wish the code to be?"); | |||
llSetTimerEvent(15); | |||
} | |||
link_message(integer send_num, integer num, string msg, key id) | |||
{ | |||
if(msg == "Reset") | |||
{ | |||
temp = []; | |||
} | |||
if(msg == "Enter") | |||
{ | |||
if(temp != code) | |||
{ | |||
llWhisper(0,"Incorrect Code!!"); | |||
temp = []; | |||
} | |||
if(llList2CSV(temp) == llList2CSV(code)) | |||
{ | |||
llWhisper(channel,"open"); | |||
llWhisper(0,"You may enter."); | |||
temp = []; | |||
} | |||
} | |||
if(msg != "Reset" && msg != "Enter") | |||
{ | |||
temp += [(integer)msg]; | |||
if(llGetListLength(temp) > llGetListLength(code)) | |||
{ | |||
temp = []; | |||
} | |||
} | |||
} | |||
timer() | |||
{ | |||
llOwnerSay("You have run out of time. Setting default " + llList2CSV(code)); | |||
llListenRemove(handle); | |||
llSetTimerEvent(0); | |||
} | |||
listen(integer chan, string name, key id, string msg) | |||
{ | { | ||
llListenRemove(handle); | |||
code = llCSV2List(msg); | |||
llOwnerSay("Code set to " + llList2CSV(code) + "."); | |||
llSetTimerEvent(0); | |||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
Now the door script. The door can be called anything. Script is as follows: | |||
<pre> | |||
integer channel = 3800; //Must be the same as in the key pad script | |||
float open_time = 3; //Change to how long you want it to stay open | |||
{{#vardefine:sort| | default | ||
{ | |||
state_entry() | |||
{ | |||
llListen(3800,"Key Pad",NULL_KEY,"open"); | |||
} | |||
listen(integer chan, string name, key id, string msg) | |||
{ | |||
llSetStatus(STATUS_PHANTOM,TRUE); | |||
llSetAlpha(0.1,ALL_SIDES); | |||
llSleep(open_time); | |||
llSetAlpha(1.0,ALL_SIDES); | |||
llSetStatus(STATUS_PHANTOM,FALSE); | |||
} | |||
} | |||
</pre> | |||
<br> | |||
If you want the completed object with key pad and door, you can buy it at http://www.tslemporium.com for 30 L$. I will not give support to people who use the scripts on this page for thier own door, only paying customers. | |||
{{#vardefine:sort|Key Pad Door}}{{LSLC|Library}}{{LSLC|Examples}} |
Revision as of 15:48, 3 March 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
This keypad Door is composed of 3 scripts, one for the door, one for the keypad, and one for each keypad button.
Below is the script for the button:
Put this script in each button. Make 11 buttons and name them the following: "Reset","Enter",and the numbers 1-9.
//Button Script default { touch_start(integer total_number) { llMessageLinked(LINK_ROOT,1,llGetObjectName(),NULL_KEY); } }
Then mount the buttons on a root prim and call the root prim "Key Pad" (without quotes) and put the following script in it. On rez it will ask you what you want the code to be, say it in the form x,y,z with as many digits as desired. After 15 seconds of not anwsering, it we default to 1,2,3,4.
integer channel = 3800; //If you change this remeber to change it in the door script as well list temp; list code = [1,2,3,4]; integer handle; default { on_rez(integer param) { handle = llListen(0,"",llGetOwner(),""); llOwnerSay("What do you wish the code to be?"); llSetTimerEvent(15); } link_message(integer send_num, integer num, string msg, key id) { if(msg == "Reset") { temp = []; } if(msg == "Enter") { if(temp != code) { llWhisper(0,"Incorrect Code!!"); temp = []; } if(llList2CSV(temp) == llList2CSV(code)) { llWhisper(channel,"open"); llWhisper(0,"You may enter."); temp = []; } } if(msg != "Reset" && msg != "Enter") { temp += [(integer)msg]; if(llGetListLength(temp) > llGetListLength(code)) { temp = []; } } } timer() { llOwnerSay("You have run out of time. Setting default " + llList2CSV(code)); llListenRemove(handle); llSetTimerEvent(0); } listen(integer chan, string name, key id, string msg) { llListenRemove(handle); code = llCSV2List(msg); llOwnerSay("Code set to " + llList2CSV(code) + "."); llSetTimerEvent(0); } }
Now the door script. The door can be called anything. Script is as follows:
integer channel = 3800; //Must be the same as in the key pad script float open_time = 3; //Change to how long you want it to stay open default { state_entry() { llListen(3800,"Key Pad",NULL_KEY,"open"); } listen(integer chan, string name, key id, string msg) { llSetStatus(STATUS_PHANTOM,TRUE); llSetAlpha(0.1,ALL_SIDES); llSleep(open_time); llSetAlpha(1.0,ALL_SIDES); llSetStatus(STATUS_PHANTOM,FALSE); } }
If you want the completed object with key pad and door, you can buy it at http://www.tslemporium.com for 30 L$. I will not give support to people who use the scripts on this page for thier own door, only paying customers.