0% found this document useful (0 votes)
3 views

scripting

The document is a Scripting Guide for Heroes of Might and Magic V, aimed at helping users create and manage scripts for their maps. It covers various aspects of scripting, including functions, variables, triggers, and syntax, while providing practical examples and debugging tips. The guide serves as a supplementary resource to the official editor documentation and encourages community support for script development.

Uploaded by

TuanHung
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

scripting

The document is a Scripting Guide for Heroes of Might and Magic V, aimed at helping users create and manage scripts for their maps. It covers various aspects of scripting, including functions, variables, triggers, and syntax, while providing practical examples and debugging tips. The guide serves as a supplementary resource to the official editor documentation and encourages community support for script development.

Uploaded by

TuanHung
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

The Basics of Heroes V Scripting

Version 1.0 © Celestial Heavens, 2007.

This Scripting Guide was written for Celestial Heavens by

Pitsu

Proofreading and constructive criticism by


Grumpy Old Wizard, Gaidal Cain and Robenhagen

Layout
Robenhagen

If you have feedback, questions or comments, please contact us at:


[email protected]

or post at the relevant topic on The Heroes Round Table:


http://www.celestialheavens.com/forums/viewforum.php?f=8
Foreword

Scripting your maps is a way to make them more interesting, per- writing: the syntax, how to build a function and set triggers prop-
sonal and control the game course better. The Heroes of Might erly. But even with this guide and other materials at hand, be
and Magic V Editor (game patch . or later required) allows you ready to lose some nerves when doing you first scripts? Luckily on
to build such scripts. In your game folder you even have docu- online forums other people can help you in your darkest hours.
mentations for editor handling and the script commands. Yet, it I must admit that without people asking for help and without
is easy to get lost when opening the script editor window and see- other mapmakers demonstrating their neat solutions, this piece
ing the blank white page. What and how do write in there? of manual would not have been written. My thanks to all the
This little pdf is meant as a supplementary material for the regulars of the Round Table Mapmaking Guild!
official editor documentations. It does not describe all the indi- Oh, and an important warning before you start to work with
vidual commands for instance, since they already are quite well scripts: be aware that Heroes V scripts works only on single player
covered in official materials. It is just about the trivial of SCRIPT maps!

Wishing you good luck with scripts,


Pitsu
Table of Contents
1. Script file layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2. Functions ........................................................ 3
2.1. Defining functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2. If … then, while … do etc. blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3. How many “end”s does there have to be? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4. Function fname() or function fname(parameter) . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4.1. Function fname(hero_name) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.5. Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3. Variables ......................................................... 5
3.1. Variable types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.1. Global variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.2. Local variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.3. Game variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4. Triggers .......................................................... 6
4.1. Instant triggering of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.2. Binding functions to map events and objects . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.3. Triggering fname(parameter) type of functions . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.4. Removing a trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

5. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.1. Are empty lines, semicolons and number of spaces important? . . . . . . . . . . . . 8
5.2. Case sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.3. Quotation marks and their use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.3.1. USE NO QUOTES WHEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.3.2. USE QUOTES WHEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.4. How to refer text message files, map objects and heroes . . . . . . . . . . . . . . . . . 9
5.5. Meaning of some symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6. Hints for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11


6.1. Enabling console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.2. Using the print command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.3. My script does not run! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Script File Layout
1. Script File Layout advised to split one script into several functions just for better
SCRIPT FILE LAYOUT

overview of the different parts of the script.


When you create a new map and open its script file (Script tab · triggers – defines when a function(script or part of script) is
under Map Properties) you’ll see only a blank white sheet. When triggered
you open a heavily scripted map script file you’ll see quite a mess · commands – commands that are NOT a part of any function
of text. Is there any particular layout to follow? The answer is no, are triggered when the map is started and the script file is read the
no particular layout has to be followed. first time. That is the early morning of day  week  month .
· comments – comments are ignored by the game and are
Thus, depending on the style of the script writer, script file can meant for script writer only. In case you are afraid of forgetting
have the following things in chaotic or well-organized mess: the meaning of the script, add a comment to it. Comments
start with double minus (double hyphen) -- and end with a
· functions – groups of commands which will be the main line break. Adding double minus in front of a command is
part of the script file. Each script that you want your map to a simple way to test how your script runs without that line.
have, gives you one or more functions. Simpler scripts need Sometimes this is useful for hunting bugs.
one function, more complicated may need many. Often it is
FUNCTIONS

Example
VARIABLES
TRIGGERS

Note the text color code. It helps a bit to avoid spelling and other mistakes. When it is green (comment), you can write anything, it
is ignored by the game. When it is blue, it is a number or has a certain meaning for lua programming language. When it is red, it is a
properly spelled Heroes V specific command. Text between quotation marks (parameter names) is orange. The rest is black.
SYNTAX
DEBUGGING

2
Functions
2. Functions if boolean test then

SCRIPT FILE LAYOUT


commands;
2.1. Defining functions else
commands;
Functions are the main part of a script file. They consist of com- end;
mands that you can find in one of the official pdfs. Simpler func-
tions look like: while boolean test do
commands;
function give_it_a_nice_name() end;
commands_of_your_choice ;
end; for variable name = start_value, end_value do
commands;
end;
More complicated functions can have different blocks. For in-
stance: repeat
commands;

FUNCTIONS
function give_it_a_nice_name() until boolean test
commands_that_run_every_time_when_the_
function_is_triggered ;
if boolean_test then
commands_that_run_only_if_boolean_test_ 2.3. How many “end”s does there have to be?
returns_true ;
end; An “end” is required for each “block” that is started with:
again_commands_that_run_every_time_when_the_
function_is_triggered ; · function
end; · if … then

VARIABLES
· if … then … else
· while … do
You can have blocks within other blocks: · for … do

function function_name() Everything that is between an above listed command and respec-
commands_that_run_always_when_the_ tive “end” statements forms a block and are run together or none
function_is_triggered ; is run. See examples under general description of functions.
if boolean_test then
commands_that_run_only_if_boolean_test_ One block that does not require “end” is:
returns_true ;

TRIGGERS
if boolean_test2 then repeat
commands_that_run_only_if_boolean_test_and_ commands;
boolean_ test2_BOTH_return_true ; until boolean test;
end;
end;
end; 2.4. Function fname() or
function fname(parameter)
NOTE: Clicking on the script editor <Check> button gives you Imagine situation where you have several objects which trigger
SYNTAX

an ERROR “function xxx not defined” for every function. This is similar scripts. For example several towns that upon capture are
meant only to confuse and scare you … Ignore it. converted to another town type. You could write a separate script
for each town, but you can use the possibility to write a general
2.2. If … then, while … do etc. blocks function and specify the town that has to be changed in the trig-
ger. For that is the possibility to define variables in parenthesis
The basic most common types of blocks are briefly described be- after function name. You can have more than one such variable
low. But in fact lua, the language that Heroes  uses, is more power- there, separated by commas, if needed.
ful than that, but in order to learn other possibilities of the same
DEBUGGING

commands, head over to any lua manual (http:www.lua.org/pil/). Example

if boolean_test then The general function looks like:


commands; function transform(townname)
end; TransformTown(townname, TOWN_ACADEMY);
end;

3
Functions
2.5. Threads
SCRIPT FILE LAYOUT A

When calling it up, you can specify the variable “townname”.


Lets say the town names are town and town. When you trigger Threads are similar to continuous events in Heroes IV. They can
this function by kick in at any time and they happily use up your CPU resources.
A thread, once triggered, can run forever and in parallel to other
transform(“town1”); functions. For becoming a successful thread a function must have
the following structure:
then variable townname is given value “town” and the original
function is understood as: function funcname()
while boolean test do
function transform() commands;
TransformTown(“town1”, TOWN_ACADEMY); sleep(10);
end; end;
end;

transform(“town2”); -- would result the very same


original function read as: As long as the boolean test returns true, commands are run. Most
FUNCTIONS

function transform() often you do need the opposite: commands are hold back until a
TransformTown(“town2”, TOWN_ACADEMY); certain requirement is fulfilled. For that use the following:
end;
function funcname()
In the following example “townname” variable is not used for while boolean test do
anything. The variable is defined, but always town is converted. if boolean test2 then
Thus “function transform()” is more appropriate to use than commands;
“function transform(townname)”. end;
sleep(10);
Bad example end;
VARIABLES

end;
function transform(townname)
TransformTown(“town2”, TOWN_ACADEMY); If you have problems defining the first boolean test which deter-
end; mines how long the thread lives, give it eternal life with “while 
do”. Official maps use this statement quite often.
... Function fname(hero_name)
Heroes have a special relationship with functionname(parameter) sleep() – why that? This is to save your CPU. If you forget it or
type of functions. Namely, one does not need to specify the hero misplace it so that it is not effective, you force the thread to run
to which the generic function applies. If not specified, the cur- without pauses, causing game lags. The higher the number the
rently selected hero, who triggered the script is chosen. more time you give for other processes.  is a good value, but
TRIGGERS

anything between  and  is quite normal in my opinion. You


Example can experiment with other values at your wish.

function message2(lollu) -- without defining Triggering threads goes via startThread(functionname) com-
the parameter here, HasArtefact returns an error mand. Triggering them in other ways basically blocks access to
if HasArtefact(lollu, 2) then -- tests whether other scripts as long as the (infinite) thread runs.
selected hero has artifact number 2
SetRegionBlocked(“passage”,0,3); Example script: You want a script that gives the player an instant
end; win when he accumulates . gold.
SYNTAX

end;
function checkgold()
while 1 do
This function can be called up without specifying the hero name if GetPlayerResources(PLAYER_1, 6) >= 100000
like : then
win();
message2(); end;
sleep(10);
DEBUGGING

or end;
end;
Trigger(REGION_ENTER_WITHOUT_STOP_TRIGGER,
“area1”,“message2”); startThread(checkgold);

See also “Triggering fname(parameter) type of functions” chap-


ter.

4
Variables
3. Variables ... Local variables

SCRIPT FILE LAYOUT


Local variables are meant to work only within the function where
A variable can have different values while the script is run. Do they are defined. There are specific cases when this may be de-
not confuse variable names with function names and names of sired, but usually one does fine with global variables only.
adventure map objects, scenario objectives, file names etc. They
are used and handled differently. When in doubt whether a name Example
refers to a variable or not, check if there is a function, adventure
map object or scenario objective with this name. If not, it is most function day2()
likely a variable. local day =2; -- defines a local variable with
value 2
3.1. Variable types if GetDate(DAY)== day then -- if statement re-
turns true on second day.
There are  types of variables based on their accessibility. Local are blabla();
used inside one function only, global in an entire script file and end;
game variables for transferring variables from one script file to end;
another (in cases when a map has more than one script file). You

FUNCTIONS
can transfer the values from one type to another. For example: function day3() -- another function in the same
script file
local m = GetGameVar(“temp.gamevar1”); if GetDate(DAY) == day then -- error, since
variable “day” does not exist in
this function.
... Global variables blabla();
These are the most common ones. Usually you can live with only end;
them, without using any other type of variables. It is not a must end;
to define them prior use. The first time you use a name and give
it a value defines the variable and it can be used at any place in the

VARIABLES
script file. For keeping better track of them and avoid potential ... Game variables
errors where using a variable before giving it a value you may still Game variables are required for transporting variables between
define them at the start of a script file like shown on the image script files. For example you have a separate combat script file
on page . beside the general map scripts and you want to use the main fail
variables in combat script. Then you have to define and use game
Example variables with the following commands:

heronm = “Aberrar”; -- with this line you define SetGameVar(“variablename”, value) and
a text string type variable called GetGameVar(“variablename”)
heronm, with current value Aberrar.

TRIGGERS
SYNTAX
DEBUGGING

5
Triggers
4. Triggers
SCRIPT FILE LAYOUT A

In both cases only the latter would work, since it overwrites the
first. Luckily you can do an intermediate function that triggers as
Another very important part of a script is to set the triggers so many other functions as you wish.
that each function is run at the moment when you wish it. You
can call a function up instantly by using its name or you can Example
define the conditions when a function has to run by the Trigger
command. Trigger(NEW_DAY_TRIGGER, “days”);

4.1. Instant triggering of functions function days()


day1();
First, a function can be called up within other function or as day2();
a map starting event. That goes simply by typing the function end;
name.
function day1();
Example commands;
end;
FUNCTIONS

function blabla()
MessageBox(“Maps/SingleMissions/test/blah.txt”); function day2();
end; commands;
end;
function day2()
if GetDate(DAY)== 2 then Of course different objects can have the same type triggers with-
blabla(); -- here function blabla is triggered out problems and the same object can have different type of trig-
and the messagebox is shown at day 2. gers without problems.
end;
end; 4.3. Triggering fname(parameter)
VARIABLES

type of functions
4.2. Binding functions What if the function has some parameter that you need to
specify? As explained above, in cases where the parameter refers to
to map events and objects currently selected hero, there is no complication. In other cases,
How do define that a function has to run when a certain event avoid using parameters for parameters (long way) or use different
happens on your map? That is what you have the Trigger com- sets of quotation marks
mand for. It is quite nicely described in the official editor docu-
mentation pdfs, consult it for more information. Such triggers Example of the long way
look like:
TRIGGERS

Trigger(NEW_DAY_TRIGGER, “transform1”);
Trigger(EVENT _TYPE, “object to which the event
is bound”, “function name that has to be function transform1();
triggered”); transform(“town1”);
end;
When the Trigger command is not a part of a function, the func-
tion specified among its parameters is bound to the specified function transform(townname)
event at the start of the map. Being a part of another function transformtown(townname, 2);
means that the link between specified function and event is cre- end;
SYNTAX

ated when the original function runs.

Note that only one function can be bound to each object and Example of the short way
event combination. For example you cannot trigger two func-
tions simultaneously by defining: Trigger(NEW_DAY_TRIGGER, “transform(‘town1’)”);
-- NB! Different types of quotation marks are
Trigger(OBJECT_CAPTURE_TRIGGER, “town1”, used. Check that “transform1(‘town1)” is entirely
“function1”); orange colored in your editor!
DEBUGGING

Trigger(OBJECT_CAPTURE_TRIGGER, “town1”,
“function2”); function transform(townname)
TransformTown(townname, 2);
or end;

Trigger(NEW_DAY_TRIGGER, “day1”);
Trigger(NEW_DAY_TRIGGER, “day2”);

6
Triggers
4.4. Removing a trigger

SCRIPT FILE LAYOUT


For removing a trigger use “nil” instead of any function name:

trigger(event_type, “object to which the event is


bound”, nil);

Excample script: At day  a town called town turns into Academy


and thereafter the trigger is removed.

Trigger(NEW_DAY_TRIGGER, “transform”);

function transform()
if GetDate(DAY) == 7 then
TransformTown(“town1”, 2);
Trigger(NEW_DAY_TRIGGER, nil);
end;

FUNCTIONS
end;

VARIABLES
TRIGGERS
SYNTAX
DEBUGGING

7
Syntax
5. Syntax
SCRIPT FILE LAYOUT A

· Names of local and global variables are always without quotes.


Note that “game variables” which are accessible via SetGame-
5.1 Are empty lines, semicolons Var and GetGameVar are different.
and number of spaces important? Example
Each “end;” has to have a semicolon, and, although it is not a
must, I recommended to have them in the end of each line except function transform(townname) -- townname without
the ones that start with function, if, else, while, for or repeat. quotes since it
You could write all the script in one row without changing the is a variable.
line, but for better tracking it is advised to change line after every local towntype = 2; -- defining a local vari-
individual command. able called towntype. No quotes anywhere.
Having more than one space instead of one or adding empty TransformTown(townname, towntype); -- townname
lines between two functions does not affect the script function- and towntype are both variables. The
ality. value of the first is defined when the
function is called up (see examples
5.2. Case sensitivity below), the value of the second was
FUNCTIONS

set to 2 right before.


Yes, commands as well as variables and map object names are all end;
case sensitive. Spelling mistakes are among the most common
errors when a script does not run.
... USE QUOTES WHEN
5.3. Quotation marks and their use · the name of a function, adventure map object, scenario objec-
tive etc. is a parameter for a command. For extra dummies:
Proper using of quotation marks with functions, variables and use quotes for everything that is inside parenthesis and is a
map object names is quite confusing, but it follows a system name of a function, messagetext file, hero, adventure map
nevertheless. Additionally, note that there are two types of quotes object or scenario objective.
VARIABLES

that can be used “ and ‘. Generally it does not matter which you
use as long as start and ending marks are the same. A specific case Example
is given under “Triggering funcname(parameter) type of func-
tions”. function blabla()
if GetDate(DAY)== 2 then
... USE NO QUOTES MessageBox(“Maps/SingleMissions/test/
· When declaring a function: blah.txt”); -- quotes required for the text file
name.
Example end;
end;
TRIGGERS

function blabla() -- blabla is without quotes.


MessageBox(“Maps/SingleMissions/test/blah.txt”); Trigger(NEW_DAY_TRIGGER, “blabla”); -- quotes re-
end; quired for function blabla name

· Numbers and the hard-coded “all capital letters” parameters · quotes are required when calling up or saving game variables.
(like NEW_DAY_TRIGGER or PLAYER_) are always See official manuals for examples.
without quotes. These capitalized words are actually names of
certain numbers (see official file IDs_for_scripts.pdf). Example script: you have a map with towns named (in
respective town properties window) town and town.
SYNTAX

· The function name acts as a command. Namely, each func- A (unnecessarily long, but illustrative) script that changes
tion that you write can be called up in the same way as the town to academy upon capture:
hard-coded commands.
function transform (townname) -- townname without
Example quotes since it is a variable
TransformTown(townname, TOWN_ACADEMY); -- town-
function blabla()
name is a variable name and TOWN_ACADEMY is,
MessageBox(“Maps/SingleMissions/test/blah.txt”);
well, “all capital letters” parameter.
DEBUGGING

end;
end;
function day2()
if GetDate(DAY)== 2 then
blabla(); -- no quotes around blabla.
end;
end;

8
Syntax
function town1capture() For example

SCRIPT FILE LAYOUT


transform(“town1”)); -- transform, which is the
name of another function acts MessageBox(“Maps/SingleMissions/MyMap/
as a command. It uses param- textfilename.txt”);
eter town1, which is the name -- MyMap is the name of your map
of one of the towns. -- textfilename.txt is the text file name you
end; created. (Open map properties tree and chose
resources SavesFilenames right click and
Trigger(OBJECT_CAPTURE_TRIGGER, “town1”, “add” make a new file and add message text
“town1capture”); -- town1 and town1capture are into it)
names of map object and function,
respectively. They are parameters Referring to map objects other than heroes goes like that: Select
for Trigger command and not vari- the object and hit spacebar (or open object properties tree). Find
ables, thus must have quotes. the field called “name” and type a good name there. In script you
can simply use the name and the object is found. When giving
identical name to two or more objects, you do not get an error

FUNCTIONS
message right away, but the script may crash when run.
5.4. How to refer text message files,
Referring to heroes goes via their in-game ID names. You can
map objects and heroes give them a name by yourself, but scripts do not recognize them.
For beginners it can be very hard to get the references to external Not even the standard game names are not understood.
names correctly.
Here is the list of standard names and ID names (the unbolded
Referring to text files requires full path starting from Maps direc- names):
tory.

VARIABLES
Agrael Agrael Galib Tan Laszlo Laszlo Segref Segref
Alaron Ildar Giar Giar Lethos Dalom Shadya Kelodin
Alastor Efion Gilraen Gillion Lorenzo RedHeavenHero02 Sinitar Inagost
Andreas RedHeavenHero01 Giovanni Giovanni Lucretia Tamika Sorgal Ferigl
Anwen Metlirn Glen Glen Maahir Maahir Svea Vegeyr
Biara Biara Godric Godric Maeve Maeve Talanar Nadaur
*Brand Brand Grawl Calid Marbas Marder Temkhan Timerkhan
Cyrus Cyrus Grok Grok Markal Berein Thralsai Thralsai
Deirdre Nemor Guarg Guarg Naadir Muscip Valeria RedHeavenHero03

TRIGGERS
Deleb Deleb Havez Havez Narxes Razzak Vayshan Ohtarig
Dirael Diraya Helmar Ottar Nathir Nur Vinrael Elleshar
Dougal Orrin Inga Una Nebiros Jazaz Vittorio Christian
Duncan Duncan Ingvar Ingvar Nicolai Nicolai Vladimir Pelt
Ebba Bersy Irina Ving Nur Astral Wulfstan Wulfstan
Ellaine Nathaniel Isabel Isabell Nymus Nymus Wyngaal Linaas
Erasial Erasial Jezebeth Oddrema Ornella Ornella Ylaya Shadwyn
Ergar Ergar Jhora Sufi Orson Straker Ylthin Itil
Erling Egil Karli Skeggy Ossir Ossir Yrbeth Almegir
SYNTAX

Eruina Eruina Kaspar Gles Raelag Raelag Yrwanna Urunir


Faiz Faiz King Tolghar KingTolghar Raven Effig Zehir Zehir
Findan Heam Klaus Sarge Razzak Isher Zoltan Aberrar
Freyda Axel Kythra Menel Rolf Rolf
Freyda Freyda Laszlo Mardigo Rutger Brem
DEBUGGING

Italic indicates names from the Hammers of Fate expansion pack.


(Names are from Curios cheat guide http://www.heroesofmightandmagic.com/heroes5/heroes5_cheats_names.shtml)

9
Syntax
5.5. Meaning of some symbols
SCRIPT FILE LAYOUT A

= means give value to. m =  means that henceforth AND between two boolean tests means that both tests have
variable m has value . to be true in order to proceed
== compares whether the left side is equal to the right OR between two boolean tests means that one of the tests
side. (returns true or false) has to be true in order to proceed
<= compares whether the left side is smaller than the right random(number) returns a random number between  and
side. (returns true or false) specified number. Both inclusive.
>= compares whether the left side is larger than the right mod the left-over of dividing.  mod  equals to ;
side. (returns true or false)  mod  equals .
~= compares whether the left side is NOT equal to the nil – means “false”or nil or “none”. Used for disabling.
right side. (returns true or false)
FUNCTIONS
VARIABLES
TRIGGERS
SYNTAX
DEBUGGING

10
Hints for Debugging
6. Hints for debugging

SCRIPT FILE LAYOUT


6.1. Enabling console other commands and see whether the script runs that far or the
problem occurs before.
Adding string
setvar dev_console_password = schwinge-des-todes as the last print(‘thus far the script works’);
line of autoexec.cfg file. print(variable1); -- shows the value of this
Under My Documents/My Games/Heroes of Might and variable in the console window.
Magic V/Profiles find input.cfg file and add bind show_console ‘`’
right after the line saying bind enter_pressed ‘NUM_ENTER’. 6.3. My script does not run!
In case of having Hammers of Fate expansion you need to edit
input_a1.cfg. (A different key might be needed for non-english · Enable console and read the error messages that are displayed
keyboards). there.
· Double-check spelling in the script.
In game you should now be able to enter the console by pressing `
(the key above TAB). · Double-check tiggers. Maybe the trigger is accidentally set to

FUNCTIONS
run under different conditions than you wish.
Console shows you many things about the game, including error
· Check that there are enough “end;” commands. A common
messages for faulty scripts.
problem is that the program does not understand properly
where a function ends and therefore ignores (a part of) the
6.2. Using the print command script file.
With console activated, you can track you scripts by using the · Make sure that the map is SingleMission and not MultiPlayer
print command. It prints specified message or variable into the (open the *.h5m file with zip or rar archiver and see the names
console window. You can put it pretty much anywhere between of subdirectories).

VARIABLES
TRIGGERS
SYNTAX
DEBUGGING

11

You might also like