Menus by Dannii Willis


Section: Basic Use

"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 players, after which they 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", "text", "submenu", "rule", and "hidden-row".

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

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

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

Table of Options
title     text (some text)     submenu (a table-name)     rule (a rule)     hidden-row (a truth state)
"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     text (some text)     submenu (a table-name)     rule (a rule)     hidden-row (a truth state)
""

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

The "rule" 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 -- text or a submenu or a rule. In the event that more than one column is filled out, the game will obey the rule in preference to creating a submenu, and create a submenu in preference to displaying text.

The "hidden-row" column can be used if we want to hide a given option. To hide the menu option, we mark this column "true". If we want the option visible, we can either leave the column empty, or mark it "false".

To display our menu to the player, we can write

display the Table of Options menu with title "Instructions"

where "Table of Options" is the name of our table, and "Instructions" is the heading we'd like to appear above the menu.

Section: Optional Glulx Features

This extension offers a few additional features for Glulx projects: a popover window, and menu hyperlinks.

A popover window will temporarily hide (rather than permanently clear) the visible story text when the player opens a menu. When players exit the menu, they will be able to see their previous actions in scrollback.

The popover window feature requires the extension Flexible Windows by Jon Ingold. We will need to include Flexible Windows before Menus in our project. So long as we do this, the popover window will be used by default.

If we've included Flexible Windows but don't want the popover window, we can disable this feature as follows:

disable the popover menu window is true

Menu hyperlinks require the extension Glulx Entry Points by Emily Short, which must be included before Menus.

Menu hyperlinks are disabled by default. We can enable them as follows:

enable menu hyperlinks is true

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 Dannii Willis.
Use scoring.

Table of Options
title     text (some text)     submenu (a table-name)     rule (a rule)     hidden-row (a truth state)
"Introduction to [story title]"     "This is a simple demonstration [story genre] game."
"Settings"     --     Table of Setting Options
"About the Author"     "[story author] is too reclusive to wish to disseminate any information. Sorry."

Table of Setting Options
title     text (some text)     submenu (a table-name)     rule (a rule)     hidden-row (a truth state)
"[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.

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:
     display the Table of Options menu with title "Instructions".

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.