LuaGuide.wiki
changeset 1414 a76bfb278ad9
parent 901 8e65ab2cd36d
child 1415 36f16bdf8440
equal deleted inserted replaced
1413:8832f69b198f 1414:a76bfb278ad9
     7 == What is a Lua script ==
     7 == What is a Lua script ==
     8 
     8 
     9 A Lua script is used to make the game behave different by giving the Hedgewars engine different commands. The script gets called by the engine on different events and the script tells the engine what to do.
     9 A Lua script is used to make the game behave different by giving the Hedgewars engine different commands. The script gets called by the engine on different events and the script tells the engine what to do.
    10 Lua is a programming language, and you must first learn some basics about the Lua programming language to get started. See [http://www.lua.org/] to learn more.
    10 Lua is a programming language, and you must first learn some basics about the Lua programming language to get started. See [http://www.lua.org/] to learn more.
    11 
    11 
       
    12 == Lua in Hedgewars ==
       
    13 Version 0.9.13 of Hedgewars introduced the ability to use Lua scripts to modify Hedgewars behaviour for different maps. The use of Lua scripts has been extended since then.
       
    14 
       
    15 Now, Lua scripts are used for:
       
    16 
       
    17 * [Missions], one of three types:
       
    18     * Training: Easy missions which explain the game, like a tutorial
       
    19     * Challenge: Missions in which the goal is to reach a high score
       
    20     * Scenario: Missions with a pre-set goal, like collecting a crate or killing all enemies
       
    21 * Mission maps (e.g. TrophyRace)
       
    22 * Styles (e.g. Highlander, Balanced Random Weapon)
       
    23 * Campaigns
       
    24 
    12 == The basic structure ==
    25 == The basic structure ==
    13 
    26 
    14 Dependent on what type of script you want to write the requirements are a bit different, but before we go into that we must first create the `.lua` file. The location of the file depends on the script type.
    27 Dependent on what type of script you want to write the requirements are a bit different, but before we go into that we must first create the `.lua` file. The location of the file depends on the script type.
    15 
    28 
    16    * If you want to make a mission for multi player you create a map and create a new file `map.lua` in the map's folder.
    29  * If you want to make a mission for multi player (also called a “mission map”) you create a map and create a new file `map.lua` in the map's folder.
    17    * If you want to make a training mission then you create a new `.lua` file under `Data/Missions/Training` folder.
    30  * If you want to make a mission then you create a new `.lua` in one of three directories, depending on the type:
    18    * Campaign missions go into `Data/Missions/Campaign/<CAMPAIGN NAME>`.
    31      * Training: `Data/Missions/Training`
    19    * If you want to make a custom game style like Highlander, create a new `.lua` file in `Data/Scripts/Multiplayer`.
    32      * Challenge: `Data/Missions/Challenge`
       
    33      * Scenario: `Data/Missions/Scenario`
       
    34  * If you want to make a custom game style, create a new `.lua` file in `Data/Scripts/Multiplayer`.
       
    35  * Campaign missions go into `Data/Missions/Campaign/<CAMPAIGN NAME>`.
    20 
    36 
    21 To get started, a `.lua` file should generally be structured like this:
    37 To get started, a `.lua` file should generally be structured like this:
    22 {{{
    38 {{{
    23 function onGameInit()
    39 function onGameInit()
    24 end
    40 end