Variables

From Mount&Blade Modding Wiki
Revision as of 09:31, 30 July 2011 by Swyter (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A brief description of variables used in the Module System as quoted from Caba`drin's <An Introduction to Module System Syntax and Usage>.

Contents

[edit] Local Variables

Local variables - ":variable" - variables declared with a : are local variables.
They only exist in the current tuple (code block) and cannot be referenced in other code blocks unless passed as script parameters. One should initialize them (to 0 or another suitable value) before they are used as they main contain a value already. They are enclosed with quotations " ". Ex: ":agent_id"

[edit] Global Variables

Global variables - "$variable" - variables declared with a $ are global variables.
They are available to be referenced in any part of the code, from any module_*, once they are defined. Their default value is 0. They are enclosed in quotations " ". Ex: "$g_talk_troop"

[edit] Registers

Registers - reg(#) OR reg# - are variables used by the engine to store bits of information temporarily.
They are global in scope, but may be accessed by a variety of different scripts for their duration and are then left for another bit of code to use them. In header_common, registers reg0 to reg65 are declared.

Detailed article here: Register

[edit] Strings

Strings - s# - are specific 'registers' used to hold a string, rather than an integer.
Strings not declared in module_strings (quick strings) begin with the @ symbol. In header_common strings s0 to s67 are declared.

Detailed article here: String

[edit] Positions

Positions - pos# - Unlike the previous two "registers", positions store more than one piece of information; each position stores X, Y, Z coordinates as well as rotations on each X, Y, and Z axis. In header_common positions pos0 to pos64 are declared, with pos64 beginning an unspecified range of positions used by siege towers (belfries).

[edit] Constants

Constants - constant - are constants that are declared in module_constants, maintain the numerical value assigned there, and cannot be altered save through editing module_constants. They can be called from any module_* file and any tuple. Constants are not enclosed with quotations.

[edit] Remarks

Local and global variables, as well as registers, are declared with the (assign, <variable_name>, <variable_value>), operation. The variable value field can be another variable name. Strings and positions have their own unique operations, as defined in header_operations

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox