I want to make an IF with a door (password panel) which asks for a password, how would I get the prompt to ask the player for a password?
I know for a fact there is nothing in the manuals about it but I know of some IF with passwords, so I know it can be done but how?
After the prompt I know how to write the rest of the code.
Could anyone assist?
Here’s a first cut at this:
Section 1 - Password-protected doors
A password-protected door is a kind of door.
It has a truth state called password given. Password given of a password-protected door is usually false.
It has a text called password. The password of a password-protected door is usually "password".
[TODO: make all flavor text configurable on a per-door basis.]
Asking password is a truth state that varies.
Asking door is a password-protected door that varies.
To ask the password of (PPD - password-protected door):
now asking door is PPD;
now asking password is true;
now the command prompt is "Password>".
To stop asking the password:
now the command prompt is ">";
now asking password is false.
Instead of opening a password-protected door (called PPD) when password given of PPD is false:
say "A computerized voice emanates from the door: 'Please state the password.'";
ask the password of PPD.
After reading a command when asking password is true:
If the player's command matches the text "[the password of the asking door]":
say "'Correct. Access authorized.' The door slides open.";
now password given of the asking door is true;
now the asking door is open;
otherwise:
say "'Incorrect. Access denied.'";
stop asking the password;
reject the player's command.
Section 2 - The Vault
The vault door is a password-protected door. It is north of a room called Outside Vault. It is south of a room called Vault.
The password of the vault door is "legolasrulz".
Test me with "n / 123 / n / legolasrulz / n / close door / s".
This works really well, thanks!
Only, by change flavour text to per-door basis you are referring to the "A computerized voice emanates from the door: “Please state the password.” lines? If so I’m sure I can figure those out…
Thanks for the help!
Yeah. I was referring to the request for a password, the password prompt, the correct password response, and the incorrect password response. All of those could be text properties of the password-protected door kind that specific doors could override. The code that says those literal texts would be changed to say “[the password request text of PPD]”, “[the prompt of PPD]”, “[the password success text of the asking door]”, and “[the password failure text of the asking door]” (or whatever you name those properties).