Well there are several techniques to make doors with passwords, but I think this is by far the easiest method. Although this tutorial is relatively long, it is still relatively easy - trust me).
STEP 1: BUILDING A KEY PAD
If you want to do a key pad password to a door(or anything else) the following is required. Note, that the colors of the keys relate to the key position and order they must be pressed to unlock the door. In this example the code is 5734:
For consistency, I have colored all keys in this tutorial, and the colours are assigned thus:
FIRST DIGIT,
SECOND DIGIT,
THIRD DIGIT,
FOURTH DIGITIn the map editor align the buttons of your key pad like this:
B1,B2,
B3B4,
B5,B6
B7,B8,B9
BR,B0,BA
Make sure
all buttons have wait=0.1
Buttons B0-B9 can have the "port 0#" texture. Where you make it bigger and make it so only the last number is shown, the port 0# textures are in SIGNS category in Qoole 99.
To make the 0-button, take port01, but use the zero in the beginning.
BR can have the empty round, gray button that turns orange when pressed.
BA can have elevator button pointing UP.
STEP 2: MAKING THE LOCK CODE
The first code number must have a trigger referring to the first
trigger_changetargetAs stated above, the code is set to 5734
B1:targetname: B1
target: but_reset
B2:targetname: B2
target: but_reset
B3:targetname: B3target: but_resetB4:targetname: B4target: but_resetB5:targetname: B5target: but_code1B6:targetname: B6
target: but_reset
B7:targetname: B7target: but_resetB8:targetname: B8
target: but_reset
B9:targetname: B9
target: but_reset
B0:targetname: B0
target: but_reset
BR:targetname: (nothing)
target: but_reset
BA:targetname: BA
target: sound_denied
STEP 3: CODING THE TRIGGER_CHANGETARGETS
11 trigger_changetarget are required to make the key pad work. Note that all these triggers here are trigger_changetarget. Set the trigger_changetargets to:
targetname: but_reset
target: B0
newtarget: but_reset
targetname: but_reset
target: B1
newtarget: but_reset
targetname: but_reset
target: B2
newtarget: but_reset
targetname: but_resettarget: B3newtarget: but_resettargetname: but_resettarget: B4newtarget: but_resetNOTE: The first code digit must be reset correctly, or else the code lock will "lock" after entering a wrong code digit!! (I learnt that the hard way)targetname: but_resettarget: B5newtarget: but_open1targetname: but_reset
target: B6
newtarget: but_reset
targetname: but_resettarget: B7newtarget: but_resettargetname: but_reset
target: B8
newtarget: but_reset
targetname: but_reset
target: B9
newtarget: but_reset
The reset for "enter" button by:
targetname: but_reset
target: BA
newtarget: sound_denied
STEP 5: BUILDING THE CODE CHECK
Now we create an 8
trigger_changetarget to update the codelock, if the correct code digit has been entered.
GROUP 1targetname: but_open1target: B5newtarget: but_resettargetname: but_open1target: B7newtarget: but_open2GROUP 2targetname: but_open2target: B7newtarget: but_resettargetname: but_open2target: B3newtarget: but_open3GROUP 3targetname: but_open3target: B3newtarget: but_resettargetname: but_open3target: B4newtarget: but_open4GROUP 4targetname: but_open4target: B4newtarget: but_resettargetname: but_open4
target: BA
newtarget: sound_granted
STEP 6: CONNECTING THE CODE LOCK TO THE DOOR
Connecting the code lock to the door is essential, else the codelock is completely useless. To do this you need to create two small button
OUTSIDE the map.
The first button:targetname: sound_denied
target: but_reset
sound: Access Denied
wait: 0.1
The second button:targetname: sound_granted
target: but_door
sound: Access Granted
wait: 0.1
STEP 7: TARGETING THE DOOR
Now we target but_door to what we want when the correct code is entered. We target it to a single func_door:
targetname: but_door
target: but_reset
<<< NOTE!! The but_reset is vital to reset the code when the door has been opened. For example, in multiplayer maps this means the next play can not open the door, without re-entering the code
CONCLUSION
The codelock can be used again and again. I believe this will be cool in multiplayer maps, where the developer can have a "code" to enter a protect-room, or full with weapons. Imagine a button to open a door with lava under all the other players. Why not a turret? use your imagination!
Finally I have included an flow diagram of all the triggers and buttons required to make this work. It doesn't display to well here, so click and download:
Have fun with your code locks!