equal
deleted
inserted
replaced
3 = Lua libraries documentation = |
3 = Lua libraries documentation = |
4 |
4 |
5 == Introduction == |
5 == Introduction == |
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. |
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. |
7 |
7 |
8 To use a library you only need to add one row at the top of the script: |
8 == Usage == |
|
9 To use a library you only need to add this function call at the top of the script: |
9 <code language="lua">HedgewarsScriptLoad("Scripts/<Library Name>.lua")</code> |
10 <code language="lua">HedgewarsScriptLoad("Scripts/<Library Name>.lua")</code> |
10 Where `<Library Name>` is replaced by the name. |
11 Where `<Library Name>` is replaced by the name. |
11 |
12 |
12 *Note*: In ancient scripts, you might find this line instead: |
13 === Legacy `loadfile` == |
|
14 *Note*: In ancient scripts, you might find this call instead: |
13 <code language="lua">loadfile(GetDataPath() .. "Scripts/<Library Name>.lua")()</code> |
15 <code language="lua">loadfile(GetDataPath() .. "Scripts/<Library Name>.lua")()</code> |
14 This does not work with new Hedgewars versions anymore and causes the script to break. Use `HedgewarsScriptLoad` instead. |
16 This does not work with new Hedgewars versions anymore and causes the script to break. Use `HedgewarsScriptLoad` instead. |
15 |
17 |
16 == List of Lua libraries == |
18 == List of Lua libraries == |
17 |
19 |