equal
deleted
inserted
replaced
3 = Introduction = |
3 = Introduction = |
4 |
4 |
5 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. |
5 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 |
6 |
7 To use a library you only need to add one row at the top of the script: |
7 To use a library you only need to add one row at the top of the script: |
8 <code language="lua"> |
8 <code language="lua">HedgewarsScriptLoad("Scripts/<Library Name>.lua")</code> |
9 loadfile(GetDataPath() .. "Scripts/<Library Name>.lua")() |
9 Where `<Library Name>` is replaced by the name. |
10 </code> |
10 |
11 Where <Library Name> is replaced by the name. Do not forget the "()" at the end as this initialises the file. |
11 *Note*: In old scripts, you will find this line instead: |
12 |
12 <code language="lua">loadfile(GetDataPath() .. "Scripts/<Library Name>.lua")()</code> |
|
13 This does not work with new Hedgewars versions anymore and causes the script to break. You have to replace it with `HedgewarsScriptLoad`. |
13 |
14 |
14 = Locale = |
15 = Locale = |
15 |
16 |
16 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. |
17 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. |
17 |
18 |