MenuQue Command Documentation

Table of Contents

UI Functions

Return information about the user interface. When the term "active menu" is used, it refers to the menu over which the mouse cursor is positioned when the command is called. Some functions accept an optional parameter specifying the specific menu you are interested in, assuming that menu is currently open.

Each induvidual component within a menu is called a tile. The UI functions from OBSE provide basic means of reading or changing their traits. But it can happen that multiple tiles have the same name, resulting in only one getting accessed. Other situations like needing to access the 'nth' element of a component or perform an action directly on the active component. In these cases more control is needed. All tile_XXX functions use the same core system by which a menu component is specified, meaning they all have the same range of tiles they can access. Which is pretty much anything.

Tile Functions

Here's a standard example of a tile_XXX function, keep in mind that each function may have additional parameters and different return values. This is merely to illustrate the core principles.
(return_value:any) tile_XXX componentPath:formatString menuType:int

First is the component path, with these functions it is now possible to access an induvidual element not through its exact name but by using its index. It works by substituting the name within the component path with a hash character followed by a number (e.g. name#nth). The name can be omitted to accept all components regardless of their names. And "nth" is the index of the desired component within its parent's list. The indexing starts at 1. To iterate in reverse direction (from bottom-to-top) negative values can be used.

A simple example which accesses the first child element of "background".
	tile_GetFloat "background\#1\width", 1001
	; Using a variable....
	set var to 1
	tile_GetFloat "background\"#%g\width", var, 1001
Second is with how the root of the function is determined. Usually it will be the root of the menumode specified but there are also a couple of special values to access other parts of the UI (things that aren't directly part of any menu). They are:

1: Strings, this is where the content of "strings.xml" and any XML files in "Data\Menus\Strings".
2: Active, uses the currently active tile as the root.

Examples:

	; Changes the base string used by the BreathMenu to 'Oxygen'
	tile_SetString "_breath|Oxygen", 1
	; Gets the base string used in the TrainingMenu for how many times you've trained in its raw form (without the actual numbers in it)
	tile_GetString "_timestrained", 1

	; Set the user1 value to 100 for the active element
	tile_SetFloat "user1", 2, 100
	; Get the name of the active element (equivalent to GetActiveMenuComponent)
	tile_GetName "\", 2

tile_GetFloat - returns the value of a float or boolean trait of the specified tile.
(value:float) tile_GetFloat trait:formatString menuType:int

tile_GetString - returns the value of a string trait of the specified tile.
(value:string_var) tile_GetString trait:formatString menuType:int

tile_SetFloat - sets the value of a float or boolean trait of the specified tile.
(success:bool) tile_SetFloat trait:formatString menuType:int newValue:float canCreate:bool

tile_SetString - sets the value of a string trait of the specified tile. The new value follows the trait name, separated from it by a pipe character. i.e. "elementName\traitName|newValue". (If calling from the console, replace the pipe character with the '@' character).
(success:bool) tile_SetString traitAndNewValue:formatString menuType:int canCreate:bool

tile_GetInfo - returns certain info for the specified tile.
(info:int) tile_GetInfo component:formatString menuType:int whichInfo:int

The following types of info can be retrieved:

 0: Counts number of child elements.
 1: Returns the index of the element within its parent's list.
-1: Same as above only the direction is reversed.
 2: Same as above except it only checks elements with the same name.
-2: Same as above only the direction is reversed.

tile_GetName - returns the name (or full name) for the specified tile.
(name:string_var) tile_GetName component:formatString menuType:int fullName:bool

Insert XML Functions

InsertXML - inserts an XML file or content of a string into the specified menu component. The file is relative to Data\Menus\Prefabs and should include the extension. Any top-level traits that already exist in the target component will be overwritten. Elements will not, they are always created regardless of existing elements with the same name. It is a very powerful function as it also allows you to change or override the raw content of the in-memory menu (but without modifying the xml file itself).
(success:bool) InsertXML fileOrString:formatString menuType:int whichChild:int bReverseOrder:bool

InsertXMLTemplate - inserts a template from the menu's xml in the specified component. The component path follows the template name, separated from it by a pipe character. i.e. "template_name|elementName". (If calling from the console, replace the pipe character with the '@' character). Optionally you can add the new name to the formatString (with another separator ofcourse) to give the new template instance a unique name.
(nothing) InsertXMLTemplate templateAndComponent:formatString menuType:int whichChild:int bReverse:int

Examples:

	string_var statMiscPage
	let statMiscPage := "stat_layout\stat_background\stat_p5\stat_p5_window\stat_p5_window_pane"
	; adding an extra misc stat to the menu and name it "Extra_Stat"
	InsertXMLTemplate "stat_misc_template|%z|Extra_Stat", statMiscPage, 1003
	; setting the various traits for this new misc stat
	SetMenuFloatValue "%z\Extra_Stat\listindex", statMiscPage, 1003, 4
	SetMenuStringValue "%z\Extra_Stat\user1|Special Kills", statMiscPage, 1003
	SetMenuFloatValue "%z\Extra_Stat\user2", statMiscPage, 1003, 103

Text Edit Functions

IsTextEditInUse - Several menus have a component where you can type a name for whatever product might come from that menu. This function will let you check if the user is typing or if the typing box is active.
(inUse:bool) IsTextEditInUse menuType:int

The following menus have a typing box by default but MenuQue also provide modders with a way to add custom typing boxes to any menu.

1036: RaceSex
1040: Alchemy
1041: Spellmaking
1042: Enchantment
1048: SigilStone
1051: TextEdit

GetTextEditBox - Returns the component that is currently being used for textedit.
(component:string_var) GetTextEditBox

GetTextEditString - Returns the typed text in the current or most recent textedit box. Works for both the default boxes aswell as any custom boxes.
(text:string_var) GetTextEditString

SetTextEditString - Sets the text for the current textedit box, default or custom does not matter, only that it is active. Return true if text is successfully changed
(success:bool) SetTextEditString text:formatString cursorIndex:int

Menu Functions

ShowMagicPopupMenu - shows or hides the MagicPopup menu. Needs to be called each time when a different item/spell/etc is selected in the relevant menu.
(nothing) ShowMagicPopupMenu bShow:bool

ShowLevelUpMenu - opens the levelup menu.
(nothing) ShowLevelUpMenu

ShowTrainingMenu - opens a training menu for the specified skill. Can be called during gamemode or menumode, no character needs to be involved. Can be called on a reference and use its training service (if any) instead. Use optional parameter to override the training cost calculations.
(nothing) reference.ShowTrainingMenu skillCode:int level:int cost:int

GetTrainingMenuSkill - returns the training skill used by the training menu
(trainingSkill:int) GetTrainingMenuSkill

GetTrainingMenuLevel - returns the training level used by the training menu
(trainingLevel:int) GetTrainingMenuLevel

GetTrainingMenuCost - returns the training cost used by the training menu
(trainingCost:int) GetTrainingMenuCost

ShowTextEditMenu - Opens up a basic textedit menu which is normally only used for typing the name for the custom class.
(nothing) ShowTextEditMenu promptText:formatString

ShowGenericMenu - opens the given generic menu, filepath is relative to Data\Menus\Generic\ and should include the extension. Name of the menu does not matter but the <class> trait does, it needs to be &GenericMenu;. Passing a value above 0 as the second argument will make only an element with that <id> trait close the menu when clicked. Otherwise a value of anything above 0 will close the menu. Other notes are that any element with an <id> trait that isn't -1 will close the menu when it is clicked. Use GetGenericButtonPressed to get some control over which element/button/etc. was clicked.
(nothing) ShowGenericMenu filePath:string closingID:int

Examples:

	; Open up a SkillPerk-generic menu and fill in the data. Ingame it'll 
	; look exactly the same as any other (game generated) SkillPerk menu.
	ShowGenericMenu "skill_perk.xml"
	SetMenuStringValue "user0|Menus\Class\Attributes\load_image_light_armor.dds", 1011
	SetMenuStringValue "user1|Congratulations! You've reached a unique level in light armor.", 1011
	SetMenuStringValue "user2|Ok", 1011

GetGenericButtonPressed - returns the id of the last choice made (or the last button/element clicked) in a generic menu. Works almost exactly the same as GetButtonPressed where the function will return the value only once and then return -1 until a new choice in a generic menu was made. The return value does not necessarily start at 0 or be in a sequenced order, it all depens on how each <id> trait is defined in the XML.
(buttonID:int) GetGenericButtonPressed

Examples:

	; Open up a QuestAdded (generic) menu and use its layout as a better looking choice/messagebox menu.
	short state
	short button
	if state == 0
		set state to 1
		ShowGenericMenu "quest_added.xml"
		SetMenuStringValue "user0|Quest Choice", 1011
		SetMenuStringValue "user1|The Path Splits....", 1011
		SetMenuStringValue "user2|30th of Last Seed, 3E433", 1011
		SetMenuStringValue "user3|Upon following the path to the city I noticed a sidepath. It may be a shortcut but it may also be filled with dangerous creatures and bandits....", 1011
		SetMenuStringValue "user4|Icons\Quest\icon_mages_guild.dds", 1011
		SetMenuStringValue "user5|Continue along the path", 1011
		SetMenuStringValue "user7|Explore the sidepath", 1011
		SetMenuFloatValue "user6", 1011, 2
	elseif state == 1
		; Get the player's choice
		set button to GetGenericButtonPressed
		if button == 1 ; id of the first button is 1
			; Continue along the path
			set state to 3
		elseif button == 2 ; id of the second button is 2
			; Explore the sidepath
			set state to 4
		endif
	endif
	; Open up a SkillPerk (generic) menu for Restoration (expert level)
	short state
	short button
	string_var text
	if state == 0
		set state to 1
		ShowGenericMenu "skill_perk.xml"
		set text to GetTexturePath SkillRestoration
		SetMenuStringValue "user0|%z", text, 1011
		set text to GetDescription SkillRestoration, 2
		SetMenuStringValue "user1|%z.", text, 1011
		SetMenuStringValue "user2|Ok", 1011
	elseif state == 1
		; no need to do anything choice-specific, except maybe reset state
	endif

Quest Functions

mqGetCurrentQuests - returns an array with the active quests with a matching questState. By default it will return all running quests with atleast one known log entry. Semi-Deprecated by GetCurrentQuests
(currentQuests:array) mqGetCurrentQuests questState:int

mqGetCompletedQuests - returns an array with the completed quests
(completedQuests:array) mqGetCompletedQuests

mqGetQuestCompleted - returns 1 if the specified quest is marked as 'completed'. Deprecated by IsQuestComplete
(completed:bool) mqGetQuestCompleted quest:ref

mqUncompleteQuest - removes the 'completed' flag from the specified quest. Deprecated by UncompleteQuest
(nothing) mqUncompleteQuest quest:ref

mqGetActiveQuest - gets the player's active quest, if any. Deprecated by GetActiveQuest
(quest:ref) mqGetActiveQuest

mqSetActiveQuest - sets the player's active quest, only works when the quest has atleast one known log entry. Deprecated by SetActiveQuest
(success:bool) mqSetActiveQuest quest:ref

mqGetActiveQuestTargets - returns an array with information about the current quest targets, each index holds a Stringmap that contains:

	"target" (ref): The actual quest target
	"door" (ref): The door leading to the target (if any)
(questTargets:array) mqGetActiveQuestTargets

Skill Functions

The following skill commands have been overwritten to accommodate new skills. They all have an 'F' version that accepts an avToken instead of an actor value code.

Other commands that do not affect skills themselves. They do not have an 'F' version.

* Note: does not (yet) exist and is added by MenuQue itself. Will automatically be overwritten once added to OBSE. Ofcourse they'll remain backwards compatible.

GetSkillCode - returns the code associated with the supplied avtoken.
(skillCode:int) GetSkillCode avToken:ref

GetSkillForm - returns the skill form for the given code.
(skillForm:ref) GetSkillForm skillCode:int

GetAllSkills - returns an array with codes for all skills, default and new.
(skillCodes:array) GetAllSkills

Examples:

array_var skills
array_var iter
int skillCode
int spec
int attr
ref skillForm
string_var attrName
string_var skillName
string_var skillDesc

....

let skills := GetAllSkills
ForEach iter <- skills
	let skillCode := *iter
	let skillName := ActorValueToStringC skillCode
	let spec := GetSkillSpecializationC skillCode
	let attr := GetSkillGoverningAttributeC skillCode
	let attrName := ActorValueToStringC attr
	
	let skillForm := GetSkillForm skillCode
	let skillDesc := GetDescription skillForm

	Print "Skill " + skillName + " w/ code " + $skillCode + " specialized for " + $spec + " and governed by " + attrName
	Print "Description is: " + skillDesc
Loop

Font Functions

MenuQue allows for the loading of extra fonts to be used ingame (up to a maximum of 25 extra fonts). To add a font place its two files in "Data\Fonts\Extra", each time the game starts every font in that folder will be added. Like the default fonts, the extra fonts have a unique id assigned to them, this is a number between 7 and 32 and depends on the combination of fonts that are loaded. It will remain the same for the duration of the session. Modders can request this id using GetFontLoaded and subsequently use any UI function to change an element's <font> trait to this new id.

GetFontLoaded - returns the id of the specified font. If not present return value is 0. Can also be used with the default fonts.
(fontID:int) GetFontLoaded font:formatString

Example:

	short fontID
	; get the fontID for "DarN_LG_Kingthings_Petrock_18", since it will
	; be static we only need to retrieve it once per session
	if GetGameLoaded || GetGameRestarted
		set fontID to GetFontLoaded "DarN_LG_Kingthings_Petrock_18"
		if fontID
			Print "Found %qDarN_LG_Kingthings_Petrock_18%q with ID of " + $fontID
			;font has a valid ID
			if fontID <= 5
				;font is a default one, doesn't really matter in this case
				;but it shows how it can be checked with GetFontLoaded
			endif
			SetMenuFloatValue "_myElement\_myText\font", 1004, fontID
		else
			Print "Could not find %qDarN_LG_Kingthings_Petrock_18%q"
		endif
	endif

GetLoadedFonts - returns a StringMap with all loaded fonts. There will be an element for each font, key is name of the font and value is its ID. You can filter the fonts for being a default (1) or extra font (2), when omitted the function will return all loaded fonts.
(loadedFonts:StringMap) GetLoadedFonts filter:int

Example:

	array_var fonts
	array_var it
	....
	Print "Getting all fonts...."
	let fonts := GetLoadedFonts
	ForEach it <- fonts
		Print "Found font %q" + it["Key"] + "%q with ID of " + $(it["Value"])
	Loop

Map Functions

GetWorldMapData - returns a stringmap containing data about the worldspace's map. You can pass an optional worldspace, else the current one is used. If it is parented by another worldspace then that one's data will be returned. If bFindMap is true and the used worldspace does not have a mapimage (Oblivion worlds for example) the function will fall back to whatever worldspace the mapmenu is using at that point. The stringmap contains the following keys:

(mapData:stringmap) GetWorldMapData worldspace:ref bFindMap:bool

SetWorldMapData - sets the data for the worldspace. You can pass an optional worldspace, else the current one is used. If it is parented by another worldspace then the parent's data will be returned. The function expects the same fields as what GetWorldMapData returns with the exception of the "Worldspace" field (it is ignored). By default the function always operates on the parent worldspace (if any) because the game ignores the map data if it has a parent worldspace.
(nothing) SetWorldMapData mapData:array_var worldspace:ref

GetWorldMapDoor - attempts to retrieve the door that leads to the target worldspace as used by the worldmap. When an optional worldspace is supplied it takes precedence. By default the returned door is to the can also be to a worldspace that has the same parent. To get the door to the actual target worldspace pass 1 as the first argument. It will always return the door leading to the worldspace.
(door:ref) GetWorldMapDoor bUseFinal:bool targetWorldspace:ref

Mouse Functions

GetMousePos - returns the current X or Y coordinate of the mouse cursor in menumode. Unlike GetCursorPos which can get behind when the mouse is moved at a rapid pace, this function will always return the correct position. Specify 'X' or 'Y' for the axis. Optional parameter to change the format of the returned coordinate (percentage based, resolution based or screen-size based).

Mode is 0 for a value between zero and one (this is the default). Use 1 as mode to return a value between zero and the user's resolution (width for 'X' and height for 'Y'). To return a value between zero and the UI screen-size use 2. This can be different from the user's resolution. The exact UI-screen-size depends on the resolution ratio (not the resolution itself) and it is what the <src="screen()" trait="width"> and <src="screen()" trait="height"> in the xml files refer to. For the 'Y' axis this is always 960 and for the 'X' axis this is 1280/(4/3)*<ratio>

Regardless of the mode the starting positon (0,0) is always in the upper left corner of the screen.
(position:float) GetMousePos axis:char mode:int

GetMouseImage - returns the filename used by the mouse
(image:string_var) GetMouseImage

SetMouseImage - sets the filename used by the mouse.
(nothing) SetMouseImage filename:formatString

Menu Event Handlers

Similar to the OBSE v0019 Event Handlers, a menu event handler is a user-defined function designed to respond to menu events. Rather than calling the function directly, the scripter uses SetMenuEventHandler to register it as a handler for a specific menu event. When the associated menu event occurs, MenuQue will invoke any handlers for that event, passing information about the event to the function through its arguments.

There are two types of menu events: events that involve the menu itself and events that involve a specific menu element.

Events
Name Parameters Notes
OnOpenmenuType:int
OnClosemenuType:int
OnClickmenuType:int, tile:string, id:int
OnMouseovermenuType:int, tile:string, id:int

These menu events are much milder than OBSE's game events because it happens during menumode, where fewer things are processed. With OnClick and OnMouseover you can input the specific id of the element you are interested in and if the full path of the element is desired.

It is recommended that you prefer to filter events as strictly as possible to allow MenuQue to avoid calling your handler for events you're not interested in. Further, once an event handler becomes unneeded, use RemoveMenuEventHandler to remove it; this prevents MenuQue from having to check against the defunct handler when processing events. Be aware that event handler scripts are invoked at the moment the event is registered by the game. For example, an OnOpen handler is invoked when a menu is opened (or enabled) but before it gets its content. Things like the inventory list, spell list or map markers, they are all handled after their respective OnOpen events have been invoked. But you can still modify the menu with the UI functions like normal.

SetMenuEventHandler - registers a user-defined function as a handler for the specified event. If the function script returns a value, it will be ignored. A menuFilter is always required and for events involving a menu component an idFilter can also be specified. Note that due to coding limitations you have to assign your user script to a ref variable and then use that with the function itself.
(success:bool) SetMenuEventHandler eventID:string script:ref menuFilter:int
(success:bool) SetMenuEventHandler eventID:string script:ref menuFilter:int idFilter:int

Example usage:
	scn FnOnOpen
	short menu

	begin Function { menu }
		; will be invoked when the menu is opened
		printc "MenuMode %g >> Opened", menu
		if menu == 1009 ;dialog was openened
			;do stuff
		elseif menu == 1034 ;persuasion opened
			;do other stuff
		endif
	end
	--------------
	scn FnOnClick
	short menu
	short id
	string_var tile

	begin Function { menu, tile, id }
		printc "MenuMode %g >> Clicked %g (%z)", menu, id, tile
		;do stuff
	end
	--------------
	scn FnOnClickDialogGoodbye
	short menu
	short id
	string_var tile

	begin Function { menu, tile, id }
		; this handler will only be invoked for the goodbye button in the dialog,
		; meaning the 'menu' and 'id' arguments will always be 1009 and 3 
		printc "Clicked Dialog::GoodBye"
	end
	---------------
	scn SomeQuestScript
	ref func
	begin gamemode
		if getGameRestarted
			; wanna be informed when player goes into dialog
			let func := FnOpOpen
			SetMenuEventHandler "OnOpen", func, 1009

			; wanna be informed when player clicks _anything_ in dialog
			let func := FnOnClick
			SetMenuEventHandler "OnClick", func, 1009

			; only interested in when the "goodbye" button is clicked
			let func := FnOnClickDialogGoodbye
			SetMenuEventHandler "OnClick", func, 1009, 3
		endif
	end

RemoveMenuEventHandler - removes the specified script as an event handler for the specified menu event. For OnClick and OnMouseover an optional argument can be supplied to only remove handlers that were registered with that specific id. If omitted, all menu event handlers matching the script, menu event and menu type will be removed. Returns true if at least one matching event handler was found and removed, false otherwise.
(success:bool) RemoveMenuEventHandler eventID:string script:ref menuFilter:int
(success:bool) RemoveMenuEventHandler eventID:string script:ref menuFilter:int idFilter:int

GetMenuEventType - When called from within an event handler, returns the name of the menu event currently being handled, as defined above.
(eventType:string) GetMenuEventType

Type Codes

Quest States

The states of a running quest.

Menu Types

Map Marker States

The states of a map marker. Is it visible, can it be traveled to or is it even enabled.

Map Marker Types

Note: Types starting at 13 are an unofficial standard created by Map Marker Overhaul.

Deprecated Functions

These functions should no longer be used.

Valid XHTML 1.0 Strict