Official Module System Documentation: Part 09

From Mount&Blade Modding Wiki
Jump to: navigation, search


The next module file we will pay attention to is module_game_menus.py. This file contains all game menus in M&B. Game menus serve as an intermediary between encountering a party and jumping to a scene, though they are flexible enough to have many other uses. The in-game Passage system also uses game menus for part of its functionality.


9.1 -- Breakdown of Module_Game_Menus

The file begins with its Python list, then lists two menus used in character creation, notably the selection of the player's gender and selection of the player's character class. These can be fairly complicated, so we'll skip ahead to a simpler one to use for an example.

Example of a game menu:

   (
   "salt_mine",mnf_auto_enter,
   "You enter the salt mine.",
   "none",
   [(reset_price_rates,0),(set_price_rate_for_item,"itm_salt",55)],
   [
     ("enter",[],"Enter.",[[set_jump_mission,"mt_visit_town_horseback"],[jump_to_scene,"scn_salt_mine"],[change_screen_mission]]),
     ("leave",[],"Leave.",[[leave_encounter],[change_screen_return]]),
   ]
 ),


This menu handles your entry into the salt mine. It is fairly straightforward, set apart only by its flag mnf_auto_enter.
Any menu with this flag will automatically activate the first menu option for which all conditions are met, without waiting for player input. In the salt mine's case, this is the menu option "enter".


Breakdown of the tuple fields:

  1. Game-menu id. Used for referencing game-menus in other files.
  2. Game-menu flags.
  3. Game-menu text. This is the text the player will see in the menu window.
  4. mesh-name. This is not currently used in the module system, must be the string "none".
  5. Operations block. A list of operations that is executed when the game menu is activated. This must be a valid operations block.
  6. List of Menu options. Each menu-option record is a tuple that contains the following fields:
  • 6.1) Menu-option-id. Used for referencing game-menu options in other files.
  • 6.2) Conditions block. All conditions are executed for each menu option to decide whether or not the option will be shown to the player. This must be a valid operation block.
  • 6.3) Menu-option text. The actual clickable text of the menu option. Substituting an underscore (_) for menu text in this field is an easy trick to make an option unclickable.
  • 6.4) Consequences block. Consequences are executed only for the menu option selected by the player. This must be a valid operation block.


Salt mine tuple examination:

  1. Game-menu id = "salt_mine"
  2. Game-menu flags = mnf_auto_enter
  3. Game-menu text = "You enter the salt mine."
  4. mesh-name = "none"
  5. Operations block = (reset_price_rates,0),(set_price_rate_for_item,"itm_salt",55)
  6. List of Menu options:
  • 6.1) Menu-option-id = "enter", "leave"
  • 6.2) Conditions block = Block contains no conditions.
  • 6.3) Menu-option text = "Enter.", "Leave."
  • 6.4) Consequences block= [set_jump_mission,"mt_visit_town_horseback"],[jump_to_scene,"scn_salt_mine"],[change_screen_mission], [leave_encounter],[change_screen_return]

The first thing this menu does is reset all trading price rates to normal, and then sets the price of salt to 55% of its normal value. Next, due to mnf_auto_enter, the menu will automatically select the first menu option for which all conditions are met ("enter") and execute it, thus automatically jumping the player into the salt mine without waiting for a click.

In the next segment we will use the salt mine as a template for creating a town menu of our own, which will finally make our modded town from Part 2 operational.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox