Heroes 5 Wiki

The purpose of this article is to explain how to use LUA scripts in Heroes 5.

Notation[1][]

The following notation is used in this article

  • n is a number
  • s - string
  • sp - string representing the path to the game resource
  • f - function
  • void - function that does not return value
  • v - variable of arbitrary type
  • t -  table / array
  • ts - table of strings;
  • tn or an - table of numbers.

Constants[]

In theory all LUA constants are defined in "data.pak/types.xml". Unfortunately in practice not all constants in "types.xml" match the one in LUA.

H5 LUA runtime environments[]

Heroes V engine has three main LUA environments. One for each game mode:

  1. Adventure mode[2] - runs while player on adventure map
  2. Combat mode - runs while player is on combat map
  3. Town mode - runs while player is in town

Environment functions and runtime is owned only by the environment itself so no functions or data can be exchanged between them. To be precise the following statements are true:

  • Functions available in Adventure mode[2] are not available in Combat and Town mode.
  • Functions available in Combat mode are not available in Adventure and Town mode.
  • Functions available in Town mode are not available in Adventure and Combat mode.

However there are a few common functions[3] that exist in all three environments.

Reference list[]