Menu.input

From AGI Wiki
Revision as of 13:33, 11 April 2019 by Andrew Korson (talk | contribs) (Created page with "The '''menu.input''' command brings up the menu at the beginning of the next interpreter cycle. == Syntax == menu.input(); == Remarks == When the '''menu.input'''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The menu.input command brings up the menu at the beginning of the next interpreter cycle.

Syntax

menu.input();

Remarks

When the menu.input command executes, it first checks the value of reserved flag f14 (menu enabled); if f14 is FALSE, the command does nothing. If f14 is TRUE, menu.input sets an internal flag that tells AGI to display the menu at the start of the next interpreter cycle. (See the allow.menu command for additional information on controlling menus in later versions of AGI.)

Once the menu is displayed, the interpreter cycle is paused until the player selects an item from the menu, or presses the ESC key to exit without selecting. If a menu item was selected, its corresponding controller is added to the input queue.

The most common method used by Sierra to display the menu was to assign the ESC key to a keyboard controller, which would then call the menu.input command. However, you could just as easily assign a different key if desired.

Possible Errors

You must create and submit a menu in order for menu.input command to work. If menu.input is called before a menu has been created and submitted, AGI will access invalid data while trying to display the menu, which will most likely crash AGI.

The menu.input command should only be executed on the graphics screen. Calling this command on the text screen is possible, but menus will not display correctly. You should disable menus by setting reserved flag f14 (menu enabled) to FALSE whenever you are displaying the text screen.

Example

Code:

<syntaxhighlight lang="agi"> [ assume menu has been created submit.menu(); [ sets up the menu so it can be accessed set(f14); [ enable menu ... if(controller(c25)) [ assume c25 is assigned to the ESC key

 {
 menu.input();
 }

</syntaxhighlight>

Technical Information

Required Interpreter Version: Available in version 2.272 and above.
Byte-Code Value: 161 (0xA1 hex)

See Also

Player Input Commands
Menus in AGI
allow.menu