simple password sequence.

OurJud
I'm using the following script for a keypad password sequence that allows three attempts. It's taken from another thread, and works up to a certain point.

You have to trigger the password entry by typing 'use keypad' - which is fine for the first time, but I would like to bypass the need for 'use keypad' every time you want to try again.

So instead of:

use keypad >> enter password >> 2635 >> Access Denied
use keypad >> enter password >> 5567 >> Access Denied
use keypad >> enter password >> 9833 >> Access Denied
fail/die/whatever

I want:

use keypad >> enter password >> 2635 >> Access Denied
enter password>> 5567 >> Access Denied
enter password>> 9833 >> Access Denied
fail/die/whatever

Silver
You would set up a command called 'enter password'.

Not sure how you'd make it so they have to use keypad the first time but they'd likely do that anyway. Forcing them to do so seems a bit anal though?

HegemonKhan
let me try to convey the conception using a computer's command line language:

echo a
echo b
echo c

outputs:
a
b
c

-------------

:loop1
echo a
echo b
echo c
goto loop1

outputs:

a
b
c
(loops~repeats)
a
b
c
(loops~repeats)
a
b
c
(and on and on forever)

------------

echo a
:loop1
echo b
echo c
goto loop1

outputs:

a
b
c
(loops~repeats)
b
c
(loops~repeats)
b
c
(and on and on forever)

-------------

echo a
echo b
:loop1
echo c
goto loop1

outputs:

a
b
c
(loops~repeats)
c
(loops~repeats)
c
(and on and on forever)

---------

now for your example of:

use keypad >> enter password >> 2635 >> Access Denied
use keypad >> enter password >> 5567 >> Access Denied
use keypad >> enter password >> 9833 >> Access Denied

echo use keypad
echo enter password
:loop1
(quest) get input
(quest) if (not result = 0000) {
-> goto loop1
(quest) } else if (result = 0000) {
-> echo The metal door opens.
(quest) }

outputs:

use keypad
enter password
_______ (awaiting input)
(if wrong password)
_______ (awaiting input again)
(if wrong password)
________ (awaiting input again)
(and on and on)
(but, if right password)
The metal door opens.

---------------------

in quest, Functions, holds the Scripts that you want to be looped, and the Function name itself (or in the GUI~Editor's Scripting: 'call function' -> add~type in your function's name) 'summons' the Function to occur.

so, using the computer's command line language:

:loop1
echo a
echo b
echo c
goto loop1

in quest, it looks like this:

(an example using the 'start' Script of the Game Object)
<game name="xxx">
-> <start type="script">
->-> function_1
-> </start>
</game>

<function name="function_1">
-> msg ("a")
-> msg ("b")
-> msg ("c")
-> function_1
</function>

---------------------

so, using the computer's command line language:

echo a
:loop1
echo b
echo c
goto loop1

in quest, it looks like this

(an example using the 'start' Script of the Game Object)
<game name="xxx">
-> <start type="script">
->-> msg ("a")
->-> function_1
-> </start>
</game>

<function name="function_1">
-> msg ("b")
-> msg ("c")
-> function_1
</function>

--------------------

so, using the computer's command line language:

echo a
echo b
:loop1
echo c
goto loop1

in quest, it looks like this

(an example using the 'start' Script of the Game Object)
<game name="xxx">
-> <start type="script">
->-> msg ("a")
->-> msg ("b")
->-> function_1
-> </start>
</game>

<function name="function_1">
-> msg ("c")
-> function_1
</function>

OurJud
Silver wrote:Not sure how you'd make it so they have to use keypad the first time but they'd likely do that anyway. Forcing them to do so seems a bit anal though?

Well, when I come to do this, it won't be a keypad at all, it will probably be a NPC asking the player a question.

Anyway, I stupidly forgot to include the code I was using, which would have made things easier for everyone concerned.

if (not HasAttribute(game, "keypadused")) {
game.keypadused = 0
}
PrintCentered ("PLEASE ENTER SECURITY CODE")
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
game.keypadused = game.keypadused+1
if (3>game.keypadused) {
PrintCentered ("ACCESS DENIED")
PrintCentered ("You notice a strange sound, like a machine being powered on.")
}
else {
PrintCentered ("ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP")
PrintCentered ("An alarm sounds. The machine gun starts up. There is no way you can escape in time.")
PrintCentered ("YOU ARE NOW DEAD")
finish
}
}
}

Silver
What I mean is the player is unlikely to know that they need to provide a password until they have spoken to the NPC or whatever anyway. The only time they might would be if they're playing the game for a second time - and they may well be grateful to avoid speaking to the NPC only to be told to do what they knew was coming anyway. I don't get the logic of forcing things to be done a certain way: especially when you're ostensibly simplifying the action.

HegemonKhan
your code, actually is nearly 'spot on', OurJud !!!!

my edited code with the comments ( '// my comments' ) in the code for you:

if (not HasAttribute(game, "keypadused")) {
game.keypadused = 0
// excellent 'checking' code segment here, advanced thinking if you understand why to do this part! (or did you just copy it from someone else, and not understanding why it is done?)
}
if (game.keypadused = 0) {
PrintCentered ("PLEASE ENTER SECURITY CODE")
}
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
// this 'game.keypadused = game.keypadused+1' can't go here, it can't go first before the 'check' (the 'if' Scrit) below
if (3 > game.keypadused) {
PrintCentered ("ACCESS DENIED")
PrintCentered ("You notice a strange sound, like a machine being powered on.")
game.keypadused = game.keypadused + 1
}
else {
PrintCentered ("ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP")
PrintCentered ("An alarm sounds. The machine gun starts up. There is no way you can escape in time.")
PrintCentered ("YOU ARE NOW DEAD")
finish
}
}
}


the code however is missing some 'finishing' checks: once you open the door, if you do it again, it'll do the entire thing again, you don't have the 'checks' of 'if door open, if door closed', but this is a bit extra for now, unless you want to add this check into it now (try to guess~do it yourself, and I'll correct you if you did it wrong).

--------

it takes quite some time to get the ordering down and the 'checking' concept down, but you're learning this very quickly! Much moreso than me, hehe!

OurJud
Alas, HK, none of that code is mine. I do say so in my OP, but it's worth mentioning again.

I understand some of it, but could never have got thee myself.

Silver wrote:What I mean is the player is unlikely to know that they need to provide a password until they have spoken to the NPC or whatever anyway. The only time they might would be if they're playing the game for a second time - and they may well be grateful to avoid speaking to the NPC only to be told to do what they knew was coming anyway. I don't get the logic of forcing things to be done a certain way: especially when you're ostensibly simplifying the action.

I think we might be thinking along different lines here, SIlver. I'm not forcing the player to do anything - in fact quite the reverse. Each time you want to try entering the passkey in the above script, you have to type 'use keypad' each time. I was trying to do away with that step and allow players to go straight into trying another code should they get it wrong. The player is free to leave the area at any time they wish, by taking any of the exits available.

As I say, though, my plan is to have this 'password' as a character's name you're asked to provide to gain access somewhere.

Silver
You could set up a command called 'type' (for example) and the game look for a value. Erm, someone more knowledgeable than me would probably have to explain although I'm sure it's touched upon in the tutorial perhaps under the 'attributes' section.

HegemonKhan
my code above will do it (I hope), see if it works. And see my previous post (with the 'echo' code stuff in it), as I try to explain it in concept. I think it's a pretty clear explanation (for once, as my posts are usually not clear at all), that you should be able to hopefully understand.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums