Official Module System Documentation: Part 01

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


Contents

[edit] What is the Module System?

The Mount&Blade Module System is a set of python scripts that lets you create and/or modify content for Mount&Blade. This is actually the system we are using for working on the content of the official version. Using the module system, you can do things like adding new troop types, new characters, new quests, new dialogs, etc., or you can edit the existing content.

It is important to note that Mount&Blade does not use Python and does not read the Module System python scripts directly. Rather, the python scripts are executed to create the text files that Mount&Blade reads.

Mount&Blade actually reads its content from text files under the Mount&Blade/Modules folder. Thus, *in theory* you can do all the modifications you'd like to do by editing these text files. (Indeed, some modders had worked out how to use these files and were able to create amazing mods by themselves.) However the text files are not really human-readable and are very impractical to work with. There are currently two options for writing new modules. The first is the official module system described in this document. The other is Effidian's unofficial editor which is currently discontinued and unusable for the current version - v.1.011, but works for older versions of M&B, such as v.7.51 .


[edit] Requirements for using the Module System

The module system consists of Python scripts, and as such, you need to have Python installed on your system to be able to work with them.

You can download Python from Python.org's download page: [1]
There are more than a few downloads on that page. However you'll only need last version of 2.*.* for Windows (current is 2.7.8), although 2.4 may also work.


After you download and install Python, you'll also need to add Python to your path enviroment variable. This is important, so try to be exact when you make these changes.

For Windows 9x systems, you can edit autoexec.bat file and add your python folder to the Path. For example if Python is installed under C:\Python27,
add the following line:

set PATH=C:\Python27;%PATH%

If you have a Windows XP, or a Windows 7 system, this operation is slightly different: Right-click on My Computer (Computer in the start menu for 7 users) select 'Properties', click on the 'Advanced' tab and then click on 'Enviroment Variables':


1. Scroll down on the 'System variables' until you find the 'Path' variable.

2. Click on the 'Edit...' button, a new window should pop up:


Scroll to the end of the 'Variable value' and add ";C:\Python27".

You may also need to find the 'PYTHONHOME' variable and add ";C:\Python27" to it's variable value also if it is not already in there.

Then click ok on the box, to save the changes to system variables.

[edit] Obtaining the Module System

The latest version of the Module System can be downloaded from the download pages here:

Mount&Blade: http://www.taleworlds.com/en/Games/MountAndBlade/Download
Mount&Blade Warband: http://www.taleworlds.com/en/Games/Warband/Download

You'll need to download the zip file for the module system and extract it (requiring a program such as WinRAR, or 7-zip). Extract the Module System wherever it is easy to locate, e.g, the Desktop or My Documents.

[edit] Module Sytem Files

Now, let's have a look at the files in the module system. When we look at the actual Python files (files that end with .py) we see that there are actually four kinds of files:

   * files that start with header_
   * files that start with process_
   * files that start with ID_
   * files that start with module_ 

The first two kinds of files are necessary for running the module system. You shouldn't modify these at all. The third kind of files (ID_) are temporary files created while building the module. You can delete them if you like and the module system will generate them again. The final kind of files (module_) are actually the files that contain the content data. These are the files you will be modifying.


[edit] Creating a new module

Before going any further, let's first create a folder for your new module. For this, we need to go to the Mount&Blade/Modules folder (by default this is at "c:/Program Files/Mount&Blade/Modules") Now, under the Modules folder there should be a folder named Native. This is, so to speak, the official module. For your own module, you must create a new folder here, and copy the files from Native to the new folder. This new folder will be your own module folder so name it as you like. For the sake of simplicity, I am assuming it is named MyNewModule

You can test if you have done this right by launching Mount&Blade. Now, Mount&Blade's launch window should show a combo box, which lets you select the module you'd like to play. Now, try selecting your new module and starting a new game. Since we copied the contents of the native folder for our new module, the game we play now will be identical to the native game.

Next, we must make the Module System use the new folder as its target. To do that, open the file module_info.py for editing (Right click on the file and select "Edit with IDLE"; or open the file with Notepad++ or your preferred text editor) and change export_dir to point to your new folder. For example, if the folder for your module is:
c:/Program Files (x86)/Mount&Blade/Modules/MyNewModule
You should change this line as follows:
export_dir = "C:/Program Files (x86)/Mount&Blade/Modules/MyNewModule/"

Now our module system setup should be ready. To try it out, remove the file conversation.txt inside our new module folder, and then double click on build_module.bat. You should see a command prompt with some output like this:


Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
 
______________________________
 
Script processing has ended.
Press any key to exit. . .

If you ran into an error, make sure you've followed all the steps of this tutorial exactly, and if you think you have, please use the Search function on the forums; chances are someone has already run into the same problem and an easy solution has already been posted.

For those who get the error "IOError: [Errno 13] Permission denied", and "Run as administrator" returns "python: can't open file 'FILE_NAME.py': [Errno 2] No such file or directory",
Do this : right click build_module.bat and choose edit, then add this line "cd /d %~dp0" under the "@echo off". Example :

@echo off
cd /d %~dp0
python process_init.py
python process_global_variables.py
...

(Tested on Win 7, May also work on other versions of Windows)


If not, congratulations! You're all set up to create your own mod with the M&B module system. Now let's move on to Part 2.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox