~ Forums of Enroth ~

An Enroth diehard fan community
 
HomeHome  ChatChat  FAQFAQ  SearchSearch  RegisterRegister  Log inLog in  

Share | 
 

 Scripting Maps

View previous topic View next topic Go down 
AuthorMessage
Orzie
Master Modder
Master Modder
avatar

Messages : 1607
Quality Points : 675
Registration Date : 2014-12-12
Age : 26
Location : Tomsk, Russia

PostSubject: Scripting Maps   2015-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.

Code:

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

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

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.

________________________
In case someone cares for my music:
Mylinks_profile_page


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

Messages : 344
Quality Points : 40
Registration Date : 2015-09-06

PostSubject: Re: Scripting Maps   2015-09-25, 06:12

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

http://lua-users.org/wiki/ForTutorial

MOD EDIT: THANKS, FIXED
Back to top Go down
 
Scripting Maps
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Maps from the Files
» Ferraris maps of Belgium
» Scratchbuild your own Kriegsspiel- ready maps for no cost
» More Austro-Hungarian maps, integrated with modern mapping applications
» Historical maps Czech Republic

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: