When Runaway begins:
say "You decide to run away.";
move player to the Living Room;
say "You run through the Living Room in the hopes of getting away from the ghost. You cross the room, reaching for the doorknob.";
move the player to the Hallway;
say "You make it to the Hallway, where you find yourself trapped, haunted by the ghost from one side and blocked by the blizzard from the other.".
How could I write this code so that the player has to press enter before some of the steps happen? For example:
You decide to run away.
[PRESS ENTER KEY]
Living Room
You run through the Living Room in the hopes of getting away from the ghost. You cross the room, reaching for the doorknob.
[PRESS ENTER KEY]
Hallway
You make it to the Hallway, where you find yourself trapped, haunted by the ghost from one side and blocked by the blizzard from the other.
Emily Shortâs âBasic Screen Effectsâ extension is built into Inform 7 and gives several different ways to do this. Include it in your source text with
If Iâm not mistaken, Basic Screen Effects has only Wait for any key and Wait for the SPACE key built in, and waiting for any other specific key would require you to modify the extension in I6? But you probably want one of those two anyway, since theyâre the conventional ones that players will expect.
You can in fact wait for other keys with the extension. If you make a reference to the chosen letter, the game will wait for a key and return its key code.
The following will wait for a key and print its code:
When play begins:
let keycode be the chosen letter;
say "The code of the pressed key is [keycode].".
With Glulx, the code for Enter is -6, so you could write:
To wait for the Enter key:
let keycode be 0;
while keycode is not -6:
let keycode be the chosen letter;
You can use the âchosen letterâ code to build a whole keypress-driven CYOA in Inform if you want. Not that many (any?) people want, and the main drawback is that the keypresses solicited this way donât go on the automatic UNDO stack.
Still, Iâve always found it easier to create menu-choice moments within a parser game using the keypress code than by going via the parser itself or using typical extensions. At least until Zarf made the UGI extension. And even then, itâs still easier for easy cases. Just more hacky, in the eyes of hacky-frowners. I ported a CYOA Apple II game I made as a kid into Inform using the keypress way. https://wadeclarke.com/ifdemos/time_warp/index.html