LuaGuide.wiki
changeset 1727 6d99747d81e3
parent 1416 ea8b1317e8f3
child 1745 6391c69a5d0a
equal deleted inserted replaced
1726:c3de0c96ce6e 1727:6d99747d81e3
    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.
    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 
    14 
    15 Now, Lua scripts are used for:
    15 Now, Lua scripts are used for:
    16 
    16 
    17  * [Missions], one of three types:
    17  * [Missions], one of three types:
    18     * Training: Easy missions which explain the game, like a tutorial
    18   * Training: Easy missions which explain the game, like a tutorial
    19     * Challenge: Missions in which the goal is to reach a high score
    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
    20   * Scenario: Missions with a pre-set goal, like collecting a crate or killing all enemies
    21  * Mission maps (e.g. TrophyRace)
    21  * Mission maps (e.g. TrophyRace)
    22  * Styles (e.g. Highlander, Balanced Random Weapon)
    22  * Styles (e.g. Highlander, Balanced Random Weapon)
    23  * Campaigns
    23  * Campaigns
    24 
    24 
    25 == The basic structure ==
    25 == The basic structure ==
    26 
    26 
    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.
    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.
    28 
    28 
    29  * If you want to make a mission for singleplayer then you create a new `.lua` in one of three directories, depending on the type:
    29  * If you want to make a mission for singleplayer then you create a new `.lua` in one of three directories, depending on the type:
    30      * Training: `Data/Missions/Training`
    30   * Training: `Data/Missions/Training`
    31      * Challenge: `Data/Missions/Challenge`
    31   * Challenge: `Data/Missions/Challenge`
    32      * Scenario: `Data/Missions/Scenario`
    32   * Scenario: `Data/Missions/Scenario`
    33  * 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.
    33  * 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.
    34  * If you want to make a custom game style, create a new `.lua` file in `Data/Scripts/Multiplayer`.
    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>`.
    35  * Campaign missions go into `Data/Missions/Campaign/<CAMPAIGN NAME>`.
    36 
    36 
    37 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:
   134 
   134 
   135 A good way to learn Lua scripting in Hedgewars is to read existing scripts. We recommend to take a look into `Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua` which is the Lua script for the Sniper Rifle target practice training mission. It should give you a rough “feeling” of how a script is supposed to look and is heavily commented.
   135 A good way to learn Lua scripting in Hedgewars is to read existing scripts. We recommend to take a look into `Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua` which is the Lua script for the Sniper Rifle target practice training mission. It should give you a rough “feeling” of how a script is supposed to look and is heavily commented.
   136 
   136 
   137 Continue with the following pages to learn more:
   137 Continue with the following pages to learn more:
   138 
   138 
   139    * [LuaAPI] contains a reference of most available functions and global variables
   139  * [LuaAPI] contains a reference of most available functions and global variables
   140    * [Missions] for a more in-depth guide on how to create missions
   140  * [Missions] for a more in-depth guide on how to create missions
   141    * [LuaLibraries] contains information about “libraries”, that is, extra scripts you can include for even more functions. One common library is `Locale` for making a mission translatable
   141  * [LuaLibraries] contains information about “libraries”, that is, extra scripts you can include for even more functions. One common library is `Locale` for making a mission translatable
   142    * [GearTypes] contains the list of all gear types, along with an explanation of how the gears and their values work
   142  * [GearTypes] contains the list of all gear types, along with an explanation of how the gears and their values work