~ 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 ~

The Enroth diehard fan community
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  
Latest topics
» fheroes2 General Announcements
Scripting Maps Icon_minitimeby sirDranik 2024-05-24, 01:00

» The YouTube thread
Scripting Maps Icon_minitimeby DanilaRud015 2024-05-19, 06:00

» Songs of Conquest
Scripting Maps Icon_minitimeby Mefista 2024-05-16, 09:29

» ...to XP run...
Scripting Maps Icon_minitimeby CATMAN 2024-03-30, 03:16

» WARNING - The dreaded moment is here: Heroes 6 servers shutting down
Scripting Maps Icon_minitimeby Blake01 2024-03-29, 23:04

» Songs of Silence (HoMM like game)
Scripting Maps Icon_minitimeby Blake01 2024-03-27, 16:52

» Heroes Orchestra's 5th Birthday concerts with Paul Romero
Scripting Maps Icon_minitimeby rrravyn 2024-03-23, 22:45

Poll
Global announcements should be:
Everlasting, 1 for each project.
Scripting Maps Redbar110%Scripting Maps Redbar12
 0% [ 0 ]
Temporary, when there is something new to announce.
Scripting Maps Redbar11100%Scripting Maps Redbar12
 100% [ 6 ]
Holalala... No idea where the Ultimate artifact is.
Scripting Maps Redbar110%Scripting Maps Redbar12
 0% [ 0 ]
Total Votes : 6
Most Viewed Topics
H3SW: General Graphics discussion
Ragoon's Graphics For HoMM3SW
Introduce yourself
H3SW General Discussion
H3SW Map List: Work in progress
H3SW: Dwelling Development
Forum Admins Feed
The Floody Land
Enrothian Fan Art
Heroes III: The Succession Wars v0.8.1 Beta

 

 Scripting Maps

Go down 
2 posters
AuthorMessage
Orzie
Master Modder
Master Modder
Orzie


Messages : 2163
Quality Points : 843
Registration Date : 2014-12-12
Age : 32
Location : Turkey

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.

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.

________________________
Scripting Maps L18zg1M


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


Messages : 778
Quality Points : 78
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.

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

MOD EDIT: THANKS, FIXED
Back to top Go down
 
Scripting Maps
Back to top 
Page 1 of 1
 Similar topics
-
» Scripting enhancements
» [Ironfist ver 1.2] Meeting with Scripting
» Project Ironfist Scripting Examples Page
» Project Ironfist Scripting Documentation Page
» Scripting option for hero defeat/running/surrender.

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: