Skip to content
Haru edited this page Oct 19, 2016 · 1 revision

Table of Contents

Syntax

  • menu "<option_text></option_text>",<target_label></target_label>{,"<option_text></option_text>",<target_label></target_label>,...};

Description

This command will create a selectable menu for the invoking character. Only one menu can be on screen at the same time.

Depending on what the player picks from the menu, the script execution will continue from the corresponding label (it's string-label pairs, not label-string).

Options can be grouped together, separated by the character ':'.

 menu "A:B",L_Wrong,"C",L_Right;

It also sets a special temporary character variable @menu, which contains the number of option the player picked. (Numbering of options starts at 1.) This number is consistent with empty options and grouped options.

Examples

 	[[menu]] "A::B",L_Wrong,"",L_Impossible,"C",L_Right;
 L_Wrong:
 	// If they click "A" or "B" they will end up here
 	// @menu == 1 if "A"
 	// @menu == 2 will never happen because the option is empty
 	// @menu == 3 if "B"
 L_Impossible:
 	// Empty options are not displayed and therefore can't be selected
 	// this label will never be reached from the menu command
 L_Right:
 	// If they click "C" they will end up here
 	// @menu == 5

If a label is '-', the script execution will continue right after the menu command if that option is selected, this can be used to save you time, and optimize big scripts.

 	[[menu]] "A::B:",-,"C",L_Right;
 	// If they click "A" or "B" they will end up here
 	// @menu == 1 if "A"
 	// @menu == 3 if "B"
 L_Right:
 	// If they click "C" they will end up here
 	// @menu == 5

Both these examples will perform the exact same task.

If you give an empty string as a menu item, the item will not display. This can effectively be used to script dynamic menus by using empty string for entries that should be unavailable at that time.

You can do it by using arrays, but watch carefully - this trick isn't high wizardry, but minor magic at least. You can't expect to easily duplicate it until you understand how it works.

Create a temporary array of strings to contain your menu items, and populate it with the strings that should go into the menu at this execution, making sure not to leave any gaps. Normally, you do it with a loop and an extra counter, like this:

 // We loop through the list of possible menu items.
 // @i is our loop counter.
 [[for]]( [[set]] @i,0; @i&lt;[[getarraysize]](@possiblemenuitems$) (@menureference&#91;@menu&#45;1&#93;=&quot;X)&quot; equivalent.

="" ="&#10;&#10;*"></getarraysize(@possiblemenuitems$)>Menus

Category:Script Command

Clone this wiki locally