# HG changeset patch # User Wuzzy # Date 1525439769 -3600 # Node ID 7c5c8c620a9f8b37a521abd2d0bcfeb7acf41eec # Parent 6d356877f1d2a85d1aef48805884ef256b2f9edc LuaAPI: EnableSwitchHog() diff -r 6d356877f1d2 -r 7c5c8c620a9f LuaAPI.wiki --- a/LuaAPI.wiki Thu May 03 22:19:00 2018 +0100 +++ b/LuaAPI.wiki Fri May 04 14:16:09 2018 +0100 @@ -1250,6 +1250,13 @@ ==== `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. +==== `EnableSwitchHog()` (0.9.25) ==== +Enable hog switching mode for the current hedgehog. This function should be called while the hedgehog is standing on solid ground (`GetFlightTime` returns 0). + +Internally, this tries to spawn a `gtSwitcher` gear which, as long it exists, handles the hog switching. You can delete this gear to stop the hog switching prematurely. If there already is a `gtSwitcher` gear, no additional gear is spawned. + +On success, returns the `gtSwitcher` gear being spawned or, if hog switching mode is already active, returns the exsting gear. On failure, returns `nil`. + === Randomness === ==== !GetRandom(number) ==== 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`.