LuaLibraries.wiki
author Wuzzy
Wed, 11 Jul 2018 13:39:34 +0100
changeset 1443 d25ab95f2311
parent 1379 d3e693b12cb6
child 1484 278848d942ba
permissions -rw-r--r--
LuaAPI: deprecate lfCurrentHog

#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.

== Usage ==
To use a library you only need to add this function call 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 call 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]
 * [LuaLibraryParams Params]
 * [LuaLibraryTracker Tracker]
 * [LuaLibraryAnimate Animate]
 * [LuaLibraryUtils Utils]
 * [LuaLibraryTargetPractice TargetPractice]
 * [LuaLibrarySpeedShoppa SpeedShoppa]
 * [LuaLibrarySimpleMission SimpleMission]