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

#summary Overview of libraries for writing Lua scripts in Hedgewars

= Lua libraries documentation =

== Introduction ==
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.

To use a library you only need to add one row at the top of the script:
<code language="lua">HedgewarsScriptLoad("Scripts/<Library Name>.lua")</code>
Where `<Library Name>` is replaced by the name.

*Note*: In ancient scripts, you might find this line instead:
<code language="lua">loadfile(GetDataPath() .. "Scripts/<Library Name>.lua")()</code>
This does not work with new Hedgewars versions anymore and causes the script to break. Use `HedgewarsScriptLoad` instead.

== List of Lua libraries ==

* [LuaLibraryLocale Locale]
* [LuaLibraryUtils Utils]
* [LuaLibraryTracker Tracker]
* [LuaLibraryAnimate Animate]
* [LuaLibraryParams Params]
* [LuaLibraryTargetPractice TargetPractice]
* [LuaLibrarySpeedShoppa SpeedShoppa]
* [LuaLibrarySimpleMission SimpleMission]