Created wiki page through web user interface.
#summary Libraries for writing Lua scripts in Hedgewars.
= 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 lang="lua">
loadfile(GetDataPath() .. "Scripts/<Library Name>.lua")()
</code>
Where <Library Name> is replaced by the name. Do not forget the "()" at the end as this initialises the file.
= Locale =
This library allows you to translate string and should be used whenever a script has text. It loads the appropriate locale file and check automatically.
== lang(text) ==
<blockquote>
Returns the localised string of text or if it is not found it returns text.
</blockquote>