LuaLibraries.wiki
author Wuzzy <almikes@aol.com>
Wed, 02 May 2018 23:47:33 +0200
changeset 1329 bd781e19a52d
parent 1234 60346a2ffb4c
child 1330 d92ed3272533
permissions -rw-r--r--
Split Lua libraries into several sub-pages
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1329
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
     1
#summary Overview of libraries for writing Lua scripts in Hedgewars
84
6fa418422e57 Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff changeset
     2
742
1ece82f7b547 LuaLibraries: Add title
Wuzzy
parents: 684
diff changeset
     3
= Lua libraries documentation =
1ece82f7b547 LuaLibraries: Add title
Wuzzy
parents: 684
diff changeset
     4
1ece82f7b547 LuaLibraries: Add title
Wuzzy
parents: 684
diff changeset
     5
== Introduction ==
1329
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
     6
Libraries in scripts in Hedgewars are Lua files that are used by many scripts to add a common function, as an example the `Locale` library that allows scripts to translate text. The variables in these files are not exposed to the script using it but all the functions can be called.
84
6fa418422e57 Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff changeset
     7
6fa418422e57 Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff changeset
     8
To use a library you only need to add one row at the top of the script:
501
04b4b463bf33 Add HedgewarsScriptLoad, warn about the old and rusty loadfile function.
almikes@aol.com
parents: 500
diff changeset
     9
<code language="lua">HedgewarsScriptLoad("Scripts/<Library Name>.lua")</code>
04b4b463bf33 Add HedgewarsScriptLoad, warn about the old and rusty loadfile function.
almikes@aol.com
parents: 500
diff changeset
    10
Where `<Library Name>` is replaced by the name.
84
6fa418422e57 Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff changeset
    11
1329
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    12
*Note*: In ancient scripts, you might find this line instead:
501
04b4b463bf33 Add HedgewarsScriptLoad, warn about the old and rusty loadfile function.
almikes@aol.com
parents: 500
diff changeset
    13
<code language="lua">loadfile(GetDataPath() .. "Scripts/<Library Name>.lua")()</code>
1329
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    14
This does not work with new Hedgewars versions anymore and causes the script to break. Use `HedgewarsScriptLoad` instead.
85
9f1d2d3db844 Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents: 84
diff changeset
    15
1329
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    16
== List of Lua libraries ==
246
7b1a6c46c3b5 Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents: 103
diff changeset
    17
1329
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    18
* [LuaLibraryLocale Locale]
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    19
* [LuaLibraryUtils Utils]
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    20
* [LuaLibraryTracker Tracker]
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    21
* [LuaLibraryAnimate Animate]
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    22
* [LuaLibraryParams Params]
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    23
* [LuaLibraryTargetPractice TargetPractice]
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    24
* [LuaLibrarySpeedShoppa SpeedShoppa]
bd781e19a52d Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents: 1234
diff changeset
    25
* [LuaLibrarySimpleMission SimpleMission]