script_UpdateMenus

Menus are indexed in two ways according to their scope. Local menus are stored in a local custom property while global menus are stored in a flat global array.

command script_UpdateMenus scriptObject put the script_MenuTitleTableArray of scriptObject into mTitleTableArray set the menu_DataArray of scriptObject to mTitleTableArray -- local -- now update Global menus repeat for each key gMenuTile in mTitleTableArray if word 1 of gMenuTile = "Global" and word 2 of gMenuTile = "|" then put mTitleTableArray [gMenuTile] into gMenuTable menu_SetGlobalTable gMenuTile, gMenuTable end if end repeat return mTitleTableArray end script_UpdateMenus

The script_UpdateMenus command contains the following key handlers: * script_MenuTitleTableArray * menu_DataArray * menu_SetGlobalTable

# How it works

First the handler generates and array by parsing the script of the object:

put the script_MenuTitleTableArray of scriptObject into mTitleTableArray

Then it sets a local custom property of the object:

set the menu_DataArray of scriptObject to mTitleTableArray

Next it repeats through every Menu Title it has found and stored in the array, and if it finds a Global Menu Title it stores these separately using:

menu_SetGlobalTable gMenuTile, gMenuTable