# MENU library integer MENU_RESPONSE integer MENU_IN_LOOP integer MENU_COUNT 0 string_array MENU_OPTIONS 10 integer MENU_MODAL # CAN BE SET TO TRUE OR FALSE integer MENU_MODE MENU_PROXY # CAN BE SET TO ONE OF: constant MENU_PROXY 0 constant MENU_EXECUTE 1 # SET TO TRUE TO DISPLAY THE COMMAND WHILE IN PROXY MODE integer MENU_DISPLAY_COMMAND true grammar $integer >menu_number {+menu_number # THIS FUNCTION IS CALLED WHEN THE PLAYER TYPES AN IN-GAME COMMAND THAT # CONTAINS ONLY AN INTEGER if MENU_COUNT = 0 write "There is no menu currently active.^" set time = false return endif if $integer < 1 : $integer > MENU_COUNT if MENU_COUNT = 1 write "The only available choice is 1.^" return else write "Please choose a number between 1 and " MENU_COUNT .^ return endif endif if MENU_MODE = MENU_EXECUTE execute MENU_OPTIONS[$integer] else if MENU_DISPLAY_COMMAND = true write "] " style input write MENU_OPTIONS[$integer] ^ style normal endif proxy MENU_OPTIONS[$integer] endif execute +menu_clear_options } {+menu_clear_options # THE FUNCTION CLEARS ALL THE CURRENT OPTIONS FROM THE MENU set MENU_COUNT = 0 } {+menu_add_option # THIS FUNCTION ADDS A NEW OPTION TO THE MENU # IT ACCEPTS: MENU_COUNT write "Please choose a number between 1 and " MENU_COUNT .^ else if MENU_MODE = MENU_EXECUTE execute MENU_OPTIONS[MENU_RESPONSE] else if MENU_DISPLAY_COMMAND = true write "] " style input write MENU_OPTIONS[MENU_RESPONSE] ^ style normal endif proxy MENU_OPTIONS[MENU_RESPONSE] endif endif until MENU_IN_LOOP = false }