• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Keypad Codes

Status
Not open for further replies.
They are featured in such games as Malum Ruina.
They include a small bit of UI which has a number pad from 1-9.
The game randomizes a 4 digit code, and then you have the opportunity to tell certain players what that code is.
The code can be used as events for triggers, such as opening a door or changing the ownership of a unit.
Anyone know how this is possible? I'm going to assume it has to do with Banks and Variables, but I have no facts supporting said assumptions.
Link to a tutorial, if possible?
 
Level 14
Joined
Jan 5, 2009
Messages
1,127
Prolly has to do with random variables
Kinda like this:
set Code1[1] = Random(1, 9)
set Code1[2] = Random(1, 9)
set Code1[3] = Random(1, 9)
set Code1[4] = Random(1, 9)
set Code1C = Combine(Int2String(Code1[1])+Int2String(Code1[2])+Int2String(Code1[3])+Int2String(Code1[4]))
Somethin like that, and when a play walks up to a door it asks for it.
But before that like a console can go Text Message: Combine("The code to the door is " + Code1C)
So ya, I think thats what your talkin bout
 
Level 11
Joined
Aug 1, 2009
Messages
963
For the UI, just use a bunch of buttons with their current values set to certain integers, with a trigger that has them added as events. EG, 1-9 for numerical buttons, 0 for enter, -1 for delete.

Then, you store the values they enter into a variable, and you check if it is the same as the stored variable you have for the keycode, ie what Crazed_seal showed.
 
Thanks <3

Edit: I understand now how you create the random 4 digit password, but my next question is how would I set a trigger event to match the given numbers? (the player has to type in the right code)
Is there a function for 'check integer' that I'm missing?

Then, you store the values they enter into a variable, and you check if it is the same as the stored variable you have for the keycode, ie what Crazed_seal showed.

Is what I'm looking for.. I just can't seem to find the functions required for this..
 
Last edited:
Yes I know that must be done, but how?
I mean.. I have no idea how to work custom UI.
The way it's set up right now (thanks to Crazed_seal2) is the randomly generated 4 digit password is set to a single variable (array of 4).
Assuming I had the keypad done, how would I set up a trigger to store the numbers typed into the keypad into another variable?
Also how would I make a trigger to check if the numbers entered and the passcode are the same?
Sorry if I'm asking so many questions.. but I'm not very good with Variables..
I can only really use player groups to my advantage as well as a few things such as income with integers.
Help is appreciated.

Edit: Worst comes to worst I can ditch the custom UI, and instead create custom buttons, labeled 1-9, and assign them to custom abilities.
The numbers could be added to the keypad code integer variable based on which abilities are used.
Then a trigger could run a check to see if the numbers in the keypad code integer match the correct keypad code.

My question is how would I do that? I can't seem to figure it out using basic GUI triggers.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Yes I know that must be done, but how?
I mean.. I have no idea how to work custom UI.
The way it's set up right now (thanks to Crazed_seal2) is the randomly generated 4 digit password is set to a single variable (array of 4).
Assuming I had the keypad done, how would I set up a trigger to store the numbers typed into the keypad into another variable?
Also how would I make a trigger to check if the numbers entered and the passcode are the same?
Sorry if I'm asking so many questions.. but I'm not very good with Variables..
I can only really use player groups to my advantage as well as a few things such as income with integers.
Help is appreciated.

Edit: Worst comes to worst I can ditch the custom UI, and instead create custom buttons, labeled 1-9, and assign them to custom abilities.
The numbers could be added to the keypad code integer variable based on which abilities are used.
Then a trigger could run a check to see if the numbers in the keypad code integer match the correct keypad code.

My question is how would I do that? I can't seem to figure it out using basic GUI triggers.

I wouldnt create an integer variable, i would do an array with strings. First, make a string variable for the entered string and set it to an empty string. Also, make a 9 array (if it is 0-9) for each button, each with the string 0,0 1, 2, 3, etc.Than, for each button, assuming the button is an actual symbol, set the string variable to ([arirthmetic] StringCodeVariable) + ((StringedCodeButtonPressed(CodeButtonPressed)) something like that, i can set it up if i wasnt on vaca :O
 
Status
Not open for further replies.
Top