Difference between revisions of "Key Pad Door"

From Second Life Wiki
Jump to navigation Jump to search
m (lsl code tagging)
m
Line 1: Line 1:
{{LSL Header}}
{{LSL Header|ml=*}}
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:

Revision as of 15:36, 24 October 2008

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. <lsl> //Button Script default {

   touch_start(integer total_number)
   {
       llMessageLinked(LINK_ROOT,1,llGetObjectName(),NULL_KEY);
   }

} </lsl>
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. <lsl> 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);
   }

} </lsl>
Now the door script. The door can be called anything. Script is as follows: <lsl> 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);
   }

} </lsl>
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.