LuaAPI: Add 0.9.24 functions
authorWuzzy
Sun, 11 Feb 2018 17:10:56 +0000
changeset 1189 e69155e475c8
parent 1188 fbcd3b2458b8
child 1190 0d33477246bc
LuaAPI: Add 0.9.24 functions
LuaAPI.wiki
--- a/LuaAPI.wiki	Sat Feb 10 16:39:18 2018 +0000
+++ b/LuaAPI.wiki	Sun Feb 11 17:10:56 2018 +0000
@@ -219,6 +219,15 @@
 === <tt>onNewTurn()</tt> ===
 This function calls at the start of every turn. You can set `ReadyTimeLeft` here to change the ready time for this turn. (See also: `Ready`)
 
+=== <tt>onEndTurn()</tt> (0.9.24) ===
+This function calls at the end of every turn. The end of a turn is defined as the point of time after the current hedgehog lost control and all the important gears are either gone or have settled.
+
+`CurrentHedgehog` holds the gear ID of the hedgehog whose turn just ended.
+
+This function is called at one of the earliest possible moment after the end of a turn. After this callback, Hedgewars then performs all the other stuff between turns. This includes things like: Applying poison or Sudden Death damage, calculating total hog damage, rising the water in Sudden Death, dropping a crate, checking victory, giving control to the next hog.
+
+Because this function is called *before* victories are checked, this is useful to set up your victory conditions here.
+
 === <tt>onSuddenDeath()</tt> (0.9.22) ===
 This function is called on the start of Sudden Death.
 
@@ -391,8 +400,13 @@
 === <tt>!SpawnHealthCrate(x, y, [, health])</tt> ===
 Spawns a health crate at the specified position. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). Set `health` for the initial health contained in the health crate. If not set, the default health (`HealthCaseAmount`) is used.
 
+=== <tt>!SpawnSupplyCrate(x, y, ammoType [, amount])</tt> (0.9.24) ===
+Spawns an ammo or utility crate at the specified position with the given ammo type and an optional amount (default: 1). The crate type is chosen automatically based on the ammo type.
+Otherwise, this function behaves like `SpawnAmmoCrate`.
+
 === <tt>!SpawnAmmoCrate(x, y, ammoType [, amount])</tt> ===
-Spawns an ammo crate at the specified position with content of ammoType (see [AmmoTypes Ammo Types]). If `ammoType` is set to `amNothing`, a random weapon (out of the available weapons from the weapon scheme) will be selected. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). The `amount` parameter specifies the amount of ammo contained in the crate. If `amount` is `nil` or `0`, the value set by `SetAmmo` is used, or if `SetAmmo` has not been used, it falls back to the weapon scheme's value. If ´amount` is equal to or greater than `100` or greater, the amount is infinite.
+Spawns an ammo crate at the specified position with content of `ammoType` (see [AmmoTypes Ammo Types]). Any `ammoType` is permitted, an ammo crate is spawned even if the ammo is normally defined as an utility.
+If `ammoType` is set to `amNothing`, a random weapon (out of the available weapons from the weapon scheme) will be selected. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). The `amount` parameter specifies the amount of ammo contained in the crate. If `amount` is `nil` or `0`, the value set by `SetAmmo` is used, or if `SetAmmo` has not been used, it falls back to the weapon scheme's value. If ´amount` is equal to or greater than `100` or greater, the amount is infinite.
 
 Note that in Lua missions, the default number of ammo in crates is 0, so it has to be set to at least 1 with `SetAmmo` first, see the example:
 
@@ -792,7 +806,12 @@
        end
     end</code>
 
+=== `HealHog(gearUid, healthBoost[, showMessage[, tint]])` (0.9.24) ===
+Convenience function to heal hedgehogs.
 
+Increases the health of the hedgehog gear with the given ID `gearUid` by `healthBoost`, displays some healing particles at the hedgehog and shows the health increae as a message. This is similar to the behavour after taking a health crate, or getting a health boost from vampirism.
+
+If `showMessage` is false, no message is shown. With `tint` you can set the RGBA color of the particles (default: `0x00FF00FF`).
 
 === <tt>!SetEffect(gearUid, effect, effectState)</tt> ===
 Sets the state for one of the effects <tt>heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen</tt> for the specified hedgehog gear.
@@ -923,7 +942,10 @@
 Sets the water level (`WaterLine`) to the specified y-coordinate.
 
 ==== <tt>!SetWind(windSpeed)</tt> ====
-Sets the current wind in the range of -100 to 100. Use together with `gfDisableWind` for full control.
+Sets the current wind in the range of -100 to 100 inclusive. Use together with `gfDisableWind` for full control.
+
+==== <tt>!GetWind()</tt> (0.9.24) ====
+Returns current wind, expressed as a floating point number between -100 to 100 inclusive. Note there may be rounding errors.
 
 ==== <tt>!SetMaxBuildDistance(distInPx)</tt> (0.9.22) ====
 Sets the maximum building distance for of girders and rubber bands in pixels to `distInPx`. If `distInPx` is `0`, the limit is disabled. If called without arguments, the distance will be reset to the default value.
@@ -1104,6 +1126,12 @@
 ==== <tt>!GetInputMask()</tt> ====
 Returns the current input mask of the player.
 
+=== `SetVampiric(bool)` (0.9.24) ===
+Toggles vampirism mode for this turn. Set `bool` to `true` to enable (same effect as if the hedgehog has used Vampirism), `false` to disable.
+
+=== `SetLaserSight(bool)` (0.9.24) ===
+Toggles laser sight for this turn. Set `bool` to `true` to enable (same effect as if the hedgehog has used Laser Sight), `false` to disable.
+
 === Randomness ===
 ==== <tt>!GetRandom(number)</tt> ====
 Returns a randomly generated number in the range of 0 to number - 1. This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games. Use `GetRandom` for anything that could impact the engine state. For example, a visual gear could simply use Lua’s `math.random`, but adding a regular gear should use `GetRandom`.
@@ -1131,6 +1159,9 @@
 --[[ Adds a new team with name “team 1”, red color (hexadecimal notation), the grave “Simple”,
 the fort “Tank” the voicepack “Default” and the flag “hedgewars”. ]]</code>
 
+==== <tt>!GetTeamName(teamIdx)</tt> (0.9.24) ====
+Returns the name of the team with the index `teamIdx`. `teamIdx` is a number between 0 and `TeamsCount-1`.
+
 ==== <tt>!DismissTeam(teamname)</tt> ====
 Removes the team with the given team name from the game.
 
@@ -1355,6 +1386,9 @@
 === `WriteLnToConsole(string)` ===
 Writes `string` to `Logs/game0.log`, found in the user data directory.
 
+=== `WriteLnToChat(string)` (0.9.24) ===
+Writes `string` into the chat.
+
 === `DumpPoint(x, y)` (0.9.23) ===
 Converts the whole numbers `x` and `y` to strings and writes them to `Logs/game0.log`, one line each.