One of the first things I want to do with my game is create a basic Start Menu for players. I have already figured out a basic intro with a “When Play Begins; say “Disclaimer Here”” but I’d like to have their be an option for the player to start a new game, load an old game, and quit the game. Don’t need to actually be able to save the game right now. Just start and quit it.
I’ve revisited a very old extension called StartEnd MenuPages by Shadowchaser, which is where I originally learned how to do this kind of thing. I pulled out the meat and updated it for current Inform.
Here’s demo code:
Include Basic Screen Effects by Emily Short. When play begins: while 1 is 1: clear the screen; clear only status line; say paragraph break; say line break; say "GAME TITLE"; say paragraph break; say "START QUOTATION."; say paragraph break; say "Please choose one of the following options:"; say paragraph break; say fixed letter spacing; say "Start the game : (SPACE)[line break]"; say "Restore a saved game : R[line break]"; say "Quit : Q"; say variable letter spacing; say paragraph break; say "START FOOTER TEXT."; say paragraph break; let k be 0; while k is 0: let k be the chosen letter; say "DEBUG: k is [k]."; if k is 32: clear the screen; make no decision; otherwise if k is 113 or k is 81: say "QUIT TEXT. You've just quit the game. Bye."; stop game abruptly; otherwise if k is 82 or k is 114: follow the restore the game rule; Art Gallery is a room. The description is "A gallery full of paintings."
If you want to add more options, it’s pretty easy. You just have to intercept the keypresses for new options down in the ‘if k is (blah blah)’ section.
How can you find out what value k is for certain keys? Leave in the DEBUG line and press that key.
Note - if you’re polling for a letter key, you must check k for both the upper case and lower case value of the letter. You’ll see two examples of that in the code for the Q and R keys, where two values of k are watched for in each case. To find your upper and lower case values… leave the DEBUG in and press your chosen letter with your caps lock on, then with it off.