author | Wuzzy |
Sun, 15 Jul 2018 16:55:40 +0100 | |
changeset 1477 | 73e1bbc61037 |
parent 1379 | d3e693b12cb6 |
child 1484 | 278848d942ba |
permissions | -rw-r--r-- |
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 | 3 |
= Lua libraries documentation = |
4 |
||
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 |
|
1352 | 8 |
== Usage == |
9 |
To use a library you only need to add this function call 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
|
10 |
<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
|
11 |
Where `<Library Name>` is replaced by the name. |
84
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
12 |
|
1352 | 13 |
*Note*: In ancient scripts, you might find this call instead: |
501
04b4b463bf33
Add HedgewarsScriptLoad, warn about the old and rusty loadfile function.
almikes@aol.com
parents:
500
diff
changeset
|
14 |
<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
|
15 |
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
|
16 |
|
1329
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
1234
diff
changeset
|
17 |
== List of Lua libraries == |
246
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
18 |
|
1330 | 19 |
* [LuaLibraryLocale Locale] |
1379 | 20 |
* [LuaLibraryParams Params] |
1330 | 21 |
* [LuaLibraryTracker Tracker] |
22 |
* [LuaLibraryAnimate Animate] |
|
1379 | 23 |
* [LuaLibraryUtils Utils] |
1330 | 24 |
* [LuaLibraryTargetPractice TargetPractice] |
25 |
* [LuaLibrarySpeedShoppa SpeedShoppa] |
|
26 |
* [LuaLibrarySimpleMission SimpleMission] |