Password with unlimited tries
docacappella
15 Jun 2014, 09:11I'm having trouble creating the following in my game:
A keypad requires a password to unlock it. If the player enters the wrong password, I would like the keypad to ask again immediately, without the player having to look at the keypad all over again. I assume this is some sort of loop, but I am unsure how to create it. I would like the player to have unlimited tries at unlocking the keypad, because this game is for novice players.
I don't have a code to show you my progress, because I am legitimately stuck. Please help.
Thanks
A keypad requires a password to unlock it. If the player enters the wrong password, I would like the keypad to ask again immediately, without the player having to look at the keypad all over again. I assume this is some sort of loop, but I am unsure how to create it. I would like the player to have unlimited tries at unlocking the keypad, because this game is for novice players.
I don't have a code to show you my progress, because I am legitimately stuck. Please help.
Thanks
HegemonKhan
15 Jun 2014, 10:04create a function, put your entire script block in it, and under the script for when you get it wrong, use~add the 'call function' Script, and type in the name of your function (this will do the function over again, aka 'looping' it).
an example (in code, as it's easier and faster for me):
------
there's also:
invoke (Object.Script_Attribute)
but functions are better as they allow for parameters (which you'll use later as you learn more).
an example (in code, as it's easier and faster for me):
<object name="pass_code_box">
<inherit name="editor_object" />
<attr name="input_pass_code_buttons" type="script">
input_pass_code_buttons_function // calls the function ( 'call function' script )
</attr>
<attr name="displayverbs" type="listextend">input_pass_code_buttons</attr>
</object>
<function name="input_pass_code_buttons_function">
msg ("What is the pass code?")
get input {
if (result = "6392") {
// open and~or unlock door scripts
msg ("The door opens, you inputted the correct pass code")
ClearScreen
} else {
msg ("wrong pass code, try again")
ClearScreen
input_pass_code_buttons_function // calls the function ( 'call function' script), thus 'looping' the function, if you put in the incorrect input
}
}
</function>
------
there's also:
invoke (Object.Script_Attribute)
<object name="pass_code_box">
<inherit name="editor_object" />
<attr name="input_pass_code_buttons" type="script">
msg ("What is the pass code?")
get input {
if (result = "6392") {
// open and~or unlock door scripts
msg ("The door opens, you inputted the correct pass code")
ClearScreen
} else {
msg ("wrong pass code, try again")
ClearScreen
invoke (pass_code_box.input_pass_code_buttons) // calls (invokes) the script, thus 'looping' the script, if you put in the incorrect input
}
}
</attr>
<attr name="displayverbs" type="listextend">input_pass_code_buttons</attr>
</object>
but functions are better as they allow for parameters (which you'll use later as you learn more).
docacappella
16 Jun 2014, 01:38Thank you!

Pertex
16 Jun 2014, 10:59docacappella wrote: If the player enters the wrong password, I would like the keypad to ask again immediately, without the player having to look at the keypad all over again. I assume this is some sort of loop,
Is this really a good idea? If the palyer doesn't know the code or maybe he forget it, then you have an infinite loop