Menus by Emily Short

Extension built in to Inform


"Menus" provides a table-based way to display menus to the player. The menu takes over the main screen of the game and prevents parser input while it is active.

"Menus" is not suitable for contexts where we want the player to be able to choose a numbered option during regular play (such as a menu of conversation choices when talking to another character). It is intended rather for situations where we wish to give the player optional instructions or hints separated from the main game.

Any given menu option may do one (and only one) of the following three things:

1) display some text to the player, after which he can press a key to return to the menu. This tends to be useful for such menu options as "About this Game" and "Credits", where we have a few paragraphs of information that we would like to share.

2) trigger a secondary menu with additional options. The player may navigate this submenu, then return to the main menu. Submenus may be nested.

3) carry out a rule. This might perform any action, including making changes to the game state.

Menus are specified by tables, in which each row contains one of the menu options, together with instructions to Inform about how to behave when that option is selected.

Each menu table should have columns called "title", "subtable", "description", and "toggle".

"Title" should be the name of the option we want the player to see: "Credits", "Hints", "About This Game", and so on.

"Description" is the text that will be printed when the option is selected. We can fill it in with as much information as we like.

"Subtable" is used to create a submenu; this column holds the name of the table that specifies the menu. For instance:

Table of Options
title     subtable     description     toggle
...
"Settings"     Table of Setting Options     --     --

would create an option entitled "Settings", which the player could select to view a submenu of setting options. That submenu would in turn need its own table, thus

Table of Setting Options
title     subtable     description     toggle
...

If we do not want a given option to trigger a new submenu, we should leave it as "--".

The "toggle" column contains the rule carried out when this option is chosen. In theory, this rule could be absolutely anything. In practice, the feature is mostly useful for giving the player a table of setting options which he can toggle on and off: for instance, we might provide the option "use verbose room descriptions", and then have the toggle rule change the game's internal settings about how room descriptions are displayed. (See the example attached for further guidance.)

It is only useful for a given option to have one of these three features -- a description or a subtable or a toggle element. In the event that more than one column is filled out, the game will obey the toggle rule in preference to creating a submenu, and create a submenu in preference to displaying description text.

Example: * Tabulation - A simple table of hints and help (see also Basic Help Menu).

For instance our Table of Options might look like this:

"Tabulation" by Secretive J.

Include Menus by Emily Short.

Table of Options
title     subtable (table name)     description     toggle
"Introduction to [story title]"     --     "This is a simple demonstration [story genre] game."     a rule
"Settings"     Table of Setting Options     --     --
"About the Author"     --     "[story author] is too reclusive to wish to disseminate any information. Sorry."     --
"Hints"     Table of Hints     --     --

Table of Setting Options
title     subtable (table name)     description     toggle
"[if notify mode is on]Score notification on[otherwise]Score notification off[end if]"     --     --     switch notification status rule

To decide whether notify mode is on:
     (- notify_mode -);

This is the switch notification status rule:
     if notify mode is on, try switching score notification off;
     otherwise try switching score notification on.

Table of Hints
title     subtable     description     toggle
"How do I reach the mastodon's jawbone?"     Table of Mastodon Hints     ""     hint toggle rule
"How can I make Leaky leave me alone?"     Table of Leaky Hints     ""     hint toggle rule

Table of Mastodon Hints
hint     used
"Have you tried Dr. Seaton's Patent Arm-Lengthening Medication?"     a number
"It's in the pantry."
"Under some cloths."

Table of Leaky Hints
hint     used
"Perhaps it would help if you knew something about Leaky's personality."
"Have you read the phrenology text in the library?"
"Have you found Dr. Seaton's plaster phrenology head?"
"Now you just need a way to compare this to Leaky's skull."
"Too bad he won't sit still."
"But he has been wearing a hat. Perhaps you could do something with that."
"You'll need to get it off his head first."
"Have you found the fishing pole?"
"And the wire?"
"Wait on the balcony until Leaky passes by underneath on his way to the Greenhouse."
"FISH FOR THE HAT WITH THE HOOK ON THE WIRE."
"Now you'll have to find out what the hat tells you."
"Putting it on the phrenology head might allow you to compare."
"Of course, if you do that, you'll reshape the felt. Hope you saved a game!"
"You need a way to preserve the stiffness of the hat."
"Have you found the plaster of paris?"
"And the water?"
"And the kettle?"

Understand "help" or "hint" or "hints" or "about" or "info" as asking for help.

Asking for help is an action out of world.

Carry out asking for help:
     now the current menu is the Table of Options;
     carry out the displaying activity;
     clear the screen;
     try looking.

The Cranial Capacity Calculation Chamber is a room. Leaky is a man in the Chamber. Leaky wears a pair of overalls and some muddy boots. He is carrying a fishing rod.

The displaying activity displays whatever is set as the current menu, so we must set the current menu before activating the activity. Afterward it is a good idea to clear the screen before returning to regular play.