I'm making a sound program with game maker and I want to make a registration function... I was thinking of something along the lines of having multiple actions in one variable like so
input=1234
5678
8987
6753
3535
3535
3544
Then when you click a button it will bring up a string and if you type in one of the codes then you will be registered...
How would I achieve something like this?
input=1234
5678
8987
6753
3535
3535
3544
response=get_string("What is the code?",""

if response=input
show_message("WELL DOE YOU ARE REGISTERED!"

if !response=input
show message("Ooops you got it wrong! Try again!"

response=get_string("What is the code?",""

Regards
Toenail
<b>Answer:</b> Your code looks good as a start. To search through all of those numbers do, it will need a little change. We will use a different approach.
We need to assign each of those numbers separately, so we use an array:
input[0]="1234";
input[1]="5678";
input[2]="8987";
input[3]="6753";
input[4]="3535";
input[5]="3535";
input[6]="3544";
As you see I wrapped the numbers with " ", you didn't, but if you want to use get_string you'll have to. Otherwise the values will be defined as real values and these cannot be compared with the value given by get_string. However, this is how you would go through to check if the number is valid:
response=get_string("What is the code?",""

valid = false;
i = 0;
for(i=0; i<7; i+=1) {
if (response==input[i]) {
valid = true;
}
}
And finally, you check whether or not valid is true. If value is not true, then the number wasn't correct.
Ask anything you'd like by commenting.
Comments
Loading comments...