~ Forums of Enroth ~
Would you like to react to this message? Create an account in a few clicks or log in to continue.

~ Forums of Enroth ~

An Enroth diehard fan community
HomeHome  SearchSearch  RegisterRegister  Log inLog in  


 Scripting Maps

Go down 
Master Modder
Master Modder

Messages : 2054
Quality Points : 814
Registration Date : 2014-12-12
Age : 28
Location : Tomsk, Russia

Scripting Maps Empty
PostSubject: Scripting Maps   Scripting Maps Icon_minitime2015-07-21, 18:11

(This is a crosspost from the Project Ironfist wiki, see link)

(This post has an associated video tutorial. See Modding with an Iron Fist: Episode 2: Scripting)

Basics of Scripting

Every map in Project Ironfist can have an associated script file. Everything is possible with scripting, from changing player's heroes in ways you can't using only the map editor, to creating intricate quests for players to solve.

Scripting in Project Ironfist uses the Lua programming language, and is inspired by how scripting is done in Heroes V. This tutorial will show you how to get started creating basic map scripts. For general information on how to program in Lua, see the Lua tutorial, http://lua-users.org/wiki/ForTutorial See the Scripting Examples post for ideas on how to build scripts for your map, and the Scripting Documentation on the wiki for a reference on all available scripting features.

Making a Script File

After you create your map, you will need to find its filename. Go the the MAPS folder and find the corresponding file. Your script file must have that filename, plus the ".lua" suffix. For example, a map named "Sorrow's End" which uses features from the expansion will be saved in a file named "SorrowEn.MX2", and thus its corresponding script file must be named "SorrowEn.MX2.lua".

The root directory of our Project Ironfist installation should contain a "SCRIPTS" folder. If not, then create one. All script files should be placed in that folder.

An Example Script

Triggers are key to building scripts in Project Ironfist, as they allow you to attach your code to in-game events. You create new triggers by calling the Trigger function. Here's an example which causes a message box saying "Hello, world!" to appear at the start of the map.


Trigger(MAP_START, "", "say_hello");

fun say_hello()
  MessageBox("Hello, world!");

The call to Trigger takes three arguments. The first denotes which trigger we are using. We chose the MAP_START trigger, which runs at the start of the map. The second argument is the empty string, as the MAP_START trigger, like most triggers, does not use it. The third argument is the name of the function that should be called when the trigger runs, which here is the say_hello function. Put together, this will cause the say_hello function to be called when the map starts, which will display a message box.

Scripting Maps L18zg1M

Last edited by Orzie on 2015-09-25, 06:14; edited 1 time in total
Back to top Go down

Messages : 724
Quality Points : 74
Registration Date : 2015-09-06

Scripting Maps Empty
PostSubject: Re: Scripting Maps   Scripting Maps Icon_minitime2015-09-25, 06:12

The link to the Lua tutorial is broken, the dot at the end of the link must be removed.


Back to top Go down
Scripting Maps
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
~ Forums of Enroth ~ :: Modding Guild :: Heroes of Might and Magic II: Project Ironfist :: Modding and Mapmaking-
Jump to: