4 = Core Lua API documentation = |
4 = Core Lua API documentation = |
5 |
5 |
6 == Introduction == |
6 == Introduction == |
7 |
7 |
8 Version 0.9.13 of Hedgewars introduced the ability to use Lua scripts to modify Hedgewars behaviour for different maps without having to recompile the whole game. The till then used triggers (only appeared in training maps) were removed. |
8 Version 0.9.13 of Hedgewars introduced the ability to use Lua scripts to modify Hedgewars behaviour for different maps without having to recompile the whole game. The till then used triggers (only appeared in training maps) were removed. |
9 f |
9 |
10 Lua is an easy to learn scripting language that’s implemented using open source libraries. If you’d like to learn more about Lua, have a look at [http://www.lua.org Lua's official homepage]. Even though its easy to learn syntax this wiki page won't explain all basics of using Lua, e.g. declaring variables or using control structures. There are tons of step-by-step tutorials and documentation available on the internet. Just throw “Lua” into your favourite search engine and give it a try. |
10 Lua is an easy to learn scripting language that’s implemented using open source libraries. If you’d like to learn more about Lua, have a look at [http://www.lua.org Lua's official homepage]. Even though its easy to learn syntax this wiki page won't explain all basics of using Lua, e.g. declaring variables or using control structures. There are tons of step-by-step tutorials and documentation available on the internet. Just throw “Lua” into your favourite search engine and give it a try. |
11 |
11 |
12 === About this wiki page === |
12 === About this wiki page === |
13 This page might become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php]. |
13 This page might become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php]. |
14 |
14 |
1065 |
1065 |
1066 In Lua missions, for *all* ammo types, the ammo count, probability, delay and number in crates is set to 0 initially. Note: This also includes skip! |
1066 In Lua missions, for *all* ammo types, the ammo count, probability, delay and number in crates is set to 0 initially. Note: This also includes skip! |
1067 |
1067 |
1068 Parameters: |
1068 Parameters: |
1069 |
1069 |
1070 * `ammoType`: Ammo type to be set |
1070 * `ammoType`: Ammo type to be set |
1071 * `count`: Initial ammo count. 9 = infinite |
1071 * `count`: Initial ammo count. 9 = infinite |
1072 * `probability`: Crate probability. Max. value is 9. 0 = never |
1072 * `probability`: Crate probability. Max. value is 9. 0 = never |
1073 * `delay`: Number of rounds this ammo is delayed |
1073 * `delay`: Number of rounds this ammo is delayed |
1074 * `numberInCrate`: Amount of ammo in a crate |
1074 * `numberInCrate`: Amount of ammo in a crate |
1075 |
1075 |
1076 Example: |
1076 Example: |
1077 |
1077 |
1078 <code language="lua"> SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players |
1078 <code language="lua"> SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players |
1079 SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade |
1079 SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade |