--- a/LuaAPI.wiki Wed Apr 17 11:38:33 2019 +0100
+++ b/LuaAPI.wiki Wed Apr 17 11:44:11 2019 +0100
@@ -5,18 +5,13 @@
== Introduction ==
-Version 0.9.13 of Hedgewars introduced the ability to use Lua scripts to modify Hedgewars behaviour for different maps without having to recompile the whole game. The till then used triggers (only appeared in training maps) were removed.
-
-Lua is an easy to learn scripting language that’s implemented using open source libraries. If you’d like to learn more about Lua, have a look at [http://www.lua.org Lua's official homepage]. Even though its easy to learn syntax this wiki page won't explain all basics of using Lua, e.g. declaring variables or using control structures. There are tons of step-by-step tutorials and documentation available on the internet. Just throw “Lua” into your favourite search engine and give it a try.
-
-=== About this wiki page ===
-This page might become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php].
+This page is the API reference for the Lua scripts in Hedgewars and contains all Lua functions, variables and features that Hedgewars supports. For a detailed introduction, see [LuaGuide].
<wiki:toc max_depth="4" />
== Overview ==
=== How Hedgewars handles Lua scripts ===
-As of Version 0.9.20, Hedgewars supports Lua scripts for two similar tasks: Define tutorial missions, campaign missions or provide special map behaviour for precreated maps. It is also used for multiplayer scripts to create new game styles.
+Hedgewars supports Lua scripts for two similar tasks: Define tutorial missions, campaign missions or provide special map behaviour for precreated maps. It is also used for multiplayer scripts to create new game styles.
=== Tutorial missions ===
Tutorial missions are located within text files inside `share/hedgewars/Data/Missions/Training`. The game will list all files with the lua extension inside this directory in the Training selection screen. You’ll find some premade example scripts within this directory that contain several comments on the script lines and what they do.
@@ -31,7 +26,6 @@
=== How Lua scripts are used ===
Several parts of script files are executed multiple times. In general, the whole script file is read while loading the map. Declarations as well as function calls outside functions are executed at once. Later on the game will call special predefined function names at special occassions such as the creation of new game objects (called “gears”).
-
=== Important things to know ===
It is possible to play missions in multiplayer. However this requires all participating players to have the exact same version of the map files, including the `map.lua` script file. If this isn’t the case the game will probably desync and “kick” at least the one player using a different version of the map files. To avoid problems when running prepackaged maps, you should never modify any maps provided with the Hedgewars default package. Instead, create a copy of the existing map and modify this one. Feel free to share your work on the forums.
@@ -39,7 +33,6 @@
=== Global variables/constants ===
Global variables are used by the game to interact with the scripts by passing and retrieving their values. While some of the variables are never read by the engine some allow you to modify the engine’s behaviour, e.g. the theme to be used for the current map.
-
=== Functions called by the game: Event handlers ===
After successfully loading the Lua script the game will call the following functions on different occasions. To be used, they have to use the exact same name as defined below.
@@ -70,7 +63,7 @@
== Globally available variables and constants ==
-The following variables are made available by Hedgewars in Lua and can be used to quickly query a value. Lua scripts schould normally *not* write to these variables, only read from them.
+The following variables are made available by Hedgewars in Lua and can be used to quickly query a value. Lua scripts should *not* write to these variables, only read from them.
=== General variables and constants ===
Here are some unsorted variables or constants which are available in Lua. *Consider these variables to be read-only.*
@@ -1776,3 +1769,6 @@
`success` is either one of `TEST_SUCCESSFUL` to report a successful test or `TEST_FAILED` for a failed test.
See [EngineTestCases] to learn more about testing the engine.
+
+== Undocumented functions ==
+This page might become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php].
\ No newline at end of file