LuaAPI.wiki
changeset 1804 396f8204b9fb
parent 1803 d75d30743663
child 1807 7df2a9651b29
equal deleted inserted replaced
1803:d75d30743663 1804:396f8204b9fb
     1 #summary API for writing Lua scripts in Hedgewars.
     1 #summary API for writing Lua scripts in Hedgewars
     2 #labels Featured
     2 #labels Featured
     3 
     3 
     4 = Core Lua API documentation =
     4 = Core Lua API documentation =
     5 
     5 
     6 == Introduction ==
     6 The Lua API in Hedgewars allows creating all scripted content in Hedgewars. Lua handles [Missions missions], [GameStyles styles] and more. If you want to create your own missions, this is the place to start.
     7 This page is the API reference for the Lua scripts in Hedgewars and contains all Lua functions, variables and features that Hedgewars supports. For a detailed introduction, see [LuaGuide].
       
     8 
     7 
     9 == Table of Contents ==
     8 For a introduction into scripting, read [LuaGuide].
    10 <wiki:toc max_depth="4" />
       
    11 
     9 
    12 == Overview ==
    10 == Sections ==
    13 === How Hedgewars handles Lua scripts ===
       
    14 Hedgewars supports Lua scripts for two similar tasks: Define tutorial missions, campaign missions or provide special map behaviour for precreated maps. It is also used for multiplayer scripts to create new game styles.
       
    15 
    11 
    16 === Tutorial missions ===
    12 The Lua API documentation is divided into the following sections:
    17 Tutorial missions are located within text files inside `share/hedgewars/Data/Missions/Training`. The game will list all files with the lua extension inside this directory in the Training selection screen. You’ll find some premade example scripts within this directory that contain several comments on the script lines and what they do.
       
    18 
    13 
    19 See [Missions] for details.
    14  * [LuaGuide Beginner's guide]
    20 
    15  * [LuaOverview Overview]
    21 === Special maps ===
    16  * [LuaGlobals Global variables and constants]
    22 In addition to tutorial missions predrawn maps (maps not created using the random map creator) may contain a single lua script file named `map.lua`. If it’s there, it will be used once the map is played. This way it’s possible to play maps alone or over the internet using custom goals. Mission maps can be found in singleplayer mode under the “training” button and in multiplayer mode, it is selectable as a map type.
    17  * [LuaEvents Event handlers]
    23 
    18  * [LuaGameplay Gameplay functions]
    24 See also [PresetMaps] for more information about such maps.
    19  * [LuaGears Gear functions]
    25 
    20  * [LuaStats Stats functions]
    26 === How Lua scripts are used ===
    21  * [LuaGUI GUI functions]
    27 Several parts of script files are executed multiple times. In general, the whole script file is read while loading the map. Declarations as well as function calls outside functions are executed at once. Later on the game will call special predefined function names at special occassions such as the creation of new game objects (called “gears”).
    22  * [LuaAudio Audio functions]
    28 
    23  * [LuaUtil Utility functions]
    29 === Important things to know ===
    24  * [LuaLibraries Lua libraries]
    30 It is possible to play missions in multiplayer. However this requires all participating players to have the exact same version of the map files, including the `map.lua` script file. If this isn’t the case the game will probably desync and “kick” at least the one player using a different version of the map files. To avoid problems when running prepackaged maps, you should never modify any maps provided with the Hedgewars default package. Instead, create a copy of the existing map and modify this one. Feel free to share your work on the forums.
       
    31 
       
    32 Another thing to note is the current status of our scripting implementation. Similar to the whole game, this is still work in progress and we can’t guarantee that scripts working in this version will run in future revisions of the game as we might extend, change or rename parts of the scripting engine.
       
    33 
       
    34 === Global variables/constants ===
       
    35 Global variables are used by the game to interact with the scripts by passing and retrieving their values. While some of the variables are never read by the engine some allow you to modify the engine’s behaviour, e.g. the theme to be used for the current map.
       
    36   	  	 
       
    37 === Functions called by the game: Event handlers ===
       
    38 After successfully loading the Lua script the game will call the following functions on different occasions. To be used, they have to use the exact same name as defined below.
       
    39 
       
    40 == Data types ==
       
    41 This section defines some commonly used non-primitive parameter types which are used in multiple functions. This section is a bit incomplete at the moment.
       
    42 
       
    43 === Color ===
       
    44 Some functions take a `color` parameter.
       
    45 
       
    46 Colors are stored in RGB or RGBA format and are specified as a three- or four-byte number, respecively.
       
    47 In 3-byte (RGB) colors, each byte represents a color component. The value 0 means no intensity and 255 is largest intensity of the component.
       
    48 The first byte is for the red component, the second byte for the green component and the third byte for the blue component.
       
    49 Four-byte (RGBA) colors use the first 3 bytes for the color components (like for the 3-byte colors) and the fourth byte is used for opacity, where 255 means maximum opacity and 0 means fully transparent (also called the “alpha channel”).
       
    50 
       
    51 Specifying the color number becomes much easier if you write it in hexadecimal notation.
       
    52 
       
    53 Examples for RGB (3-byte) colors:
       
    54 <code language="lua">
       
    55 c = 0x000000 -- black (R, G, B are all 0)
       
    56 c = 0xFF0000 -- red
       
    57 c = 0x00FF00 -- green
       
    58 c = 0x0000FF -- blue
       
    59 c = 0xFFFFFF -- white
       
    60 c = 0x808080 -- gray (50%)</code>
       
    61 
       
    62 Hint: On [http://www.colorpicker.com/] you find a color-picking tool for getting RGB colors easily.
       
    63 
       
    64 
       
    65 == Globally available variables and constants ==
       
    66 The following variables are made available by Hedgewars in Lua and can be used to quickly query a value. Lua scripts should *not* write to these variables, only read from them.
       
    67 
       
    68 === General variables and constants ===
       
    69 Here are some unsorted variables or constants which are available in Lua. *Consider these variables to be read-only.*
       
    70 
       
    71 || *Identifier* || *Description* ||
       
    72 || `LOCALE` || Current locale identifier (e.g. `"de"` for German) ||
       
    73 || `INTERFACE` || Type of the game interface: `"desktop"` for desktop, `"touch"` for touchscreen ||
       
    74 || `MAX_HOG_HEALTH` || Maximum possible hedgehog health ||
       
    75 || `MAX_TURN_TIME` || Maximum possible turn time in milliseconds ||
       
    76 || `LAND_WIDTH` || The width of the landscape in pixels. Not available before `onGameStart` ||
       
    77 || `LAND_HEIGHT` || The height of the landscape in pixels. Not available before `onGameStart` ||
       
    78 || `LeftX` || X coordinate of the leftmost point of the landscape. Not available before `onGameStart` ||
       
    79 || `RightX` || X coordinate of the rightmost point of the landscape. Not available before `onGameStart` ||
       
    80 || `TopY` || Y coordinate of the topmost point of the landscape. Not available before `onGameStart` ||
       
    81 || `CursorX` || The X position of the cursor if the player is choosing a target. Otherwise, this equals `NO_CURSOR` ||
       
    82 || `CursorY` || The Y position of the cursor if the player is choosing a target. Otherwise, this equals `NO_CURSOR` ||
       
    83 || `WaterLine` || The y position of the water, used to determine at which position stuff drowns. Use `SetWaterLine` to change. ||
       
    84 || `ClansCount` || Number of clans, including defeated ones (a clan is a group of teams with same color) ||
       
    85 || `TeamsCount` || Number of teams, including defeated ones ||
       
    86 || `TurnTimeLeft` || Number of game ticks (milliseconds) left until the current turn ends. To set this value, use `SetTurnTimeLeft` ||
       
    87 || `ReadyTimeLeft` || Remaining ready time in millseconds, 0 if turn in progress. To set this value, use `SetReadyTimeLeft` ||
       
    88 || `GameTime` || Number of total game ticks ||
       
    89 || `TotalRounds` || Number of rounds that have passed. Equals `-1` if game has not started yet or hogs are still being placed. ||
       
    90 || `CurrentHedgehog` || The hedgehog gear that is currently in play ||
       
    91 || `AmmoTypeMax` || Maximum ammo type ID (useful to iterate through all ammo types, starting by 0) ||
       
    92 
       
    93 === !GameFlags ===
       
    94 The !GameFlags are used to store simple boolean settings of the game.
       
    95 You can read/modify them using the [LuaAPI#GameFlags_functions GameFlags-Functions].
       
    96 
       
    97 || *Identifier* || *Description (active state)* ||
       
    98 || `gfOneClanMode` || Used when only one clan is in the game. This game flag is primarily used for training missions. ||
       
    99 || `gfMultiWeapon` || Shooting any weapon enters multi-shot mode with infinite shots. The remaining shots counter for weapons like shotgun is suppressed. Intended for target practice missions, not recommended for anything else. ||
       
   100 || `gfSwitchHog` || Free hog switching at turn start ||
       
   101 || `gfDivideTeams` || Each clan will start in its own side of the terrain. No effect if `gfPlaceHog` is active. ||
       
   102 || `gfBorder` || An indestructible border is active around the map. ||
       
   103 || `gfBottomBorder` || There is an indestructable border at the bottom of the map. ||
       
   104 || `gfShoppaBorder` || The terrain edge will be replaced by a decorative black/yellow “danger stripe”. This has no gameplay effect. ||
       
   105 || `gfSolidLand` || The terrain is indestructible. ||
       
   106 || `gfLowGravity` || The gravity is low. ||
       
   107 || `gfLaserSight` || A laser sight is almost always active. ||
       
   108 || `gfInvulnerable` || All hedgehogs are invulnerable. ||
       
   109 || `gfVampiric` || All hedgehogs become vampires and get 80% of the damage they deal as health. ||
       
   110 || `gfKarma` || Attackers share the damage they deal to enemies. ||
       
   111 || `gfArtillery` || Hedgehogs can’t walk. ||
       
   112 || `gfRandomOrder` || The game is played in random order. ||
       
   113 || `gfPlaceHog` || Placement mode: At the beginning of the round, all hedgehogs are placed manually first. ||
       
   114 || `gfKing` || King Mode: One hedgehog per team becomes their king, if the king dies, the team loses. ||
       
   115 || `gfSharedAmmo` || Teams in the same clan share their ammo. Takes precedence over `gfPerHogAmmo`.  ||
       
   116 || `gfDisableGirders` || No girders will be created in random maps ||
       
   117 || `gfDisableLandObjects` || No land objects will be created in random maps ||
       
   118 || `gfAISurvival` || Computer-controlled hedgehogs will be revived after they die. ||
       
   119 || `gfInfAttack` || Attacks don’t end the turn. ||
       
   120 || `gfResetWeps` || The weapons will be reset to the initial state each turn. ||
       
   121 || `gfPerHogAmmo` || Each hedgehog has its own weapon stash. No effect if `gfSharedAmmo` is active. ||
       
   122 || `gfDisableWind` || There is no wind. ||
       
   123 || `gfMoreWind` || There is always strong wind. ||
       
   124 || `gfTagTeam` || Tag Team: Teams in the same clan share their turn time. ||
       
   125 || `gfResetHealth` || The health of all living hedgehogs is reset at the end of each turn. ||
       
   126 
       
   127 === Land flags ===
       
   128 The land flags denote several types of terrain. Like all flags, they can be combined at will.
       
   129 
       
   130 || *Identifier* || *Meaning* ||
       
   131 || `lfIce` || Slippery terrain, hogs will slide on it. ||
       
   132 || `lfBouncy` || Bouncy terrain, hogs and some other gears will bounce off when they collide with it. ||
       
   133 || `lfIndestructible` || Almost indestructible terrain, most weapons will not destroy it. ||
       
   134 || `0` || Normal destroyable terrain. Note that this is the case when no other land flag is set. ||
       
   135 
       
   136 === More constants ===
       
   137 More constants are at at [GearTypes Gear Types] , [AmmoTypes Ammo Types], [Sounds], [States], [Sprites], [VisualGearTypes Visual Gear Types].
       
   138 
       
   139 == Event handlers ==
       
   140 Lua scripts are supposed to _define_ these functions to do something. The functions are then _called_ by Hedgewars when a certain event has occoured.
       
   141 
       
   142 === <tt>onGameInit()</tt> ===
       
   143 This function is called before the game loads its resources. One can read and modify various game variables here. These variables will become globally available after `onGameInit` has been invoked, but changing them has only an effect in `onGameInit`.
       
   144 Most variables are optional, but for missions, `Theme` must be set by the scripter if you want to use a random map, rather than an image map. All other variables do not need to be set by the scripter and have default values.
       
   145 
       
   146 List of game variables:
       
   147 || *Identifier* || *Default* || *Description* ||
       
   148 || `Theme` || _depends_ || The theme to be used. When `Map` is set, a default value is used. For missions which don't use an image map, `Theme` *must* be set explicitly ||
       
   149 || `Map` || `""` || The image map being played or `""` if no image map is used ||
       
   150 || `Seed` || `0` || Seed of the random number generator ||
       
   151 || `LandDigest` || _N/A_ || Digest for the current map. Only meant for internal use by Hedgewars ||
       
   152 || `MapGen` || `mgRandom` || Type of map generator. One of `mgRandom`, `mgMaze`, `mgPerlin`, `mgDrawn`. ||
       
   153 || `TemplateFilter` || `0` || _unknown meaning_ ||
       
   154 || `TemplateNumber` || `0` || _unknown meaning_ ||
       
   155 || `MapFeatureSize` || `50` (`12` in 1.0.0) || Used by random maps to determine its “curvyness” or complexity. This value can be set by the user with the slider under the random map preview in the game setup screen. The user-set value ranges from 1 (leftmost position) to 25 (rightmost position). A good starting value is `12`. ||
       
   156 || `GameFlags` || `0` || All `GameFlags` combined as a bitmask. Setting `GameFlags` directly is discouraged, use the [LuaAPI#GameFlags_functions] instead ||
       
   157 || `Ready` || `5000` || Ready timer at the start of the turn (in milliseconds) ||
       
   158 || `Delay` || `100` || Time the current hedgehog needs to be inactive before gear stuff gets updated in infinite attack mode, like applying hog damage and deaths. This is quite an obscure variable, only change it if you know what you're doing ||
       
   159 || `TurnTime` || `45000` || Turn time in milliseconds ||
       
   160 || `GetAwayTime` || `100` || Retreat time in percent ||
       
   161 || `CaseFreq` || `5` || Probability that a crate drops in a turn. 0: never, >0: probability = `1/CaseFreq` ||
       
   162 || `MaxCaseDrops` || `5` || Maximum number of crates that can be in the game before the random crate drops stop ||
       
   163 || `HealthCaseProb` || `35` || Chance that a crate drop is a health crate, in percent (other crates are ammo or utility crates) ||
       
   164 || `HealthCaseAmount` || `25` || Amount of health in a health crate ||
       
   165 || `DamagePercent` || `100` || Global damage in percent, affects damage and knockback ||
       
   166 || `RopePercent` || `100` || Rope length in percent ||
       
   167 || `MinesNum` || `4` || Number of mines being placed on a medium-sized map ||
       
   168 || `MinesTime` || `3000` || Time for a mine to explode from activated (in milliseconds), `-1000` for random ||
       
   169 || `MineDudPercent` || `0` || Chance of mine being a dud, in percent ||
       
   170 || `AirMinesNum` || `0` || Number of air mines being placed on a medium-sized map ||
       
   171 || `Explosives` || `2` || Number of barrels being placed on a medium-sized map ||
       
   172 || `SuddenDeathTurns` || `15` || Number of rounds until Sudden Death begins, _after the first round is over_. E.g. 0 = SD starts in 2nd round ||
       
   173 || `WaterRise` || `47` || Height of water rise in pixels for each Sudden Death turn ||
       
   174 || `HealthDecrease` || `5` || Amount of health decreased on each turn in Sudden Death ||
       
   175 || `Goals` || `""` || Use this to add additional text to the goal text popup shown at the beginning and when using the quit or pause keys. The text is added to the default text which usually explains the game modifiers and does not replace it. The text supports the same special characters as in `ShowMission` ||
       
   176 || `WorldEdge` || `weNone` || Type edges being used at the left and right sides of the terrain (see below). ||
       
   177 || `ScreenWidth` || _N/A_ || Width of the Hedgewars window or screen ||
       
   178 || `ScreenHeight` || _N/A_ || Height of the Hedgewars window or screen ||
       
   179 
       
   180 The proper way to disable Sudden Death is by setting both `WaterRise` and `HealthDecrease` to `0`.
       
   181 
       
   182 If you want to add teams or hogs manually, you have to do it here. If you want to draw your own map using `AddPoint` and `FlushPoints`, you have to do this within this function as well.
       
   183 
       
   184 ==== <tt>!WorldEdge</tt> ====
       
   185 The value of `WorldEdge` can have the following values:
       
   186 
       
   187 || *Identifier* || *Meaning* ||
       
   188 || `weNone` || No world edges ||
       
   189 || `weBounce` || Bouncy world edges ||
       
   190 || `weWrap` || World wraps around at the edges ||
       
   191 || `weSea` || Ocean world edges ||
       
   192 
       
   193 === <tt>onGameStart()</tt> ===
       
   194 This function is called when the first round starts.
       
   195 
       
   196 Can be used to show the mission and for more setup, for example initial target spawning.
       
   197 
       
   198 At this stage, the global variables `LeftX`, `RightX`, `TopY`, `LAND_WIDTH` and `LAND_HEIGHT` become available.
       
   199 
       
   200 === <tt>onPreviewInit()</tt> ===
       
   201 This function is called when the map preview in the frontend is initialized. This happens when the script is selected or you change a map generator parameter.
       
   202 
       
   203 It is useful for scripts which create their own maps (see `AddPoint` and `FlushPoints`). If you create a map in this function, a preview will be generated from this map and is exposed to the frontend.
       
   204 
       
   205 === <tt>onParameters()</tt> ===
       
   206 This function is called when the script parameters (as specified in the game scheme) become available. The script parameter string is stored in the global variable `ScriptParam`.
       
   207 
       
   208 Please note that it is normally not safe to call many of the other functions inside this function, this function is called very early in the game, only use this to initialize variables and other internal stuff like that.
       
   209 
       
   210 *Tip*: If you use the Params library  (`/Scripts/Params.lua`), you can make the task of dissecting the string into useful values a bit easier, but it’s not required. (The Params library is not documented yet, however).
       
   211 
       
   212 *Tip*: If you use this callback, make sure to document the interpretation of the parameters so others know how to set the parameters properly.
       
   213 
       
   214 === <tt>onGameTick()</tt> ===
       
   215 This function is called on every game tick, i.e. 1000 times a second. If you just need to check on something periodically, consider `onGameTick20`.
       
   216 
       
   217 === <tt>onGameTick20()</tt> ===
       
   218 This function is called every 20 game ticks, which equals 50 times a second. It reduces Lua overhead for simple monitoring that doesn’t need to happen every single tick.
       
   219 
       
   220 === <tt>onNewTurn()</tt> ===
       
   221 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`)
       
   222 
       
   223 === <tt>onCaseDrop(gear)</tt> ===
       
   224 This function calls between two turns right after the moment at which the game *might* drop a crate according to the game scheme settings. It does not matter if it actually wants to drop a crate.
       
   225 
       
   226 If a crate was dropped, `gear` is the crate gear that was dropped, if no crate was dropped, `gear` is `nil`.
       
   227 
       
   228 This function is useful to add custom crate drops as well.
       
   229 
       
   230 === <tt>onEndTurn()</tt> (0.9.24) ===
       
   231 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.
       
   232 
       
   233 `CurrentHedgehog` holds the gear ID of the hedgehog whose turn just ended.
       
   234 
       
   235 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.
       
   236 
       
   237 Because this function is called *before* victories are checked, this is useful to set up your victory conditions here.
       
   238 
       
   239 === <tt>onSkipTurn()</tt> (0.9.24) ===
       
   240 This function calls when a hog skips its turn.
       
   241 
       
   242 === <tt>onGameResult(winningClan)</tt> (0.9.25) ===
       
   243 This function calls when the game ends with a winner or in a draw. If a clan wins, `winningClan` is the clan ID of the winning clan. If the game ends in a draw, `winningClan` is set to -1.
       
   244 
       
   245 === <tt>onSuddenDeath()</tt> ===
       
   246 This function is called on the start of Sudden Death.
       
   247 
       
   248 === <tt>onGearAdd(gearUid)</tt> ===
       
   249 This function is called when a new gear is added. Useful in combination with `GetGearType(gearUid)`.
       
   250 
       
   251 === <tt>onGearDelete(gearUid)</tt> ===
       
   252 This function is called when a new gear is deleted. Useful in combination with `GetGearType(gearUid)`.
       
   253 
       
   254 === <tt>onVisualGearAdd(vgUid)</tt> (0.9.23) ===
       
   255 This function is called when a new visual gear is added. Useful in combination with `GetVisualGearType(vgUid)`.
       
   256 
       
   257 === <tt>onVisualGearDelete(vgUid)</tt> (0.9.23) ===
       
   258 This function is called when a new visual gear is deleted. Useful in combination with `GetVisualGearType(vgUid)`.
       
   259 
       
   260 === <tt>onGearDamage(gearUid, damage)</tt> ===
       
   261 This function is called when a gear is damaged.
       
   262 
       
   263 Example:
       
   264 
       
   265 <code language="lua">    function onGearDamage(gear, damage)
       
   266         if (GetGearType(gear) == gtHedgehog) then
       
   267             -- adds a message saying, e.g. "Hoggy H took 25 points of damage"
       
   268             AddCaption(GetHogName(gear) .. ' took ' .. damage .. ' points of damage')
       
   269         end
       
   270     end</code>
       
   271 === <tt>onGearResurrect(gearUid, spawnedVGear) </tt> ===
       
   272 This function is called when a gear is resurrected due to the hog effect `heResurrectable` being set (see `SetEffect`) and/or being an AI hog when the game modifier “AI Survival” (`gfAISurvival`) is active. It is *not* called when a hog was resurrected by the resurrector tool you can use in the game.
       
   273 
       
   274 `spawnedVGear` is a visual gear handle of the “resurrection effect”. You can use this handle to modify or delete the resurrection animation.
       
   275 
       
   276 === <tt>onAmmoStoreInit()</tt> ===
       
   277 This function is called when the game is initialized to request the available ammo and ammo probabilities. Use `SetAmmo` here.
       
   278 
       
   279 === <tt>onNewAmmoStore(team/clan index, hog index)</tt> ===
       
   280 This function is identical to `onAmmoStoreInit` in function, but is called once per ammo store.  This allows different ammo sets for each clan, team or hedgehog depending on the mode.
       
   281 If `gfSharedAmmo` is set, the parameters passed are the clan index, and `-1`, and the function will be called once for each clan.
       
   282 If `gfPerHogAmmo` is set, the parameters passed are the team index and the hog index in that team, and the function will be called once for each hedgehog.
       
   283 If neither is set, the parameters passed are the team index and `-1`, and the function will be called once for each team.
       
   284 
       
   285 These indexes can be used to look up details of the clan/team/hedgehog prior to gear creation. Routines to do these lookups will be created as needed.
       
   286 If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from `onAmmoStoreInit` are ignored.
       
   287 
       
   288 === <tt>onGearWaterSkip(gear)</tt> ===
       
   289 This function is called when the gear `gear` skips over water.
       
   290 
       
   291 === <tt>onScreenResize()</tt> ===
       
   292 This function is called when you resize the screen. Useful place to put a redraw function for any `vgtHealthTags` you're using.
       
   293 
       
   294 === <tt>onAttack()</tt> ===
       
   295 This function is called when your Hedgehog attacks.
       
   296 
       
   297 === <tt>onHJump()</tt> ===
       
   298 This function is called when you press the high jump key.
       
   299 
       
   300 === <tt>onLJump()</tt> ===
       
   301 This function is called when you press the long jump key.
       
   302 
       
   303 === <tt>onPrecise()</tt> ===
       
   304 This function is called when you press the precise key.
       
   305 
       
   306 === <tt>onLeft()</tt> ===
       
   307 This function is called when you press the left key.
       
   308 
       
   309 === <tt>onRight()</tt> ===
       
   310 This function is called when you press the right key.
       
   311 
       
   312 === <tt>onUp()</tt> ===
       
   313 This function is called when you press the up key.
       
   314 
       
   315 === <tt>onDown()</tt> ===
       
   316 This function is called when you press the down key.
       
   317 
       
   318 === <tt>onAttackUp()</tt> ===
       
   319 This function is called when you release the attack key.
       
   320 
       
   321 === <tt>onDownUp()</tt> ===
       
   322 This function is called when you release the down key.
       
   323  
       
   324 === <tt>onHogAttack(ammoType)</tt> ===
       
   325 This function is called when you press the attack key. Beginning with 0.9.21, the parameter `ammoType` is provided. It contains the ammo type of the weapon used for the attack. 
       
   326 
       
   327 Note: If you want to detect when a turn was skipped, use `onSkipTurn()`. There is no guarantee that `onHogAttack(amSkip)` is called in such an event.
       
   328 
       
   329 === <tt>onLeftUp()</tt> ===
       
   330 This function is called when you release the left key.
       
   331 
       
   332 === <tt>onPreciseUp()</tt> ===
       
   333 This function is called when you release the precise key.
       
   334 
       
   335 === <tt>onRightUp()</tt> ===
       
   336 This function is called when you release the right key.
       
   337 
       
   338 === <tt>onSetWeapon(msgParam)</tt> ===
       
   339 It is get called when a weapon is selected or switched.
       
   340 
       
   341 `msgParam` tells you which ammo type was selected.
       
   342 
       
   343 === <tt>onSlot(msgParam)</tt> ===
       
   344 This function is called when one of the weapon slot keys has been pressed.
       
   345 
       
   346 `msgParam` tells the slot number minus 1 (i.e. `0` is for slot number 1, `1` is for slot number 2, etc.).
       
   347 
       
   348 === <tt>onSwitch()</tt> ===
       
   349 This function is called when a hog is switched to another.
       
   350 
       
   351 === <tt>onTaunt(msgParam)</tt> ===
       
   352 This function is called when the player uses an animated emote for example by using the chat commands `/wave`, `/juggle`, etc.
       
   353 
       
   354 `msgParam` tells you which animation was played:
       
   355 
       
   356 || *`msgParam`* || *Animation* || *Associated chat command* ||
       
   357 || 0 || Rolling up || `/rollup` ||
       
   358 || 1 || Sad face || `/sad` ||
       
   359 || 2 || Waving hand || `/wave` ||
       
   360 || 3 || Stupid winner's grin / “Awesome” face || `/hurrah` ||
       
   361 || 4 || Peeing || `/ilovelotsoflemonade` ||
       
   362 || 5 || Shrug || `/shrug` ||
       
   363 || 6 || Juggling || `/juggle` ||
       
   364 
       
   365 === <tt>onTimer(msgParam)</tt> ===
       
   366 This function is called when one of the timer keys is pressed.
       
   367 
       
   368 `msgParams` tells the set timer in seconds (i.e. `3` for the 3 seconds timer key).
       
   369 
       
   370 === <tt>onUpUp()</tt> ===
       
   371 This function is called when you release the up key.
       
   372 
       
   373 === <tt>onUsedAmmo(ammoType)</tt> (0.9.23) ===
       
   374 Called after a weapon has been used completely, with `ammoType` as the used ammo type.
       
   375 
       
   376 For example, it is called right after a bazooka is fired, when both shots of a shotgun have been fired, when extra time is used, or when all 4 shots of a portable portal device have been fired. It is also called when using a multi-shot ammo has been aborted by changing the weapon selection mid-way, because this still uses up the ammo.
       
   377 
       
   378 *Warning:* In 0.9.24 or earlier, you must not manipulate any ammo within this callback, e.g. by using `AddAmmo`. The ammo storage might become garbled otherwise.
       
   379 
       
   380 === <tt>onHogHide(gearUid)</tt> ===
       
   381 This function is called when a hedgehog with the gear ID `gearUid` is hidden (removed from the map).
       
   382 
       
   383 === <tt>onHogRestore(gearUid)</tt> ===
       
   384 This function is called when a hedgehog with the specified gear ID `gearUid` is restored (unhidden).
       
   385 
       
   386 === <tt>onSpritePlacement(spriteId, centerX, centerY)</tt> ===
       
   387 This function is called when a [Sprites Sprite] has been placed.
       
   388 
       
   389 `spriteID` is the type of the sprite, you find a list at [Sprites Sprites]. `centerX` and `centerY` are the coordinates of the center of the sprite.
       
   390 
       
   391 === <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> ===
       
   392 This function is called when a girder has been placed.
       
   393 
       
   394 `frameIdx` is used for the length and orientation of the girder. The possible values are explained in `PlaceGirder`. `centerX` and `centerY` are the coordinates of the girder’s center.
       
   395 
       
   396 === <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> ===
       
   397 This function is called when a rubber has been placed.
       
   398 
       
   399 `frameIdx` is used for the rubber orientation. The possible values are explained in `PlaceRubber`. `centerX` and `centerY` are the coordinates of the rubber’s center.
       
   400 
       
   401 === <tt>onSpecialPoint(x, y, flags)</tt> ===
       
   402 This is used while a special hand-drawn map is loaded. The engine is building these hand-drawn maps by reading points from the map definition. Optionally, some of these points may be “special”. These are not actually drawn on the map, but are used to store additional information for a position on the map. Special points currently need to be added manually in the map, the in-game editor is not able to add those yet (as of 0.9.23).
       
   403 Now, when such a special point at the coordinates `x` and `y` with an assigned value of `flags` is added, this function is called. `flags` is a whole number between `0` and `255` inclusive.
       
   404 
       
   405 This function is used in Racer and !TechRacer to define waypoints.
       
   406 
       
   407 === <tt>onAchievementsDeclaration()</tt> ===
       
   408 This function is called after the stats for the stats screen (after the game) have been generated. You are supposed to call `DeclareAchievement` here.
       
   409 
       
   410 == Functions for creating gears ==
       
   411 
       
   412 === <tt>!AddGear(x, y, gearType, state, dx, dy, timer)</tt> ===
       
   413 This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]).  Gears are dynamic objects or events in the world that affect the gameplay, including hedgehogs, projectiles, weapons, land objects, active utilities and a few more esoteric things.
       
   414 The initial velocities are `dx` and `dy`. All arguments are numbers. The function returns the `uid` of the gear created. Gears can have multple states at once: `state` is a bitmask, the flag variables can be found in [States].
       
   415 
       
   416 Example:
       
   417 
       
   418 <code language="lua">    local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
       
   419     FindPlace(gear, true, 0, LAND_WIDTH)</code>
       
   420 
       
   421 === <tt>!AddVisualGear(x, y, visualGearType, state, critical [, layer])</tt> ===
       
   422 This attempts to create a new visual gear at position x,y (measured from top left) of kind `visualGearType` (see [VisualGearTypes Visual Gear Types]).  Visual gears are decorational objects which are usually used for purely decorational graphical effects.  They have no effect on gameplay.  Visual gears are not the same as gears, but they share some similarities.
       
   423 
       
   424 The function returns the `uid` of the visual gear created or `nil` if creation failed.  There is no guarantee that a visual gear will spawn.  *IMPORTANT: Do not rely on visual gears to spawn*. *Always* be prepared for this function to return `nil`.
       
   425 
       
   426 Set `critical` to `true` if the visual gear is crucial to gameplay and must always be spawned when in-game.  Use `false` if it is just an effect or eye-candy, and its creation can be skipped when in fast-forward mode (such as when joining a room).
       
   427 
       
   428 You can set an optional `layer` to specify which visual gears get drawn on top.
       
   429 
       
   430 Most visual gears delete themselves eventually.
       
   431 
       
   432 *NOTE:* Visual gears *must* only be used for decorational/informational/rendering purposes. *Never* use the visual gear's internal state to manipulate anything gameplay-related. Visual gears are not safe for reliable storage and using them as that would lead to strange bugs.
       
   433 
       
   434 *NOTE:* Since 0.9.25, visual gears will never spawn when Hedgewars is run in a testing mode (i.e. not as the real game), so don't rely for visual gears to spawn even if they're critical.
       
   435 
       
   436 Example:
       
   437 
       
   438 <code language="lua">  -- adds an non-critical explosion at position 1000,1000. Returns 0 if it was not created.
       
   439     local vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) 
       
   440 </code>
       
   441 
       
   442 === <tt>!SpawnHealthCrate(x, y, [, health])</tt> ===
       
   443 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. Do not use a negative value for `health`.
       
   444 
       
   445 === <tt>!SpawnSupplyCrate(x, y, ammoType [, amount])</tt> (0.9.24) ===
       
   446 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.
       
   447 Otherwise, this function behaves like `SpawnAmmoCrate`.
       
   448 
       
   449 === <tt>!SpawnAmmoCrate(x, y, ammoType [, amount])</tt> ===
       
   450 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.
       
   451 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 `AMMO_INFINITE`, the amount is infinite.
       
   452 
       
   453 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:
       
   454 
       
   455 Example:
       
   456 
       
   457 <code language="lua">    SetAmmo(amGrenade, 0, 0, 0, 1) -- grenade ammo crates now contain 1 grenade each
       
   458     SpawnAmmoCrate(0, 0, amGrenade) -- spawn grenade ammo crate at random position</code>
       
   459 
       
   460 === <tt>!SpawnUtilityCrate(x, y, ammoType [, amount])</tt> ===
       
   461 Spawns an utility crate with some ammo at the specified position. The function behaves almost like `SpawnAmmoCrate`, the differences are 1) the crate looks different and 2) if `ammoType` is set to `amNothing`, a random utility out of the set of available utilities from the weapon scheme is chosen as content.
       
   462 
       
   463 Example:
       
   464 
       
   465 <code language="lua">    SetAmmo(amLaserSight, 0, 0, 0, 1)
       
   466     SpawnUtilityCrate(0, 0, amLaserSight)</code>
       
   467 
       
   468 === <tt>!SpawnFakeAmmoCrate(x, y, explode, poison) </tt> ===
       
   469 Spawns a crate at the specified coordinates which looks exactly like a real ammo crate but contains not any ammo. It can be use useful for scripted events or to create a trap. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land).
       
   470 `explode` and `poison` are booleans.
       
   471 If `explode` is `true`, the crate will explode when collected.
       
   472 If `poison` is `true`, the collector will be poisoned.
       
   473 
       
   474 Example:
       
   475 
       
   476 <code language="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison.
       
   477 </code>
       
   478 
       
   479 === <tt>!SpawnFakeHealthCrate(x, y, explode, poison) </tt> ===
       
   480 Same as `SpawnFakeAmmoCrate`, except the crate will look like a health crate.
       
   481 
       
   482 === <tt>!SpawnFakeUtilityCrate(x, y, explode, poison) </tt> ===
       
   483 Same as `SpawnFakeAmmoCrate`, except the crate will look like an utility crate.
       
   484 
       
   485 === <tt>!AddHog(hogname, botlevel, health, hat)</tt> ===
       
   486 Adds a new hedgehog for current team (last created one with the `AddTeam` function), with a bot level, an initial health and a hat.
       
   487 
       
   488 `botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot, where `1` is strongest and `5` is the weakest. Note that this is the reverse order of how the bot level is displayed in the game. Note that mixing human-controlled and computer-controlled hedgehogs in the same team is not permitted, but it is permitted to use different computer difficulty levels in the same team.
       
   489 
       
   490 Returns the gear ID.
       
   491 
       
   492 *Warning*: This only works in singleplayer mode (e.g. missions). Also, Hedgewars only supports up to 64 hedgehogs in a game.
       
   493 
       
   494 Example:
       
   495 
       
   496 <code language="lua">    local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player
       
   497     SetGearPosition(player, 1500, 1000)
       
   498     -- hint: If you don't call `SetGearPosition`, the hog spawns randomly</code>
       
   499 
       
   500 === <tt>!AddMissionHog(health)</tt> (0.9.25) ===
       
   501 Add a hedgehog for the current team, using the player-chosen team identity when playing in singleplayer missions. The “current team” is the last team that was added with `AddMissionTeam` or `AddTeam`.
       
   502 
       
   503 The name and hat match the player's team definition. The hog is also always player-controlled.
       
   504 
       
   505 Examples:
       
   506 <code language="lua">-- Add player team with 3 hogs
       
   507 AddMissionTeam(-1)
       
   508 AddMissionHog(100)
       
   509 AddMissionHog(100)
       
   510 AddMissionHog(100)</code>
       
   511 
       
   512 <code language="lua">-- You can also mix mission hogs with “hardcoded” hogs.
       
   513 -- This adds a player team with 2 hogs taken from the player team and 1 hog with a hardcoded name, botlevel and hat.
       
   514 AddMissionTeam(-2)
       
   515 AddMissionHog(100)
       
   516 AddMissionHog(100)
       
   517 AddHog("My Hardcoded Hog", 0, 100, "NoHat")
       
   518 </code>
       
   519 
       
   520 == Functions to get gear properties ==
       
   521 
       
   522 === <tt>!GetGearType(gearUid)</tt> ===
       
   523 This function returns the [GearTypes gear type] for the specified gear, if it exists.  If it doesn't exist, `nil` is returned.
       
   524 
       
   525 === <tt>!GetVisualGearType(vgUid)</tt> (0.9.23) ===
       
   526 This function returns the [VisualGearTypes visual gear type] for the specified visual gear, if it exists.  If it doesn't exist, `nil` is returned.
       
   527 
       
   528 === <tt>!GetGearPosition(gearUid)</tt> ===
       
   529 Returns x,y coordinates for the specified gear. Not to be confused with `GetGearPos`.
       
   530 
       
   531 === <tt>GetGearCollisionMask(gearUid)</tt> ===
       
   532 Returns the current collision mask of the given gear. See `SetGearCollisionMask` for an explanation of the mask.
       
   533 
       
   534 === <tt>!GetGearRadius(gearUid)</tt> ===
       
   535 Returns the `Radius` value for the specified gear. For most [GearTypes gear types] for “projectile” gears (like `gtShell` or `gtGrenade`), the radius refers to the gear's collision radius. This is an invisible circle around the center of the gear which is used for the collision checks. For a few gear types, its radius means something different, see [GearTypes] for a full list.
       
   536 
       
   537 To set the `Radius` value, use `SetGearValues`.
       
   538 
       
   539 === <tt>!GetGearVelocity(gearUid)</tt> ===
       
   540 Returns a tuple of dx,dy values for the specified gear.
       
   541 
       
   542 === <tt>!GetFlightTime(gearUid)</tt> ===
       
   543 Returns the `FlightTime` of the specified gear. The `FlightTime` is a gear varialbe used to store a general time interval. The precise meaning of the `FlightTime` depends on the gear type.
       
   544 
       
   545 For example: The `FlightTime` of a hedgehog (`gtHedgehog`) is the time since they last have stood on solid ground. For most projectile gear types (i.e. `gtShell`), it stores the time after it has been launched.
       
   546 
       
   547 === <tt>!GetGearElasticity(gearUid) </tt> ===
       
   548 Returns the elasticity of the specified gear. The elasticity normally determines how strong the gear will bounce after collisions, where higher elasticity is for stronger bounces.
       
   549 
       
   550 This is also useful for determining if a hog is on a rope or not. If a hog is attached to a rope, or is busy firing one, the elasticity of the rope will be a non-zero number.
       
   551 
       
   552 === <tt>!GetGearFriction(gearUid) </tt> ===
       
   553 Returns the friction of the specified gear. The friction normally determines how well the gear will slide on terrain. Higher values are for increased sliding properties.
       
   554 
       
   555 === <tt>!GetHogClan(gearUid)</tt> ===
       
   556 Returns the clan ID of the specified hedgehog gear.
       
   557 
       
   558 === <tt>!GetHogTeamName(gearUid)</tt> ===
       
   559 Returns the name of the specified gear’s team. `gearUid` can be a hedgehog or a grave.
       
   560 
       
   561 === <tt>!GetHogName(gearUid)</tt> ===
       
   562 Returns the name of the specified hedgehog gear.
       
   563 
       
   564 === <tt>!IsHogHidden(gearUid)</tt> (0.9.25) ===
       
   565 Returns true if hedgehog gear is hidden (e.g. via `HideHog` or the !TimeBox), false if it isn't, nil if that hedgehog never existed.
       
   566 
       
   567 === <tt>!GetEffect(gearUid, effect)</tt> ===
       
   568 Returns the state of given effect for the given hedgehog gear.
       
   569 
       
   570 See `SetEffect` for further details.
       
   571 
       
   572 === <tt>!GetHogHat(gearUid)</tt> ===
       
   573 Returns the hat of the specified hedgehog gear.
       
   574 
       
   575 === <tt>!GetHogFlag(gearUid)</tt> ===
       
   576 Returns the name of the flag of the team of the specified hedgehog gear.
       
   577 
       
   578 === <tt>!GetHogFort(gearUid)</tt> (0.9.23) ===
       
   579 Returns the name of the fort of the team of the specified hedgehog gear.
       
   580 
       
   581 === <tt>!GetHogGrave(gearUid)</tt> ===
       
   582 Returns the name of the grave of the team of the specified hedgehog gear.
       
   583 
       
   584 === <tt>!GetHogVoicepack(gearUid)</tt> ===
       
   585 Returns the name of the voicepack of the team of the specified hedgehog gear.
       
   586 
       
   587 === <tt>!GetAmmoCount(gearUid, ammoType)</tt> ===
       
   588 Returns the ammo count of the specified ammo type for the specified hedgehog gear. If infinite, returns `AMMO_INFINITE`.
       
   589 
       
   590 === <tt>!GetAmmoTimer(gearUid, ammoType)</tt> (0.9.25) ===
       
   591 Returns the currently configured ammo timer (in milliseconds) for the given hedgehog gear and specified ammo type. This is the timer which is set by the player by using the timer keys (1-5). For ammo types for which the timer cannot be changed, `nil` is returned.
       
   592 
       
   593 Example:
       
   594 <code lang="lua">GetAmmoTimer(CurrentHedgehog, amGrenade)
       
   595 -- May return 1000, 2000, 3000, 4000 or 5000</code>
       
   596 
       
   597 === <tt>!IsHogLocal(gearUid)</tt> (0.9.23) ===
       
   598 Returns `true` if the specified hedgehog gear is controlled by a human player on the computer on which Hedgewars runs on (i.e. not over a computer over the network). Also returns `true` if the hog is a member of any of the local clans. Returns `false` otherwise. Returns `nil` if `gearUid` is invalid.
       
   599 
       
   600 This is perfect to hide certain captions like weapon messages from enemy eyes.
       
   601 
       
   602 === <tt>!GetGearTarget(gearUid, x, y) </tt> ===
       
   603 Returns the x and y coordinate of target-based weapons/utilities. 
       
   604 <b>Note:</b>: This can’t be used in `onGearAdd()` but must be called after gear creation. 
       
   605 
       
   606 === <tt>GetX(gearUid)</tt> ===
       
   607 Returns x coordinate of the gear.
       
   608 
       
   609 === <tt>GetY(gearUid)</tt> ===
       
   610 Returns y coordinate of the gear.
       
   611 
       
   612 === <tt>!GetState(gearUid)</tt> ===
       
   613 Returns the state of the gear. The gear state is a bitmask which is built out of the variables as shown in [States].
       
   614 
       
   615 This function is usually used in combination with `band` to extract the truth value of a single flag. It is also used together with `SetState` and `bor` in order to activate a single flag.
       
   616 
       
   617 Examples:
       
   618 <code language="lua">
       
   619 local state = GetState(gear)
       
   620 --[[ Stores the full raw bitmask of gear in state. Usually
       
   621 useless on its own. ]]
       
   622 </code>
       
   623 
       
   624 <code language="lua">
       
   625 isDrowning = band(GetState(CurrentHedgehog),gstDrowning) ~= 0
       
   626 --[[ GetState(CurrentHedgehog) returns the state bitmask of
       
   627 CurrentHedgehog, gstDrowning is a bitmask where only the
       
   628 “drowning” bit is set. band does a bitwise AND on both, if
       
   629 it returns a non-zero value, the hedgehog is drowning.]]
       
   630 </code>
       
   631 
       
   632 <code language="lua">
       
   633 SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstInvisible))
       
   634 --[[ first the state bitmask of CurrentHedgehog is bitwise ORed with
       
   635 the gstInvisible flag, thus making the bit responsible for
       
   636 invisiblity to become 1. Then the new bitmask is applied to
       
   637 CurrentHedgehog, thus making it invisible.]]
       
   638 </code>
       
   639 
       
   640 
       
   641 === <tt>!GetGearMessage(gearUid)</tt> ===
       
   642 Returns the message of the gear. This is a bitmask built out of flags seen in [GearMessages].
       
   643 
       
   644 === <tt>!GetTag(gearUid)</tt> ===
       
   645 Returns the tag of the specified gear (by `gearUid`). 
       
   646 
       
   647 The `Tag` of a gear is just another arbitrary variable to hold the gear's state. The meaning of a tag depends on the gear type. For example, for `gtBall` gears, it specifies the ball color, for `gtAirAttack` gears (airplane) it specifies the direction of the plane, etc. See [GearTypes] for a full list. The returned value will be an integer.
       
   648 
       
   649 Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. 
       
   650 
       
   651 <code language="lua">
       
   652 -- This adds a ball (the one from the ballgun) at (123, 456):
       
   653 ball = AddGear(123, 456, gtBall, 0, 0, 0, 0)
       
   654 -- The tag of a ball defines its color. It will automatically chosen at random when created.
       
   655 colorTag = GetTag(ball)
       
   656 -- Now colorTag stores the tag of ball (in this case a number denoting its color)
       
   657 </code>
       
   658 
       
   659 The meaning of tags are described in [GearTypes].
       
   660 
       
   661 === <tt>!GetFollowGear()</tt> ===
       
   662 Returns the uid of the gear that is currently being followed.
       
   663 
       
   664 === <tt>!GetTimer(gearUid)</tt> ===
       
   665 Returns the timer of the gear. This is for example the time it takes for watermelon, mine, etc. to explode. This is also the time used to specify the blowtorch or RC plane time. See [GearTypes] for a full list.
       
   666 
       
   667 === <tt>!GetHealth(gearUid)</tt> ===
       
   668 Returns the health of the gear. Depending on the gear type, the gear's “health” can also refer to other things, see [GearTypes] for a full list.
       
   669 
       
   670 === <tt>!GetHogLevel(gearUid)</tt> ===
       
   671 Returns the bot level ranging from `0` to `5`. `1` is the strongest bot level and `5` is the weakest one (this is the reverse of what players see). `0` is for human player.
       
   672 
       
   673 === <tt>!GetGearPos(gearUid)</tt> ===
       
   674 Get the `Pos` value of the specified gear. `Pos` is just another arbitrary value to hold the state of the gear, such as `Tag` and `Health`, the meaning depends on the gear type. See [GearTypes] for the conrete meaning of a gear's `Pos` value. 
       
   675 
       
   676 *Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that.
       
   677 
       
   678 === <tt>!GetGearValues(gearUid)</tt> ===
       
   679 This returns a bunch of values associated with the gear, their meaning is often depending on the gear type and many values might be unused for certain gear types.
       
   680 
       
   681 This is returned (all variables are integers):
       
   682 
       
   683 `Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom`
       
   684 
       
   685 A rough description of some of the parameters:
       
   686 
       
   687  * `Radius`: Effect or collision radius, most of the time
       
   688  * `ImpactSound`: Sound it makes on a collision (see [Sounds])
       
   689  * `Tint`: Used by some gear types to determine its colorization. The color is in RGBA format.
       
   690  * `Boom`: Used by most gears to determine the damage dealt.
       
   691 
       
   692 Example:
       
   693 <code language="lua">
       
   694 -- Get all values in a single line of code:
       
   695 local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom, Scale = GetGearValues(myGear)
       
   696 </code>
       
   697 
       
   698 === <tt>!GetVisualGearValues(vgUid)</tt> ===
       
   699 This returns the typically set visual gear values for the specified visual gear `vgUid`, useful if manipulating things like smoke, bubbles or circles. On success, it returns the following values:
       
   700 
       
   701 `X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale`
       
   702 
       
   703 The meaning of these values is the same as in `SetVisualGearValues`.
       
   704 
       
   705 If the visual gear does not exist, `nil` is returned. Always check the result for `nil` before you plug in the values anywhere.
       
   706 
       
   707 Most visual gears require little to no modification of parameters.
       
   708 
       
   709 Example:
       
   710 
       
   711 <code language="lua">-- Return visual gear values
       
   712 local X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale = GetVisualGearValues(vgUid)
       
   713 </code>
       
   714 
       
   715 == Functions to modify gears ==
       
   716 
       
   717 === <tt>!HideHog(gearUid)</tt> ===
       
   718 Removes a hedgehog from the map. The hidden hedgehog can be restored with `RestoreHog(gearUid)`. Since 0.9.23, returns `true` on success and `false` on failure (if gear does not exist / hog is already hidden).
       
   719 
       
   720 Example: 
       
   721 
       
   722 <code language="lua">    gear = AddGear(...)
       
   723      HideHog(gear) -- Hide the newly created gear.</code>
       
   724 
       
   725 === <tt>!RestoreHog(gearUid)</tt> ===
       
   726 Restores a previously hidden hedgehog.  Nothing happens if the hedgehog does not exist or is not hidden.
       
   727 
       
   728 Example: 
       
   729 
       
   730 <code language="lua">    gear = AddGear(...)
       
   731      HideHog(gear) -- Hide the newly created gear.
       
   732      RestoreHog(gear) -- Restore the newly hidden gear.</code>
       
   733 
       
   734 === <tt>!DeleteGear(gearUid)</tt> ===
       
   735 Deletes a gear.  If the specified gear did not exist, nothing happens.
       
   736 
       
   737 Example:
       
   738 
       
   739 <code language="lua">    gear = AddGear(...)
       
   740     DeleteGear(gear) -- Delete the newly created gear.</code>
       
   741 
       
   742 === <tt>!DeleteVisualGear(vgUid)</tt> ===
       
   743 Deletes a visual gear.  If it does not exist, nothing happens. 
       
   744 
       
   745 Note, most visual gears delete themselves after a while.
       
   746 
       
   747 
       
   748 
       
   749 Example:
       
   750 
       
   751 <code language="lua">    vgear = AddVisualGear(...)
       
   752     DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code>
       
   753 
       
   754 === <tt>!SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)</tt> ===
       
   755 Sets various gear value for the specified gear (`gearUid`). The meaining of each value often depends on the gear type. See the documentation on !GetGearValues for a brief description of the gear values. If `gearUid` is invalid or the gear does not exist, nothing happens.
       
   756 
       
   757 Set `nil` for each value you do not want to change.
       
   758 
       
   759 Example:
       
   760 <code language="lua">
       
   761 -- Paints all RC planes into a white color
       
   762 function onGearAdd(gear)
       
   763     if GetGearType(gear) == gtRCPlane then
       
   764          SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFFFFFFFF)
       
   765     end
       
   766 end
       
   767 </code>
       
   768 
       
   769 === <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, !FrameTicks, State, Timer, Tint, Scale)</tt> ===
       
   770 This allows manipulation of the internal state of the visual gear `vgUid`. If `vgUid` is invalid or the `vgUid` does not refer to an existing visual gear, the function does nothing. Thus, you can safely call this function even if you are not sure if the visual gear actually exists.
       
   771 
       
   772 All visual gear values are numbers. Each visual gear may be using these parameters differently, but the *usual* meaning of these is the following:
       
   773 
       
   774  * `X`, `Y`: Position
       
   775  * `dX`, `dY`: Speed along the X and Y axis
       
   776  * `Angle`: Current rotation
       
   777  * `Frame`: Image frame, if using a sprite sheet
       
   778  * `FrameTicks` is usually an animation counter
       
   779  * `State`: Helper value to save some internal state
       
   780  * `Timer`: Time in milliseconds until it expires
       
   781  * `Tint`: RGBA color
       
   782  * `Scale` is a scale factor (not used by all visual gears)
       
   783 
       
   784 Some visual gears interpret these values differently, just like normal gears. See [VisualGearTypes] for details.  Also, most visual gears are not using all possible values, while some values are just ignored.
       
   785 
       
   786 Note that most visual gears require little to no modification of their values.
       
   787 
       
   788 *NOTE*: *Never* use the visual gear's internal state to manipulate/store anything gameplay-related.  Visual gears are not safe for reliable storage and using them as that would lead to strange bugs.
       
   789 
       
   790 Example 1:
       
   791 
       
   792 <code language="lua">  -- set a circle to position 1000,1000 pulsing from opacity 20 to 200 (8%-78%), radius of 50, 3px thickness, bright red.
       
   793     SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff)</code>
       
   794 
       
   795 Only the first argument is required. Everything else is optional. Any such argument which is declared as `nil` will not overwrite the corresponding value of the visual gear.
       
   796 
       
   797 Example 2:
       
   798 
       
   799 <code language="lua">  -- set a visual gear to position 1000,1000
       
   800     SetVisualGearValues(circleUid, 1000, 1000)</code>
       
   801 <code language="lua">  -- set the tint of a visual gear to bright red.
       
   802     SetVisualGearValues(circleUid, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff0000ff)</code>
       
   803 
       
   804 
       
   805 === <tt>!FindPlace(gearUid, fall, left, right[, tryHarder])</tt> ===
       
   806 Finds a place for the specified gear between x=`left` and x=`right` and places it there. `tryHarder` is optional, setting it to `true`/`false` will determine whether the engine attempts to make additional passes, even attempting to place gears on top of each other.
       
   807 
       
   808 Example:
       
   809 
       
   810 <code language="lua">    gear = AddGear(...)
       
   811     FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code>
       
   812 === <tt>HogSay(gearUid, text, manner [,vgState])</tt> ===
       
   813 Makes the specified gear say, think, or shout some text in a comic-style speech or thought bubble. `gearUid` is _not_ limited to hedgehogs, altough the function name suggests otherwise.
       
   814 
       
   815 The `manner` parameter specifies the type of the bubble and can have one of these values:
       
   816 
       
   817 || *Value of `manner`* || *Looks* ||
       
   818 || `SAY_THINK` || Thought bubble ||
       
   819 || `SAY_SAY` || Speech bubble ||
       
   820 || `SAY_SHOUT` || Exclamatory bubble (denotes shouting) ||
       
   821 
       
   822 There is a optional 4th parameter `vgState`, it defines wheather the speechbubble is drawn fully opaque or semi-transparent. The value `0` is the default value.
       
   823 
       
   824 || *Value of `vgState`* || *Effect* ||
       
   825 || `0` || If the specified gear is a hedgehog, and it’s the turn of the hedgehog’s team, the bubble is drawn fully opaque.<br>If the gear is a hedgehog, and it’s another team’s turn, the bubble is drawn translucent.<br>If the gear is not a hedgehog, the bubble is drawn fully opaque. ||
       
   826 || `1` || The bubble is drawn translucent. ||
       
   827 || `2` || The bubble is drawn fully opaque. ||
       
   828 
       
   829 Examples:
       
   830 
       
   831 <code language="lua">HogSay(CurrentHedgehog, "I wonder what to do …", SAY_THINK) -- thought bubble with text “I wonder what to do …”</code>
       
   832 <code language="lua">HogSay(CurrentHedgehog, "I'm hungry.", SAY_SAY) -- speech bubble with text “I’m hungry.”</code>
       
   833 <code language="lua">HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text “I smell CAKE!”</code>
       
   834 === <tt>!HogTurnLeft(gearUid, boolean)</tt> ===
       
   835 Faces the specified hog left or right.
       
   836 
       
   837 Example:
       
   838 
       
   839 <code language="lua">    HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left 
       
   840     HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code>
       
   841 === <tt>!SetGearPosition(gearUid, x, y)</tt> ===
       
   842 Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`.
       
   843 
       
   844 === <tt>SetGearCollisionMask(gearUid, mask)</tt> ===
       
   845 Set the collision mask of the given gear with `gearUid`.
       
   846 The collision mask defines with which gears and terrain types the gear can collide.
       
   847 
       
   848 `mask` is a number between `0x0000` and `0xFFFF` and used as a bitfield, which means you can combine these flags with `bor`. These are the available flags:
       
   849 
       
   850 || *Identifier* || *Collision with …* ||
       
   851 || `lfLandMask` || Terrain ||
       
   852 || `lfCurHogCrate` || Current hedgehog, and crates ||
       
   853 || `lfHHMask` || Any hedgehogs ||
       
   854 || `lfNotHHObjMask` || Objects, not hogs (e.g. mines, explosives) ||
       
   855 || `lfAllObjMask` || Hedgehogs and objects ||
       
   856 
       
   857 Beware, the collision mask is often set by the engine as well.
       
   858 
       
   859 Examples:
       
   860 <code language="lua">SetGearCollisionMask(gear, bnot(lfCurHogCrate))
       
   861 -- Ignore collision with current hedgehog</code>
       
   862 
       
   863 <code language="lua">SetGearCollisionMask(gear, 0xFFFF)
       
   864 -- Collide with everything</code>
       
   865 
       
   866 <code language="lua">SetGearCollisionMask(gear, lfAllObjMask)
       
   867 -- Collide with hedgehogs and objects</code>
       
   868 
       
   869 <code language="lua">SetGearCollisionMask(gear, 0x0000)
       
   870 -- Collide with nothing</code>
       
   871 
       
   872 There are actual more flags availbable, but they are not as useful for use in Lua and their constants have not been exposed to Lua. You can find the full range of flags in the engine source code (in Pascal):
       
   873 
       
   874 [https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uConsts.pas#l112]
       
   875 
       
   876 === <tt>!SetGearVelocity(gearUid, dx, dy)</tt> ===
       
   877 Gives the specified gear the velocity of `dx`, `dy`.
       
   878 
       
   879 === <tt>!SetFlightTime(gearUid, flighttime)</tt> ===
       
   880 Sets the `FlightTime` of the given gear to `flighttime`. The meaning of `FlightTime` is explained in the section `GetFlightTime`.
       
   881 
       
   882 === <tt>!SetGearElasticity(gearUid, Elasticity) </tt> ===
       
   883 Sets the elasticity of the specified gear. For most gears, the elasticity determines how strong the gear will bounce after collisions, where higher elasticity is for stronger bounces. Recommended are values between `0` and `9999`.
       
   884 
       
   885 === <tt>!SetGearFriction(gearUid, Friction) </tt> ===
       
   886 Sets the friction of the specified gear. The friction normally determines how well the gear will slide on terrain. Higher values are for increased sliding properties. `0` is for no sliding whatsoever, where `9999` is for very long slides, greater values are not recommended.
       
   887 
       
   888 === <tt>!SetHealth(gearUid, health)</tt> ===
       
   889 Sets the health of the specified gear. The “health” of a gear can refer to many things, depending on the gear type.
       
   890 
       
   891 *Hint*: If you like to increase the health of a hedgehog with nice visual effects, consider using `HealHog` instead.
       
   892 
       
   893 Use cases:
       
   894 
       
   895   * Setting the health of a hedgehog (`gtHedgehog`) to 99
       
   896   * Starting the RC Plane (`gtRCPlane`) with 10 bombs
       
   897   * Starting flying saucer (`gtJetpack`) with only 50% fuel
       
   898   * Setting all the mines (`gtMine`) to duds
       
   899   * And more!
       
   900 
       
   901 See [GearTypes] for a full description.
       
   902 
       
   903 <code language="lua">    function onGearAdd(gear)
       
   904        if (GetGearType(gear) == gtHedgehog) then
       
   905             -- Set hedgehog health to 99
       
   906             SetHealth(gear, 99)
       
   907        end
       
   908        if (GetGearType(gear) == gtRCPlaane) then
       
   909             -- Give the plane 10 bombs
       
   910             SetHealth(gear, 10)
       
   911        end
       
   912        if (GetGearType(gear) == gtJetpack) then
       
   913             -- Set fuel to 50% only
       
   914             SetHealth(gear, 1000)
       
   915        end
       
   916        if (GetGearType(gear) == gtMine) then
       
   917             -- Turn mine into dud
       
   918             SetHealth(gear, 0)
       
   919        end
       
   920     end</code>
       
   921 
       
   922 === <tt>HealHog(gearUid, healthBoost[, showMessage[, tint]])</tt> (0.9.24) ===
       
   923 Convenience function to increase the health of a hedgehog with default visual effects.
       
   924 
       
   925 Specifically, this 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.
       
   926 
       
   927 If `showMessage` is false, no message is shown. With `tint` you can set the RGBA color of the particles (default: `0x00FF00FF`).
       
   928 
       
   929 This function does not affect the poison state, however (see `SetEffect`).
       
   930 
       
   931 === <tt>!SetEffect(gearUid, effect, effectState)</tt> ===
       
   932 Sets the state for one of the effects <tt>heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen</tt> for the specified hedgehog gear.
       
   933 A value of 0 usually means the effect is disabled, values other than that indicate that it is enabled and in some cases specify e.g. the remaining time of that effect.
       
   934 
       
   935 || *`effect`* || *Description* || *`effectState`* ||
       
   936 || `heInvulnerable` || Wether hog is invulnerable || Any non-zero value turns on invulnerability. `0` turns it off. ||
       
   937 || `hePoisoned` || Poison damage, damages hog each turn. || Amount of damage per turn. Use `0` to disable poisoning. ||
       
   938 || `heResurrectable` || Whether to resurrect the hog on death || With a non-zero value, the hedgehog will be resurrected and teleported to a random location on death. `0` disables this. ||
       
   939 || `heResurrected` || Whether the hedgehog has been resurrected once. This is only a subtle graphical effect. || With a non-zero value, the hedgehog was resurrected, `0` otherwise. ||
       
   940 || `heFrozen` || Freeze level. Frozen hedgehogs skip turn, are heavy and take half damage || The hog is considered frozen if the value is `256` or higher, otherwise not. A number of `256` or higher denotes “how frozen” the hedgehog is, i.e. how long it takes to melt. The freezer sets this to `199999` initially. The value will be reduced by `50000` each round. Being hit by a flame reduces this number by `1000`. The values `0` to `255` are used for the freeze/melt animations. ||
       
   941 || `heArtillery` || If enabled, the hedgehog can't walk (since 0.9.24). || `0` = disabled. `1` = permanently enabled. `2` = temporarily enabled (used by sniper rifle between shots) ||
       
   942 
       
   943 Example (sets all bots poisoned with poison damage of 1):
       
   944 
       
   945 <code language="lua">    function onGearAdd(gear)
       
   946         if (GetGearType(gear) == gtHedgehog) and (GetHogLevel(gear) > 0) then
       
   947             SetEffect(gear, hePoisoned, 1)
       
   948         end
       
   949     end</code>
       
   950 
       
   951 === <tt>CopyPV(gearUid, gearUid)</tt> ===
       
   952 This sets the position and velocity of the second gear to the first one.
       
   953 
       
   954 === <tt>!FollowGear(gearUid)</tt> ===
       
   955 Makes the game client follow the specifiec gear (if it exists). Does not work for visual gears.
       
   956 
       
   957 === <tt>!SetHogName(gearUid, name)</tt> ===
       
   958 Sets the name of the specified hedgehog gear.
       
   959 
       
   960 === <tt>!SetHogTeamName(gearUid, name)</tt> ===
       
   961 Sets the team name of the specified gear. The gear can be a hedgehog or grave.
       
   962 
       
   963 === <tt>!SetHogHat(gearUid, hat)</tt> ===
       
   964 Sets the hat of the specified hedgehog gear.
       
   965 
       
   966 === <tt>!SetGearTarget(gearUid, x, y)</tt> ===
       
   967 Sets the x and y coordinate of target-based weapons/utilities.
       
   968 *Note*: This can’t be used in onGearAdd() but must be called after gear creation.
       
   969 
       
   970 === <tt>!SetState(gearUid, state)</tt> ===
       
   971 Sets the state of the specified gear to the specified `state`. This is a bitmask made out of the variables as seen in [States].
       
   972 
       
   973 This function is often used together with `GetState` and the bitmask utility functions `band` and `bnot` in order to manipulate a single flag.
       
   974 
       
   975 Examples:
       
   976 <code language="lua">
       
   977 SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstInvisible))
       
   978 --[[ first the state bitmask of CurrentHedgehog is bitwise ORed with
       
   979 the gstInvisible flag, thus making the bit responsible for
       
   980 invisiblity to become 1. Then the new bitmask is applied to
       
   981 CurrentHedgehog, thus making it invisible. ]]
       
   982 </code>
       
   983 
       
   984 <code language="lua">
       
   985 SetState(CurrentHedgehog, band(GetState(CurrentHedgehog), bnot(gstInvisible)))
       
   986 --[[ The reverse of the above: This function toggles CurrentHedgehog’s
       
   987 gstInvisible flag off, thus making it visible again. ]]
       
   988 </code>
       
   989 
       
   990 === <tt>!SetGearMessage(gearUid, message)</tt> ===
       
   991 Sets the gear messages of the specified gear. `message` is a bitmask built out of flags seen in [GearMessages].
       
   992 
       
   993 === <tt>!SetTag(gearUid, tag)</tt> ===
       
   994 Sets the `Tag` value of the specified gear (by `gearUid`). The `Tag` value of a gear is simply an extra variable to modify misc. things. The meaning of a tag depends on the gear type. For example, for `gtBall` gears, it specifies the ball color, for `gtAirAttack` gears (airplane) it specifies the direction of the plane, etc. See [GearTypes] for a full list. `tag` has to be an integer.
       
   995 
       
   996 Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. 
       
   997 
       
   998 <code language="lua">
       
   999 -- This adds a ball (the one from the ballgun) at (123, 456):
       
  1000 ball = AddGear(123, 456, gtBall, 0, 0, 0, 0)
       
  1001 -- This sets the tag of the gear. For gtBall, the tag specified the color. “8” is the color white.
       
  1002 SetTag(ball, 8) -- 
       
  1003 </code>
       
  1004 
       
  1005 The meaning of tags are described in [GearTypes].
       
  1006 
       
  1007 === <tt>!SetTimer(gearUid, timer)</tt> ===
       
  1008 Sets the timer of the specified gear. Also see `GetTimer`.
       
  1009 
       
  1010 === <tt>!SetHogLevel(gearUid, level)</tt> ===
       
  1011 Sets the bot level from 0 to 5. `1` is the strongest bot level and `5` is the weakest one (this is the reverse of what players see). `0` means human player.
       
  1012 
       
  1013 === <tt>SetGearAIHints(gearUid, aiHint)</tt> ===
       
  1014 Set some behaviour hints for computer-controlled hedgehogs for any given gear with `gearUid`.
       
  1015 
       
  1016 Set `aiHint` to either of:
       
  1017 
       
  1018  * `aihUsualProcessing`: AI hogs treat this gear the usual way. This is the default.
       
  1019  * `aihDoesntMatter`: AI hogs don't bother attacking this gear intentionally.
       
  1020 
       
  1021 Example:
       
  1022 
       
  1023 <code language="lua">
       
  1024 SetGearAIHints(uselessHog, aihDoesntMatter)
       
  1025 -- This makes AI hogs stop caring about attacking uselessHog</code>
       
  1026 
       
  1027 === <tt>!SetGearPos(gearUid, value)</tt> ===
       
  1028 Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information.
       
  1029 
       
  1030 == Gameplay functions ==
       
  1031 
       
  1032 === `GameFlags` functions ===
       
  1033 
       
  1034 ==== <tt>!ClearGameFlags()</tt> ====
       
  1035 Disables *all* !GameFlags.
       
  1036 
       
  1037 ==== <tt>!DisableGameFlags(gameflag, ...)</tt> ====
       
  1038 Disables the listed !GameFlags, without changing the status of other !GameFlags.
       
  1039 
       
  1040 ==== <tt>!EnableGameFlags(gameflag, ...)</tt> ====
       
  1041 Enables the listed !GameFlags, without changing the status of other !GameFlags. In missions, no !GameFlags are set initially.
       
  1042 
       
  1043 ==== <tt>!GetGameFlag(gameflag)</tt> ====
       
  1044 Returns `true` if the specified gameflag is enabled, otherwise `false`.
       
  1045 
       
  1046 === Turns ===
       
  1047 ==== <tt>SkipTurn()</tt> (0.9.24) ====
       
  1048 Forces the current hedgehog to skip its turn.
       
  1049 
       
  1050 ==== <tt>EndTurn([noTaunts])</tt> (0.9.23) ====
       
  1051 Ends the current turn immediately.
       
  1052 
       
  1053 Normally, a “Coward” taunt may be played and an announcer message may be shown (depending on the situation). Set the optional `noTaunts` parameter to `true` to force the engine to never play a taunt or show a message. `noTaunts` is `false` by default.
       
  1054 
       
  1055 ==== <tt>Retreat(time [, respectGetAwayTimeFactor)</tt> (0.9.25) ====
       
  1056 Forces the current turn into the retreating phase, as if the hog made an attack. That is, the current hedgehog is unable to attack or select a weapon, only movement is possible until the retreat time is up.
       
  1057 
       
  1058 The retreat time must be set with `time` in milliseconds. By default, this time is automatically multiplied with get-away time percentage from the game scheme for seamless integration with schemes. If you want to ignore the game scheme for some reason and set the retreat time no matter what, set `respectGetAwayTimeFactor` to `false`.
       
  1059 
       
  1060 If the current hedgehog was busy doing an attack, the attack is aborted, no shot is made. If this function is called in the ready phase of af a turn, the ready phase continues normally, but the turn will begin in the retreat phase instead.
       
  1061 
       
  1062 Note: If you want the turn to end instantly, it is recommended to use `EndTurn` instead.
       
  1063 
       
  1064 ==== <tt>!SetTurnTimeLeft(newTurnTimeLeft)</tt> (0.9.25) ====
       
  1065 Set the remaining turn time in milliseconds. The current remaining turn time can be read from the variable `TurnTimeLeft`.
       
  1066 
       
  1067 ==== <tt>!SetReadyTimeLeft(newReadyTimeLeft)</tt> (0.9.25) ====
       
  1068 Set the remaining ready time in milliseconds. This function should only be called in onNewTurn. The current remaining ready time can be read from the variable `ReadyTimeLeft`.
       
  1069 
       
  1070 ==== <tt>!SetTurnTimePaused(isPaused)</tt> (0.9.25) ====
       
  1071 Pauses the turn time indefinitely if `isPaused` is set to `true`, disabled the turn time pause if `isPaused` is set to `false`.
       
  1072 
       
  1073 ==== <tt>!GetTurnTimePaused()</tt> (0.9.25) ====
       
  1074 Returns `true` if the turn time is currently paused by `SetTurnTimePaused`, otherwise returns `false`.
       
  1075 
       
  1076 ==== <tt>!EndGame()</tt> ====
       
  1077 Makes the game end.
       
  1078 
       
  1079 === Environment ===
       
  1080 ==== <tt>!SetGravity(percent)</tt> ====
       
  1081 Changes the current gravity of the game in percent (relative to default, integer value).
       
  1082 Setting it to 100 will set gravity to default gravity of hedgewars, 200 will double it, etc.
       
  1083 
       
  1084 ==== <tt>!GetGravity()</tt> ====
       
  1085 Returns the current gravity in percent.
       
  1086 
       
  1087 ==== <tt>!SetWaterLine(waterline)</tt> ====
       
  1088 Sets the water level (`WaterLine`) to the specified y-coordinate.
       
  1089 
       
  1090 ==== <tt>!SetWind(windSpeed)</tt> ====
       
  1091 Sets the current wind in the range of -100 to 100 inclusive. Use together with `gfDisableWind` for full control.
       
  1092 
       
  1093 ==== <tt>!GetWind()</tt> (0.9.24) ====
       
  1094 Returns current wind, expressed as a floating point number between -100 to 100 inclusive. Note there may be rounding errors.
       
  1095 
       
  1096 ==== <tt>!SetMaxBuildDistance(distInPx)</tt> ====
       
  1097 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.
       
  1098 
       
  1099 ==== <tt>Explode(x, y, radius[, options])</tt> (0.9.24) ====
       
  1100 Cause an explosion or erase land, push or damage gears.
       
  1101 
       
  1102 By default, an explosion destroys a circular piece of land and damages and pushes gears in its radius.
       
  1103 
       
  1104 The explosion occours at coordinates `(x, y)` with the given `radius`. Assuming 100% damage, the explosion damage at the center equals the explosion radius.
       
  1105 
       
  1106 The explosion will also have a visual effect (by spawning an explosion visual gear), unless the radius is very small.
       
  1107 
       
  1108 `options` is a bitmask which can be used to tweak how the explosion behaves:
       
  1109 
       
  1110 || *Flag* || *Meaning* ||
       
  1111 || `EXPLAutoSound` || Plays an appropriate sound ||
       
  1112 || `EXPLNoDamage` || Deal no damage to gears ||
       
  1113 || `EXPLDoNotTouchHH` || Do not push hedgehogs ||
       
  1114 || `EXPLDoNotTouchAny` || Do not push any gears ||
       
  1115 || `EXPLDontDraw` || Do not destroy land ||
       
  1116 || `EXPLForceDraw` || Destroy land, even if `gfSolidLand` is active ||
       
  1117 || `EXPLNoGfx` || Do not show an explosion animation and do not shake the screen ||
       
  1118 || `EXPLPoisoned` || Poison all hedgehogs in explosion radius ||
       
  1119 
       
  1120 `options` is assumed to be `EXPLAutoSound` by default. Set `options` to 0 to disable all flags.
       
  1121 
       
  1122 Examples:
       
  1123 <code language="lua">
       
  1124 -- Simple explosion at (100, 50) with radius 50
       
  1125 Explode(100, 50, 50)
       
  1126 
       
  1127 -- Simple explosion without sound
       
  1128 Explode(100, 50, 50, 0)
       
  1129 
       
  1130 -- Fake explosion which only pushes gears but deals no damage to gears and terrain
       
  1131 Explode(500, 1000, 50, EXPLAutoSound + EXPLNoDamage + EXPLDontDraw)
       
  1132 
       
  1133 -- Erase a circle of land without side effects
       
  1134 Explode(500, 100, 100, EXPLNoDamage + EXPLDoNotTouchAny + EXPLNoGfx)
       
  1135 </code>
       
  1136 
       
  1137 === Ammo ===
       
  1138 ==== <tt>!SetAmmo(ammoType, count, probability, delay, numberInCrate)</tt> ====
       
  1139 This updates the settings (initial ammo, crate probability, etc.) for a specified [AmmoTypes ammo type]. This must only be used in the `onAmmoStoreInit()` event handler. In other places, this function will not work.
       
  1140 
       
  1141 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!
       
  1142 
       
  1143 Parameters:
       
  1144 
       
  1145  * `ammoType`: Ammo type to be set
       
  1146  * `count`: Initial ammo count. 9 = infinite
       
  1147  * `probability`: Crate probability. Max. value is 9. 0 = never
       
  1148  * `delay`: Number of rounds this ammo is delayed
       
  1149  * `numberInCrate`: Amount of ammo in a crate
       
  1150 
       
  1151 Example:
       
  1152 
       
  1153 <code language="lua">    SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players
       
  1154     SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade
       
  1155     SetAmmo(amSkip, 9, 0, 0, 0) -- enable skip</code>
       
  1156 
       
  1157 Hint: It is recommended to always enable skip in missions. Only in exceptional circumstances you should choose to not enable skip.
       
  1158 
       
  1159 ==== <tt>!GetAmmo(ammoType)</tt> ====
       
  1160 Returns ammo settings (initial ammo, crate probability, etc.) for a specified [AmmoTypes ammo type]. This function is analogue to `SetAmmo`.
       
  1161 
       
  1162 This function returns four numbers, in this order: initial ammo count, probability, delay and number in crate. These values correspond to the parameters 2-5 provided in `SetAmmo` and have the same meaning.
       
  1163 
       
  1164 Example:
       
  1165 
       
  1166 <code language="lua">count, prob, delay, numberInCrate = GetAmmo(amGrenade) -- Get ammo settings of amGrenade</code>
       
  1167 
       
  1168 ==== <tt>!SetAmmoDelay(ammoType, delay)</tt> ====
       
  1169 Changes the delay of a specified [AmmoTypes Ammo Type].
       
  1170 
       
  1171 ==== <tt>!SetAmmoTexts(ammoType, name, caption, description [, showExtra])</tt> (0.9.23) ====
       
  1172 Allows you to overwrite the displayed name and tooltip descriptions of a given ammo type. This function must only be called either inside the `onGameStart` callback function, or after the engine has called `onGameStart`.
       
  1173 
       
  1174  * `ammoType`: The ammo type to set the text for
       
  1175  * `name`: Name of the ammo type (e.g. “Grenade” for `amGrenade`), affects both name in ammo menu and in the “ticker” message on the screen top.
       
  1176  * `caption`: The second line in the ammo menu (below the title). E.g. “Timed grenade” for `amGrenade`.
       
  1177  * `description`: Description text in ammo menu, below the caption.
       
  1178  * `showExtra`: If `false` the special “extra” text line like “Weapon is not yet available” or “Weapon does not end turn” will be suppressed
       
  1179 
       
  1180 `title`, `caption`, `description` can be `nil`, in which case they will be reverted to the engine default value. This function returns `nil`.
       
  1181 
       
  1182 Example:
       
  1183 <code language="lua">
       
  1184 -- Overwrites bazooka name and description
       
  1185 SetAmmoTexts(amBazooka, "Spoon Missile", "Crazy weapon", "This crazy weapon looks like a spoon and explodes on impact.|Attack: Hold to launch with more power")</code>
       
  1186 
       
  1187 ==== <tt>!SetAmmoDescriptionAppendix(ammoType, descAppend)</tt> (0.9.23) ====
       
  1188 Will set a string `descAppend` to be appended below the “core” description (ammo tooltip) of the specified `ammoType`, without changing the ordinary description.
       
  1189 Note that calling this function always sets the complete appended string, you can't use this function to append multiple texts in row.
       
  1190 
       
  1191 This function is recommended if you have tweaked an existing ammo type only a little and want to keep the original description intact as much as possible.
       
  1192 
       
  1193 Example:
       
  1194 <code language="lua">
       
  1195 -- Appends a text to the ammo tooltip of the bazooka but leaves name and main description intact
       
  1196 SetAmmoTexts(amBazooka, "This weapon deals double the damage than usually.")</code>
       
  1197 
       
  1198 ==== <tt>!AddAmmo(gearUid, ammoType, ammoCount)</tt> ====
       
  1199 Adds `ammoType` to the specified gear. The amount added is determined by the arguments passed via `SetAmmo()` in the `onAmmoStoreInit()` event handler. `ammoCount` is an optional parameter. If this is set, the ammo will *not* be added, but instead set to `ammoCount`. A value of `0` will remove the weapon, a value of `AMMO_INFINITE` will give infinite ammo.
       
  1200 
       
  1201 Note: By default, ammo is per-team, so calling `AddAmmo` for a hedgehog will give the ammo for the whole team. The game flags `gfPerHogAmmo` and `gfSharedAmmo` change how ammo is managed in the game, so these game flags also affect `AddAmmo`.
       
  1202 
       
  1203 ==== <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> (0.9.23) ====
       
  1204 Returns the localized name for the specified `ammoType`, taking an ammo name overwritten by `SetAmmoTexts` into account. If `ignoreOverwrite` is `true`, this function will always return the original ammo name of the weapon and ignores names which may have been overwritten by `SetAmmoTexts`.
       
  1205 
       
  1206 === Map ===
       
  1207 ==== <tt>!MapHasBorder()</tt> ====
       
  1208 Returns `true`/`false` if the map has a border or not.
       
  1209 
       
  1210 ==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly)</tt> ====
       
  1211 Checks the rectangle between the given coordinates for possible collisions. Set `landOnly` to `true` if you don’t want to check for collisions with gears (hedgehogs, etc.).
       
  1212 
       
  1213 ==== <tt>!PlaceGirder(x, y, frameIdx)</tt> ====
       
  1214 Attempts to place a girder with centre points `x`, `y` and a certain length and orientation, specified by `frameIdx`. The girder can only be placed in open space and must not collide with anything so this function may fail. It will return `true` on successful placement and `false` on failure.
       
  1215 
       
  1216 These are the accepted values for `frameIdx`:
       
  1217 
       
  1218 || *`frameIdx`* || *Length* || *Orientation* ||
       
  1219 || 0 || short || horizontal ||
       
  1220 || 1 || short || decreasing right ||
       
  1221 || 2 || short || vertical ||
       
  1222 || 3 || short || increasing right ||
       
  1223 || 4 || long || horizontal ||
       
  1224 || 5 || long || decreasing right ||
       
  1225 || 6 || long || vertical ||
       
  1226 || 7 || long || increasing right ||
       
  1227 
       
  1228 ==== <tt>!PlaceRubber(x, y, frameIdx)</tt> (0.9.23) ====
       
  1229 Attempts to place a rubber with centre points `x`, `y` and a certain orientation, specified by `frameIdx`. The rubber can only be placed in open space and must not collide with anything so this function may fail. It will return `true` on successful placement and `false` on failure.
       
  1230 
       
  1231 These are the accepted values for `frameIdx`:
       
  1232 
       
  1233 || *`frameIdx`* || *Orientation* ||
       
  1234 || 0 || horizontal ||
       
  1235 || 1 || decreasing right ||
       
  1236 || 2 || vertical ||
       
  1237 || 3 || increasing right ||
       
  1238 
       
  1239 ==== <tt>!PlaceSprite(x, y, sprite, frameIdx, tint, behind, flipHoriz, flipVert, [, landFlag, ...])</tt> ====
       
  1240 Places a [Sprites sprite] at the specified position (`x`, `y`) on the map, it behaves like terrain then. Unlike `PlaceGirder`, this function does not check for collisions, so the sprite can be placed anywhere within map boundaries. The function returns `true` if the placement was successful, `false` otherwise. `frameIdx` is the frame index starting by 0. `frameIdx` is used if the sprite consists of several sub-images. Only a subset of the sprites is currently supported by this function:
       
  1241 
       
  1242  * `sprAmGirder`
       
  1243  * `sprAmRubber`
       
  1244  * `sprAMSlot`
       
  1245  * `sprAMAmmos`
       
  1246  * `sprAMAmmosBW`
       
  1247  * `sprAMCorners`
       
  1248  * `sprHHTelepMask`
       
  1249  * `sprTurnsLeft`
       
  1250  * `sprSpeechCorner`
       
  1251  * `sprSpeechEdge`
       
  1252  * `sprSpeechTail`
       
  1253  * `sprTargetBee`
       
  1254  * `sprThoughtCorner`
       
  1255  * `sprThoughtEdge`
       
  1256  * `sprThoughtTail`
       
  1257  * `sprShoutCorner`
       
  1258  * `sprShoutEdge`
       
  1259  * `sprShoutTail`
       
  1260  * `sprBotlevels`
       
  1261  * `sprIceTexture`
       
  1262  * `sprCustom1`
       
  1263  * `sprCustom2`
       
  1264 
       
  1265 `tint` is for an RGBA colouring to apply, this works about the same as `Tint` in gears. If `nil`, the original color is used.
       
  1266 
       
  1267 `behind` indicates the sprite should not replace existing land.
       
  1268 
       
  1269 `flipHoriz` and `flipVert` are for mirroring the sprite vertically and horizontally before placing, respectively.
       
  1270 
       
  1271 The 9th and later arguments specify land flags (see the constants section) to be used for the newly created terrain. If omitted, `lfNormal` is assumed.
       
  1272 
       
  1273 Example:
       
  1274 
       
  1275 <code language="lua">PlaceSprite(2836, 634, sprAmGirder, 5)
       
  1276 -- Places the girder sprite as normal terrain at (2836, 634). The `frameIdx` 5 is for the long decreasing right girder.</code>
       
  1277 <code language="lua">PlaceSprite(1411, 625, sprAmRubber, 1, nil, nil, nil, nil, lfBouncy)
       
  1278 -- Places the rubber band sprite as bouncy terrain at (2836, 634). The `frameIdx` 1 is for the decreasing right rubber band.</code>
       
  1279 
       
  1280 ==== <tt>!EraseSprite(x, y, sprite, frameIdx, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert, [, landFlag, ...])</tt> ====
       
  1281 Erases a [Sprites sprite] at the specified position (`x`, `y`) on the map. `frameIdx` is the frame index starting by 0. `sprite`, `frameIdx`, `flipHoriz` and `flipVert` behave the same as in `PlaceSprite`. For `sprite`, the same subset of sprites is permitted.
       
  1282 
       
  1283 Set `eraseOnLFMatch` to `true` to erase all land for a pixel that matches any of the passed in land flags.  This is useful if, for example, an `lfBouncy` sprite was placed “behind” land using `PlaceSprite` and you want to remove it without destroying the non-bouncy terrain.
       
  1284 
       
  1285 Set `onlyEraseLF` to `true` to only remove specific land flags. If for example a sprite consists of `lfIndestructible` and `lfBouncy`, and you call `EraseSprite` with `onlyEraseLF` and `lfIndestructible` set, the sprite will remain bouncy but can be destroyed.  You can use this to entirely remove all land flags from a sprite—at this point the sprite will be visual only, painted on the map but with no collision.
       
  1286 
       
  1287 Examples:
       
  1288 
       
  1289 <code language="lua">EraseSprite(2836, 634, sprAmGirder, 5)
       
  1290 -- Removes the girder sprite at (2836, 634). The frameIdx 5 is for the long decreasing right girder.</code>
       
  1291 <code language="lua">EraseSprite(1411, 625, sprAmRubber, 1, true, true, nil, nil, lfIndestructible)
       
  1292 -- Removes indestructibility from a rubber band sprite at (2836, 634). The frameIdx 1 is for the decreasing right rubber band.</code>
       
  1293 
       
  1294 ==== <tt>!AddPoint(x, y [, width [, erase] ])</tt> ====
       
  1295 This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”.
       
  1296 
       
  1297 The function takes a `x`,`y` location, a `width` (means start of a new line) and `erase` (if `false`, this function will draw normally, if `true`, this function will erase drawn stuff).
       
  1298 
       
  1299 This function must be called within `onGameInit`, where `MapGen` has been set to `mgDrawn`. You also should call `FlushPoints` when you are finished with drawing.
       
  1300 
       
  1301 See [LuaDrawning] for some examples.
       
  1302 
       
  1303 ==== <tt>!FlushPoints()</tt> ====
       
  1304 Makes sure that all the points/lines specified using `AddPoint` are actually applied to the map. This function must be called within `onGameInit`.
       
  1305 
       
  1306 === Current hedgehog ===
       
  1307 
       
  1308 ==== <tt>!GetCurAmmoType()</tt> ====
       
  1309 Returns the currently selected [AmmoTypes Ammo Type].
       
  1310 
       
  1311 ==== <tt>!SwitchHog(gearUid)</tt> ====
       
  1312 This function will switch to the hedgehog with the specifiedd `gearUid`.
       
  1313 
       
  1314 ==== <tt>!SetWeapon(ammoType)</tt> ====
       
  1315 Sets the selected weapon of `CurrentHedgehog` to one of the [AmmoTypes Ammo Type].
       
  1316 
       
  1317 Examples:
       
  1318 
       
  1319 <code language="lua">
       
  1320   SetWeapon(amBazooka) -- select the bazooka (if hog has one)
       
  1321 </code>
       
  1322 <code language="lua">
       
  1323   SetWeapon(amNothing) -- unselects the weapon.
       
  1324 </code>
       
  1325 
       
  1326 ==== <tt>!SetNextWeapon()</tt> ====
       
  1327 This function makes the current hedgehog switch to the next weapon in list of available weapons. It can be used for example in trainings to pre-select a weapon.
       
  1328 
       
  1329 ==== <tt>!SetInputMask(mask)</tt> ====
       
  1330 Masks specified player input. This means that Hedgewars ignores certain player inputs, such as walking or jumping.
       
  1331 
       
  1332 Example: 
       
  1333 <code language="lua">    -- masks the long and high jump commands
       
  1334 SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) 
       
  1335     -- clears input mask, allowing player to take actions
       
  1336     SetInputMask(0xFFFFFFFF) 
       
  1337 		</code>
       
  1338 *Note*: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping.
       
  1339 
       
  1340 *Note*: This function is used internally in the Animate [LuaLibraries library].
       
  1341 
       
  1342 See also [GearMessages].
       
  1343 
       
  1344 ==== <tt>!GetInputMask()</tt> ====
       
  1345 Returns the current input mask of the player.
       
  1346 
       
  1347 ==== <tt>!SetVampiric(bool)</tt> (0.9.24) ====
       
  1348 Toggles vampirism mode for this turn. Set `bool` to `true` to enable (same effect as if the hedgehog has used Vampirism), `false` to disable.
       
  1349 
       
  1350 ==== <tt>!GetVampiric()</tt> (0.9.25) ====
       
  1351 Returns true if vampirism mode is currently active.
       
  1352 
       
  1353 ==== <tt>!SetLaserSight(bool)</tt> (0.9.24) ====
       
  1354 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.
       
  1355 
       
  1356 ==== <tt>!GetLaserSight()</tt> (0.9.25) ====
       
  1357 Returns true if laser sight (as utility) is currently active. The sniper rifle's built-in laser sight does not count.
       
  1358 
       
  1359 ==== <tt>!EnableSwitchHog()</tt> (0.9.25) ====
       
  1360 Enable hog switching mode for the current hedgehog. This function should be called while the hedgehog is standing on solid ground (`GetFlightTime` returns 0).
       
  1361 
       
  1362 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.
       
  1363 
       
  1364 On success, returns the `gtSwitcher` gear being spawned or, if hog switching mode is already active, returns the exsting gear. On failure, returns `nil`.
       
  1365 
       
  1366 === Randomness ===
       
  1367 ==== <tt>!GetRandom(number)</tt> ====
       
  1368 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`.
       
  1369 
       
  1370 === Clans and teams ===
       
  1371 ==== <tt>!AddTeam(teamname, color, grave, fort, voicepack, flag)</tt> ====
       
  1372 
       
  1373 Adds a new team.
       
  1374 
       
  1375 You *must* call it only in `onGameInit`.
       
  1376 You *must* add at least one hedgehog with `AddHog` after calling this. The engine does not support empty teams.
       
  1377 `AddTeam` is only supported for singleplayer missions. You *must not* call this function in multiplayer.
       
  1378 
       
  1379 Arguments:
       
  1380 
       
  1381  * `teamname`: The name of the team.
       
  1382  * `color`: Team color, usually a number from -9 to -1 (see below)
       
  1383  * `grave`: The name of the team’s grave (equals file name without the suffix)
       
  1384  * `fort`: The name of the team’s fort (equals file name without the suffix and without the letter “L” or “R” before that suffix)
       
  1385  * `voicepack`: The name of the team’s voice pack (equals the directory name)
       
  1386  * `flag`: Optional argument for the name of the team’s flag (equals file name without the suffix). If set to `nil`, the flag “hedgewars” is used.
       
  1387 
       
  1388 ===== Clan color =====
       
  1389 Each team must have a color. The color also determines clan membership: Teams with equal color are in the same clan.
       
  1390 
       
  1391 The team color is specified as a number from -9 to -1. This will select one of the 9 possible team colors as specified in the player's settings. As the actual colors are set by the player, you can't predict them, but you can usually trust these defaults:
       
  1392 
       
  1393  * `-1`: red
       
  1394  * `-2`: blue
       
  1395  * `-3`: cyan
       
  1396  * `-4`: purple
       
  1397  * `-5`: magenta
       
  1398  * `-6`: green
       
  1399  * `-7`: orange
       
  1400  * `-8`: brown
       
  1401  * `-9`: yellow
       
  1402 
       
  1403 An older (and now discouraged) method of specifying the color is by hardcoding it as an RGB color (i.e. `0xDD0000`). This practice is now strongly discouraged because it will ignore the player-chosen color (which is *bad* for players with color blindness) and in 99% of cases you don't need it anyway. It should be only used for testing and debugging. 
       
  1404 
       
  1405 ===== Example =====
       
  1406 
       
  1407 <code language="lua">AddTeam("team 1", -1, "Simple", "Tank", "Default", "hedgewars")
       
  1408 --[[ Adds a new team with name “team 1”, the first default color (usually red), the grave “Simple”,
       
  1409 the fort “Tank” the voicepack “Default” and the flag “hedgewars”. ]]</code>
       
  1410 
       
  1411 ==== <tt>!AddMissionTeam(color)</tt> (0.9.25) ====
       
  1412 Adds a new team using the player-chosen team identity when playing a singleplayer mission. Does not work in multiplayer.
       
  1413 
       
  1414 This function is very similar to `AddTeam`. Team settings like team name and flag will be taken from the player-chosen team.
       
  1415 You only need to specify the clan color, which has the same meaning as in `AddTeam`.
       
  1416 
       
  1417 Use `AddMissionHog` or `AddHog` afterwards to add hedgehogs for this team. You can mix `AddMissionHog` and `AddHog` as you wish.
       
  1418 
       
  1419 Example:
       
  1420 <code language="lua">-- Add mission team with default clan color
       
  1421 AddMissionTeam(-1)</code>
       
  1422 
       
  1423 ==== <tt>!GetTeamName(teamIdx)</tt> (0.9.24) ====
       
  1424 Returns the name of the team with the index `teamIdx`. `teamIdx` is a number between 0 and `TeamsCount-1`.
       
  1425 
       
  1426 ==== <tt>!GetTeamIndex(teamname)</tt> (0.9.24) ====
       
  1427 Returns the team index (number between 0 and `TeamsCount-1`) of the team with the name `teamName`.
       
  1428 
       
  1429 ==== <tt>!GetTeamClan(teamname)</tt> (0.9.24) ====
       
  1430 Returns the clan ID of the team with the given `teamName`.
       
  1431 
       
  1432 ==== <tt>!DismissTeam(teamname)</tt> ====
       
  1433 Vaporizes all the hogs of the team with the given team name in a puff of smoke.
       
  1434 
       
  1435 This function must not be called while it's the team's turn.
       
  1436 
       
  1437 ==== <tt>!SetTeamLabel(teamname[, label])</tt> (0.9.24) ====
       
  1438 Set or remove a label for the team with the given team name. The label is a string and will be displayed next to the team's health bar.
       
  1439 
       
  1440 If `label` is `nil`, the label will be removed.
       
  1441 
       
  1442 There's a special case: If the AI Survival game modifier is active, the AI kill counter will be replaced by the custom team label if it has been set. If `label` is set to `nil`, the default AI counter is shown again.
       
  1443 
       
  1444 Use this to display a score, power value or another important team attribute. There's no hard length limit, but please try to keep it as short as possible to avoid visual clutter.
       
  1445 
       
  1446 === <tt>SetTeamPassive(teamname, isPassive)</tt> (1.0.0) ===
       
  1447 Mark a team as passive if `isPassive` is `true`. Passive teams do not participate in the game and are treated like frozen teams. When determining the team order, passive teams are completely ignored.
       
  1448 
       
  1449 ==== <tt>!GetClanColor(clan)</tt> ====
       
  1450 Returns the RGBA color of the chosen clan by its number. The color data type is described in [LuaAPI#Color].
       
  1451 
       
  1452 ==== <tt>!SetClanColor(clan, color)</tt> ====
       
  1453 Sets the RGBA color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]. The new clan color *must* be different from the color of all clans (you can't use this function to change clan memberships of teams).
       
  1454 
       
  1455 Note: The stats graph does not support changing clan colors. If the clan colors change in mid-game, the graph might get confused and shows weird stuff. You may want to turn off the graph with if this is the case (see `SendHealthStatsOff`).
       
  1456 
       
  1457 === Campaign management ===
       
  1458 ==== <tt>!SaveCampaignVar(varname, value)</tt> ====
       
  1459 Stores the value `value` (a string) into the campaign variable `varname` (also a string). Campaign variables allow you to save progress of a team in a certain campaign. Campaign variables are saved on a per-team per-campaign basis. They are written into the team file (see [ConfigurationFiles#TeamName.hwt]).
       
  1460 
       
  1461 There are some special campaign variables which are used by Hedgewars to determine which missions to display in the campaign menu. This is described [ConfigurationFiles#%5BCampaign%20%3CCAMPAIGN_NAME%3E%5D here].
       
  1462 
       
  1463 ==== <tt>!GetCampaignVar(varname)</tt> ====
       
  1464 Returns the value of the campaign variable `varname` as a string. See also `SaveCampaignVar`.
       
  1465 
       
  1466 ==== <tt>!SaveMissionVar(varname, value)</tt> (0.9.25) ====
       
  1467 Stores the value `value` (a string) into the mission variable `varname` (also a string). A mission variable is like a campaign variable, but it applies for singleplayer missions only (Training/Challenge/Scenario), excluding campaign missions.
       
  1468 
       
  1469 ==== <tt>!GetMissionVar(varname)</tt> (0.9.25) ====
       
  1470 Returns the value of the mission variable `varname` as a string. See also `SaveMissionVar`.
       
  1471 
       
  1472 == Functions affecting the GUI ==
       
  1473 
       
  1474 === <tt>!AddCaption(text)</tt> ===
       
  1475 Display an event text in the upper part of the screen. The text will be white and the caption group will be `capgrpMessage`.
       
  1476 
       
  1477 Example:
       
  1478 <code language="lua">
       
  1479 AddCaption("Hello, world!")
       
  1480 </code>
       
  1481 
       
  1482 === <tt>!AddCaption(text, color, captiongroup)</tt> ===
       
  1483 Display an event text in the upper part of the screen with the specified RGBA text [LuaAPI#Color color] and caption group. Although an RBGA color is used, Hedgewars does not actually support transparent or semi-transparent captions, so the fourth byte is ignored. We recommend you to always specify a full opacity (`FF` in hexadecimal) for the caption.
       
  1484 
       
  1485 || *`captiongroup`* || *Meaning* ||
       
  1486 || `capgrpGameState` || Used for important global game events, like Sudden Death ||
       
  1487 || `capgrpAmmoinfo` || Used for new weapon crates and some other events ||
       
  1488 || `capgrpVolume` || Used for “local” changes of client settings that don't affect gameplay, like volume change, auto camera on/off, etc. ||
       
  1489 || `capgrpMessage` || Generic message ||
       
  1490 || `capgrpMessage2` || Generic message ||
       
  1491 || `capgrpAmmostate` || Used to show information about weapon state, i.e. bounce level, timer, remaining shots, etc. ||
       
  1492 
       
  1493 The color can be specified in RGBA format, but you can (but don't have to) use one of the following built-in text color.
       
  1494 
       
  1495 || *Built-in color* || *Meaning* ||
       
  1496 || `capcolDefault` || Default caption color ||
       
  1497 || `capcolSetting` || Notification related to a local client setting (audio volume, auto camera on/off) ||
       
  1498 
       
  1499 Example:
       
  1500 <code language="lua">
       
  1501 AddCaption("Melon bomb rain in 2 rounds!", 0xFF0000FF, capgrpGameState)
       
  1502 -- Green example message.
       
  1503 </code>
       
  1504 
       
  1505 === <tt>!ShowMission(caption, subcaption, text, icon, time [, forceDisplay])</tt> ===
       
  1506 This function will open the mission panel and set the texts in it.
       
  1507 
       
  1508 Use to tell the player what he/she is supposed to do. If you use this function, a mission panel is shown for the amount of time specified in `time` (in milliseconds). If `time` is set to 0, it will be displayed for a default amount of time.
       
  1509 This function replaces the *entire* text of the mission panel. Compare this to the global `Goals` variable, which *adds* to the default text without replacing it.
       
  1510 
       
  1511 `caption` is the text displayed in the first line, `subcaption` is displayed in the second line and `text` is the text displayed in the third and following lines.
       
  1512 
       
  1513 By convention, `caption` should *normally* contain the name of the game style or mission and `subcaption` should *normally* contain the type of game style or mission, or a witty tagline. But this is only a loose convention which you don't have to follow all the time.
       
  1514 
       
  1515 `text` uses some special characters for formatting:
       
  1516 
       
  1517 || *Special character* || *Meaning* ||
       
  1518 || `|` || Line break ||
       
  1519 || `:` || Highlight itself and all text before that character in this line. The colon itself will be written. ||
       
  1520 || `::` || Like above, except the two colons will not be written. ||
       
  1521 || `\|` || Will be replaced with “|” without triggering a line break (escape sequence) ||
       
  1522 || `\:` || Will be replaced with “:” without triggering highlighting (escape sequence) ||
       
  1523 
       
  1524 `icon` accepts the following values:
       
  1525 
       
  1526 || *`icon`* || *What is shown* ||
       
  1527 || _negative number_ || Icon of an ammo type. It is specified as the negative of an ammo type constant (see [AmmoTypes]), i.e. `-amBazooka` for the bazooka icon. ||
       
  1528 || `0` || Golden crown ||
       
  1529 || `1` || Target ||
       
  1530 || `2` || Exclamation mark ||
       
  1531 || `3` || Question mark ||
       
  1532 || `4` || Golden star ||
       
  1533 || `5` || Utility crate ||
       
  1534 || `6` || Health crate ||
       
  1535 || `7` || Ammo crate ||
       
  1536 || `8` || Barrel ||
       
  1537 || `9` || Dud mine ||
       
  1538 
       
  1539 If the optional parameter `forceDisplay` is `true`, this mission panel cannot be removed manually by the player. It's `false` by default.
       
  1540 
       
  1541 Example:
       
  1542 <code language="lua">
       
  1543 ShowMission(loc("Nobody Laugh"), loc("User Challenge"), loc("Eliminate the enemy before the time runs out"), 0, 0)
       
  1544 </code>
       
  1545 
       
  1546 === <tt>!HideMission()</tt> ===
       
  1547 Hides the mission panel if it is currently displayed, otherwise, this function does nothing.
       
  1548 
       
  1549 === <tt>!SetZoom(zoomLevel)</tt> ===
       
  1550 Sets the zoom level. The value for maximum zoom is currently 1.0 and for minimum 3.0 The default zoom level is 2.0
       
  1551 
       
  1552 === <tt>!GetZoom()</tt> ===
       
  1553 Returns the current zoom level.
       
  1554 
       
  1555 === <tt>!SetCinematicMode(enable)</tt> (0.9.23) ===
       
  1556 Turns on or off cinematic mode. Cinematic mode can be used for cutscenes etc.
       
  1557 If `enable` is set to `true`, cinematic mode is enabled,
       
  1558 if it is `false`, cinematic mode is disabled.
       
  1559 
       
  1560 == Sound functions ==
       
  1561 === `PlaySound(soundId, [gearUid [, instaVoice]])` ===
       
  1562 Plays the specified sound. Possible values for `soundId` are listed on the [Sounds] page.
       
  1563 
       
  1564 To play a voice (see [Taunts] for a list), you must also set `gearUid`. `gearUid` is the hedgehog gear which is used to “talk”.
       
  1565 
       
  1566 If you play a voice, by default the voice will respect an internal queue and might be played with an delay in order to prevent annoying voice overlapping. Since version 0.9.24, you can disable this behaviour and force Hedgewars to instantly play the voice by also setting `instaVoice` to `true`. Only use `instaVoice` when you really need it.
       
  1567 
       
  1568 === `PlayMusicSound(soundId)` (0.9.25) ===
       
  1569 Plays a sound as replacement for the background music. The sound is played once. The main music is paused and the sound is played instead. The main background music does not resume automatically, so you should call `StopMusicSound` after a while.
       
  1570 
       
  1571 Example:
       
  1572 <code language="lua">
       
  1573 PlayMusicSound(sndRideOfTheValkyries) -- Replace the background music the Ride of the Valkyries
       
  1574 </code>
       
  1575 
       
  1576 === `StopMusicSound(soundId)` (0.9.25) ===
       
  1577 Stops the specified “music sound” (if it was still playing) and resumes the main background music.
       
  1578 
       
  1579 === `SetSoundMask(soundId, isMasked)` (0.9.24) ===
       
  1580 Disables a given sound (including taunts) from being played by the engine. `soundId` is a valid sound ID on [Sounds] or [Taunts]. `isMasked` is a boolean. If `true`, the sound will not be played by the engine anymore. If `false`, playing this sound is allowed again.
       
  1581 
       
  1582 Sounds played by the Lua function `PlaySound` will always work, however, and ignore the sound mask.
       
  1583 
       
  1584 Note: Due to the way the voices work internally in Hedgewars, if you want to play a masked voice, you have to set `instaVoice` to `true` when you call `PlaySound`. Otherwise, it won't work.
       
  1585 
       
  1586 Example:
       
  1587 
       
  1588 <code language="lua">SetSoundMask(sndIncoming, true)
       
  1589 -- Disable the “Incoming” sound from being played</code>
       
  1590 
       
  1591 == File system functions ==
       
  1592 === <tt>!HedgewarsScriptLoad(scriptPath [, mustExist])</tt> ===
       
  1593 Loads a script (i.e. a [LuaLibraries library]) from the specified `scriptPath`. The root directory is here Hedgewars’ data directory. There will be a Lua error if the script does not exist.
       
  1594 
       
  1595 If `mustExist` is `false`, no Lua error will happen even when the script does not exist.
       
  1596 
       
  1597 Returns `true` if the script was loaded successfully, `false` otherwise.
       
  1598 
       
  1599 Example:
       
  1600 <code language="lua">
       
  1601 HedgewarsScriptLoad("/Scripts/Locale.lua")  -- loads locale library
       
  1602 </code>
       
  1603 
       
  1604 == Stats functions ==
       
  1605 === <tt>!SendStat(TStatInfoType, statMessage[, teamName])</tt> ===
       
  1606 
       
  1607 This function allows to change the details of the stats screen seen after the end of a game.
       
  1608 
       
  1609 `TStatInfoType` is the piece of information you want to manipulate. The result of this functions varies greatly for different `TStatInfoType`s. The parameter `statMessage` is mandatory and is a string used for the statistics, its meaning depends on the `TStatInfoType`. The parameter `teamName` contains the name of a team which is relevant to the chosen stat. This parameter is not always required, this also depends on `TStatInfoType`.
       
  1610 
       
  1611 This tables explains the different behaviours of this function for different values of `TStatInfoType`:
       
  1612 
       
  1613 || *`TStatInfoType`* || *Meaning of `statMessage`* || *Team parameter used?* ||
       
  1614 || `siGraphTitle` || Title of the graph. If you use this, the health icon changes into a star. || No ||
       
  1615 || `siGameResult` || Title of the stats screen, used to show the result of the game, i.e. who won the game || No ||
       
  1616 || `siCustomAchievement` || A freeform text for a single “bullet point” in the “bullet point” list in the details section. For each time you call `SendStat` with this `TStatInfoType`, a new “bullet point” gets added to the list. || No ||
       
  1617 || `siPointType` || Replaces the word “kills” in the ranking list. You have to call this each time before you report the score or kills of a team with `siPlayerKills`. Sadly, grammatical number is currently not respected at all here. || No ||
       
  1618 || `siPlayerKills` || Adds a team into the ranking with the given number of kills. The order in which this is called for each team matters. Unless the word “kills” has been replaced by `siPointType`, then that word is used instead. Only integers (converted to string) are possible. || Yes ||
       
  1619 || `siClanHealth` || Value of a data point. This sets a single data point on the graph for the specified team. All teams will be converted to clans prior to drawing, there can only be one chart per clan. Subsequent calls will draw the next point along the horizontal axis; the frontend will then simply connect the dots in the final chart. Only whole numbers are supported. There must be at least 2 data points for any given clan, otherwise there won't be much to look at. ;-) You also should have called `SendHealthStatsOff` if to prevent the default health graphs to be drawn. || Yes ||
       
  1620 || `siMaxStepKills` || Most hedgehogs killed in a round. `statMessage` must be in format “`<kills> <name of killer hedgehog> (<team name of killer>)`”. || No ||
       
  1621 || `siMaxTeamDamage` || Team with most damage inflicted to self. `statMessage` must be in the format “`<damage> <team name>`”. || No ||
       
  1622 || `siKilledHHs` || Total number of killed hedgehogs (converted to string). || No ||
       
  1623 || `siTeamStats` || This does not have an effect. || No ||
       
  1624 || `siMaxStepDamage` || Most damage in one turn for the “best shot award”. `statMessage` must be in format “`<damage> <hedgehog name> (<team name>)`”. || No ||
       
  1625 || `siMaxTurnSkips` || Team with most skips. `statMessage` must be of format “`<number> <teamName>`”. || No ||
       
  1626 || `siTeamRank` || Overwrite rank of team. `statMessage` is the rank of your choice. Must be sent before `siPlayerKills` of the team in question. || No ||
       
  1627 
       
  1628 <b>Examples:</b>
       
  1629 
       
  1630 <code language="lua">
       
  1631 -- will automatically change the health icon to a star
       
  1632 SendStat(siGraphTitle,'Custom Graph Title')
       
  1633 
       
  1634 SendStat(siGameResult,'Winner is Team A!')
       
  1635 
       
  1636 SendStat(siCustomAchievement,'This is a custom message posted in the Details section!')
       
  1637 
       
  1638 -- Adds 3 teams into the ranking: First, Team A (with 3 kills), then Team B (1 kill) and then Team C (5 kills).
       
  1639 SendStat(siPlayerKills, "3", 'Team A')
       
  1640 SendStat(siPlayerKills, "1", 'Team B')
       
  1641 SendStat(siPlayerKills, "5", 'Team C')
       
  1642 
       
  1643 -- In the next ranking, this changes the word “kills” to “points”,
       
  1644 -- call it just before sending kills/score for each team
       
  1645 -- in case you want to change the word i.e. print “point” or “points”
       
  1646 SendStat(siPointType, "points")
       
  1647 
       
  1648 -- this will add Team D to the ranking and show “3 points“ in brackets (because of the siPointType above)
       
  1649 SendStat(siPlayerKills, "3", "Team D")
       
  1650 
       
  1651 -- call siClanHealth to send the "value" of a clan that will be used for the graph creation
       
  1652 -- a good idea is to call it always for every hog by using the runOnGears(function)
       
  1653 -- in normal mode "value" represents clan health
       
  1654 SendStat(siClanHealth, "100", "teamName")
       
  1655 
       
  1656 -- most hedgehogs killed in a round (hedgehogName is who killed them)
       
  1657 SendStat(siMaxStepKills, "1 hedgehogName (teamName)")
       
  1658 
       
  1659 -- team with most damage inflicted to self
       
  1660 SendStat(siMaxTeamDamage, "100 teamName")
       
  1661 
       
  1662 -- total number of killed hedgehogs
       
  1663 SendStat(siKilledHHs, "1")
       
  1664 
       
  1665 -- best shot award
       
  1666 SendStat(siMaxStepDamage, "30 hedgehogName (teamName)")
       
  1667 
       
  1668 -- team with most kills of own hedgehogs
       
  1669 SendStat(siMaxStepDamage, "2 teamName")
       
  1670 
       
  1671 -- team with most skips
       
  1672 SendStat(siMaxTurnSkips, "3 teamName")
       
  1673 
       
  1674 -- set 15 kills for team "MyTeam" and overwrite its rank to 3
       
  1675 SendStat(siPlayerKills, "15", "MyTeam")
       
  1676 SendStat(siTeamRank, "3")
       
  1677 
       
  1678 </code>
       
  1679 
       
  1680 <b>Important:</b>
       
  1681 
       
  1682   * As the game engine send stats to the frontend at the end of the game one should send her stats when the game is going to finish and right before the call of `EndGame()`. (Note: Stats are sent from the engine in `CheckForWin`. If conditions are met (win or draw) then `SendStats(uStats)` is called.)
       
  1683   * Calling just `EndGame()` won’t produce any stats.
       
  1684   * If one would like to produce a custom graph see also `SendHealthStatsOff()`.
       
  1685 
       
  1686 === <tt>!SendHealthStatsOff()</tt> ===
       
  1687 Prevents the engine of sending health stats to the frontend. 
       
  1688 
       
  1689 If any health stats haven’t been sent before this will cause the health graph to the stats page to be hidden. Use this function in the Lua scripts to produce custom graphs by calling it inside `onGameStart()` and using the `SendStat()` function.
       
  1690 f
       
  1691 === <tt>!SendAchievementsStatsOff()</tt> (0.9.23) ===
       
  1692 Prevents the engine of populating the snarky comments in the “Details” section (internally known as “achievements”) of the stats screen, such as “best shot award”, etc. So you can start with a clean list when the game ends normally. This function needs to be called inside `onGameStart()`.
       
  1693 
       
  1694 === <tt>!SendRankingStatsOff()</tt> (0.9.23) ===
       
  1695 Prevents the engine of populating the team rankings in the stats screen, so you can start with a clean list when the game ends normally. This function needs to be called inside `onGameStart()`.
       
  1696 
       
  1697 === <tt>!SendGameResultOff()</tt> (0.9.23) ===
       
  1698 Prevents the engine of setting the game result text at the top of the stats screen, e.g. “Team 1 wins!” when the game ends normally. This function needs to be called inside `onGameStart()`.
       
  1699 
       
  1700 === <tt>!GetTeamStats(teamname)</tt> (0.9.23) ===
       
  1701 Returns a table of internal stats of a team. This table has the following fields:
       
  1702 
       
  1703  * `Kills`: Number of kills
       
  1704  * `Suicides`: Number of suicides (not yet working)
       
  1705  * `AIKills`: Number of AI kills
       
  1706  * `TeamKills`: Number of hedgehogs killes in own team (excluding current hedghog)
       
  1707  * `TurnSkips`: Number of skipped turns
       
  1708  * `TeamDamage`: Damage inflicted to own team (excluding current hedgehog)
       
  1709 
       
  1710 == Math Functions ==
       
  1711 
       
  1712 === <tt>div(dividend, divisor)</tt> ===
       
  1713 Performs an integer division and returns the result.
       
  1714 The result is an integer and has the value of the first parameter (an integer) divided by the second parameter (another integer), rounded towards zero.
       
  1715 
       
  1716 === <tt>band(value1, value2)</tt> ===
       
  1717 Returns the bitwise logical AND of `value1` and `value2`.
       
  1718 
       
  1719 === <tt>bor(value1, value2)</tt> ===
       
  1720 Returns the bitwise logical OR of `value1` and `value2`.
       
  1721 
       
  1722 === <tt>bnot(value)</tt> ===
       
  1723 Returns the bitwise logical NOT of `value`.
       
  1724 
       
  1725 
       
  1726 == Debugging Functions ==
       
  1727 === <tt>WriteLnToConsole(string)</tt> ===
       
  1728 Writes `string` to `Logs/game0.log`, found in the user data directory.
       
  1729 
       
  1730 === <tt>WriteLnToChat(string)</tt> (0.9.24) ===
       
  1731 Writes `string` into the chat.
       
  1732 
       
  1733 === <tt>DumpPoint(x, y)</tt> (0.9.23) ===
       
  1734 Converts the whole numbers `x` and `y` to strings and writes them to `Logs/game0.log`, one line each.
       
  1735 
       
  1736 === <tt>StartGhostPoints(count)</tt> ===
       
  1737 Just prints out “GHOST_POINTS” and the argument on the console. This function might change in later versions.
       
  1738 
       
  1739 === <tt>DeclareAchievement(id, teamname, location, value)</tt> ===
       
  1740 Declares an achievement with the identifier `id` achieved by the team `teamname` on the map `location` with an achievement value (e.g. score) of `value`. `value` must be an integer. You are supposed to call this function inside an `onAchievementsDeclaration` callback.
       
  1741 
       
  1742 Currently, this actually just triggers a console output, but it might be changed later. The idea is to track multiplayer records.
       
  1743 
       
  1744 Example:
       
  1745 
       
  1746 <code language="lua">DeclareAchievement("height reached", teamname, "ClimbHome", -score)</code>
       
  1747 Records a team's best height in !ClimbHome.
       
  1748 
       
  1749 === <tt>!ParseCommand(string)</tt> ===
       
  1750 Makes the game client parse and execute the specified internal game engine command.
       
  1751 
       
  1752 The available commands depend on the current engine protocol version. The *engine protocol can (and will) change* between releases.
       
  1753 
       
  1754 *Important*: If you use `ParseCommand` to overcome a shortcoming in our Lua API (e.g. a missing function), please make sure to [https://issues.hedgewars.org/enter_bug.cgi report the issue].
       
  1755 
       
  1756 With your report we can fix the shortcoming in future releases. We will try to remove the reliance on `ParseCommand` as good as possible. This will allow scripts to use the previously missing feature in a way that won’t break!
       
  1757 
       
  1758 There are many available commands, but actual use in scripting is rare, and even then it's discouraged for long-term use. As of 0.9.24, the only command used in official scripts is:
       
  1759 
       
  1760  * `"draw <map>"`: Draws a hand-drawn map. `MapGen` must be `mgDrawn` for this to work. `<map>` is a string which must follow the format specified in [DrawnMapFormat]
       
  1761 
       
  1762 Moreover, the control action names as listed in [ConfigurationFiles] (under “Binds”) can be used. Note we will eventually try to remove all `ParseCommand`s in the official scripts.
       
  1763 
       
  1764 === <tt>!EndLuaTest(success)</tt> ===
       
  1765 This function is used by the Hedgewars developers in testing scripts in order to test the game engine. The testing scripts can be found in the Hedgewars source code under `tests/lua`. This function is useless for anything else.
       
  1766 
       
  1767 Calling this function ends an engine test and reports a test result.
       
  1768 
       
  1769 `success` is either one of `TEST_SUCCESSFUL` to report a successful test or `TEST_FAILED` for a failed test.
       
  1770 
       
  1771 See [EngineTestCases] to learn more about testing the engine.
       
  1772 
       
  1773 == Undocumented functions ==
       
  1774 This page might become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php].