How to Make a Working Keypad: Difference between revisions
Jump to navigation
Jump to search
Dr. Kylstien (talk | contribs) mNo edit summary |
Dr. Kylstien (talk | contribs) No edit summary |
||
Line 84: | Line 84: | ||
useractor notenemy KEYPAD WEAKEST | useractor notenemy KEYPAD WEAKEST | ||
{ | { | ||
ifpdistl 1024 ifp pfacing ifhitspace ifvare com_pause 0 // There are lot of conditons on this line. The last one is there to ensure proper timing. | ifpdistl 1024 ifp pfacing ifhitspace ifcansee ifvare com_pause 0 // There are lot of conditons on this line. The last one is there to ensure proper timing. | ||
{ | { | ||
ifvare pad_id -1 // enter passcode entering mode | ifvare pad_id -1 // enter passcode entering mode | ||
Line 116: | Line 116: | ||
state clearpad | state clearpad | ||
ifp pfacing nullop else | ifp pfacing nullop else | ||
state clearpad | |||
ifcansee nullop else | |||
state clearpad | state clearpad | ||
} | } |
Revision as of 19:09, 31 March 2007
If you've ever wanted to have a keypad in your mod that the player can type a code into, this should demonstrate how:
gamevar pad_id -1 1 //This stores the id of the keypad that the player is using.
gamevar pnum 0 1 // This stores the passcode as he enters it.
gamevar param 0 2
gamevar temp 0 2
gamevar hitagsav 0 2
gamevar lotagsav 0 2
// This is defined once and re-used for each of the buttons. 'param' is the digit to enter
state enterdigit
{
ifvarn pad_id -1 ifvarl pnum 9999 //hitags can only reach 65536, so we limit entered codes to 5 digits.
{
setvar RETURN -1 //Keep in mind that the buttons we are using are serving double-duty as weapon selection. We only disbale that when we are entering a passcode.
mulvar pnum 10 // This shifts the passcode over a place value to make room for the new digit
addvarvar pnum param
}
}
ends
// The actual buttons. Any one should do as long as you set param to the digit and call 'enterdigit'.
onevent EVENT_WEAPKEY10
setvar param 0
state enterdigit
endevent
onevent EVENT_WEAPKEY1
setvar param 1
state enterdigit
endevent
onevent EVENT_WEAPKEY2
setvar param 2
state enterdigit
endevent
onevent EVENT_WEAPKEY3
setvar param 3
state enterdigit
endevent
onevent EVENT_WEAPKEY4
setvar param 4
state enterdigit
endevent
onevent EVENT_WEAPKEY5
setvar param 5
state enterdigit
endevent
onevent EVENT_WEAPKEY6
setvar param 6
state enterdigit
endevent
onevent EVENT_WEAPKEY7
setvar param 7
state enterdigit
endevent
onevent EVENT_WEAPKEY8
setvar param 8
state enterdigit
endevent
onevent EVENT_WEAPKEY9
setvar param 9
state enterdigit
endevent
// this makes reseting the code entry easier.
state clearpad
{
setvar pad_id -1
setvar pnum 0
}
ends
// The hitag of the keypad actor is the passcode, and the lotag should match that of the activator or activator-locked.
eventloadactor KEYPAD
{
getactor[THISACTOR].hitag hitagsav
getactor[THISACTOR].lotag lotagsav
setactor[THISACTOR].hitag 0
setactor[THISACTOR].lotag 0
}
enda
useractor notenemy KEYPAD WEAKEST
{
ifpdistl 1024 ifp pfacing ifhitspace ifcansee ifvare com_pause 0 // There are lot of conditons on this line. The last one is there to ensure proper timing.
{
ifvare pad_id -1 // enter passcode entering mode
{
soundonce MONITOR_ACTIVE
setvarvar pad_id THISACTOR
quote 143
}
else ifvarvare pad_id THISACTOR
{
ifvarvare pnum hitagsav // passcode accepted
{
getplayer[THISACTOR].i temp
operateactivators lotagsav temp
soundonce MONITOR_ACTIVE
quote 145
state clearpad
}
else // passcode rejected (The 'soundonce' and 'quote' statements are optional, and the quote numbers wil likely be different for your mod. )
{
soundonce LASERTRIP_ARMING
quote 144
state clearpad
}
}
setvar com_pause 10 // This sets a delay between presses of space so that everything doesn't happen at once.
}
ifvarvare pad_id THISACTOR // this block disengages the player from the keypad when he moves or looks away from it.
{
ifpdistg 1024
state clearpad
ifp pfacing nullop else
state clearpad
ifcansee nullop else
state clearpad
}
}
enda
/* These lines should go into the APLAYER code:
ifvarg com_pause 0
subvar com_pause 1
*/