| 
View
 

Basics of Scripting

This version was saved 12 years, 11 months ago View current version     Page history
Saved by James Koppel
on August 19, 2013 at 4:50:39 am
 

This page has an associated video tutorial. See Modding with an Iron Fist: Episode 2: Scripting ( http://www.youtube.com/watch?v=fxPmLLQtqIQ )

 

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 for ideas on how to build scripts for your map, and the Scripting Documentation 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!"); 
end; 

 

The call to Trigger takes three arguments. The first denotes which trigger we are using. We chose the MAP_START triggerwhich 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.

Comments (0)

You don't have permission to comment on this page.