LuaAPI.wiki
changeset 1232 4ac63a5c0184
parent 1231 550b1afc9300
child 1235 dae4580eca94
equal deleted inserted replaced
1231:550b1afc9300 1232:4ac63a5c0184
   194 === <tt>onGameStart()</tt> ===
   194 === <tt>onGameStart()</tt> ===
   195 This function is called when the first round starts.
   195 This function is called when the first round starts.
   196 
   196 
   197 Can be used to show the mission and for more setup, for example initial target spawning.
   197 Can be used to show the mission and for more setup, for example initial target spawning.
   198 
   198 
   199 === <tt>onPreviewInit()</tt> (0.9.21) ===
   199 === <tt>onPreviewInit()</tt> ===
   200 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.
   200 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.
   201 
   201 
   202 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.
   202 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.
   203 
   203 
   204 === <tt>onParameters()</tt> (0.9.21) ===
   204 === <tt>onParameters()</tt> ===
   205 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`.
   205 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`.
   206 
   206 
   207 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.
   207 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.
   208 
   208 
   209 *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).
   209 *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).
   226 
   226 
   227 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.
   227 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.
   228 
   228 
   229 Because this function is called *before* victories are checked, this is useful to set up your victory conditions here.
   229 Because this function is called *before* victories are checked, this is useful to set up your victory conditions here.
   230 
   230 
   231 === <tt>onSuddenDeath()</tt> (0.9.22) ===
   231 === <tt>onSuddenDeath()</tt> ===
   232 This function is called on the start of Sudden Death.
   232 This function is called on the start of Sudden Death.
   233 
   233 
   234 === <tt>onGearAdd(gearUid)</tt> ===
   234 === <tt>onGearAdd(gearUid)</tt> ===
   235 This function is called when a new gear is added. Useful in combination with `GetGearType(gearUid)`.
   235 This function is called when a new gear is added. Useful in combination with `GetGearType(gearUid)`.
   236 
   236 
   267 If neither is set, the parameters passed are the team index and `-1`, and the function will be called once for each team.
   267 If neither is set, the parameters passed are the team index and `-1`, and the function will be called once for each team.
   268 
   268 
   269 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.
   269 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.
   270 If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from `onAmmoStoreInit` are ignored.
   270 If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from `onAmmoStoreInit` are ignored.
   271 
   271 
   272 === <tt>onGearWaterSkip(gear)</tt> (0.9.21) ===
   272 === <tt>onGearWaterSkip(gear)</tt> ===
   273 This function is called when the gear `gear` skips over water.
   273 This function is called when the gear `gear` skips over water.
   274 
   274 
   275 === <tt>onScreenResize()</tt> (0.9.16) ===
   275 === <tt>onScreenResize()</tt> ===
   276 This function is called when you resize the screen. Useful place to put a redraw function for any `vgtHealthTags` you're using.
   276 This function is called when you resize the screen. Useful place to put a redraw function for any `vgtHealthTags` you're using.
   277 
   277 
   278 === <tt>onAttack()</tt> ===
   278 === <tt>onAttack()</tt> ===
   279 This function is called when your Hedgehog attacks.
   279 This function is called when your Hedgehog attacks.
   280 
   280 
   355 === <tt>onUsedAmmo(ammoType)</tt> (0.9.23) ===
   355 === <tt>onUsedAmmo(ammoType)</tt> (0.9.23) ===
   356 Called after a weapon has been used completely, with `ammoType` as the used ammo type.
   356 Called after a weapon has been used completely, with `ammoType` as the used ammo type.
   357 
   357 
   358 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.
   358 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.
   359 
   359 
   360 === <tt>onHogHide(gearUid)</tt> (0.9.16) ===
   360 === <tt>onHogHide(gearUid)</tt> ===
   361 This function is called when a hedgehog with the gear ID `gearUid` is hidden (removed from the map).
   361 This function is called when a hedgehog with the gear ID `gearUid` is hidden (removed from the map).
   362 
   362 
   363 === <tt>onHogRestore(gearUid)</tt> (0.9.16) ===
   363 === <tt>onHogRestore(gearUid)</tt> ===
   364 This function is called when a hedgehog with the specified gear ID `gearUid` is restored (unhidden).
   364 This function is called when a hedgehog with the specified gear ID `gearUid` is restored (unhidden).
   365 
   365 
   366 === <tt>onSpritePlacement(spriteId, centerX, centerY)</tt> (0.9.21) ===
   366 === <tt>onSpritePlacement(spriteId, centerX, centerY)</tt> ===
   367 This function is called when a [Sprites Sprite] has been placed.
   367 This function is called when a [Sprites Sprite] has been placed.
   368 
   368 
   369 `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.
   369 `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.
   370 
   370 
   371 === <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) ===
   371 === <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> ===
   372 This function is called when a girder has been placed.
   372 This function is called when a girder has been placed.
   373 
   373 
   374 `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.
   374 `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.
   375 
   375 
   376 === <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) ===
   376 === <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> ===
   377 This function is called when a rubber has been placed.
   377 This function is called when a rubber has been placed.
   378 
   378 
   379 `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.
   379 `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.
   380 
   380 
   381 === `onSpecialPoint(x, y, flags)` ===
   381 === `onSpecialPoint(x, y, flags)` ===
   512 See `SetEffect` for further details.
   512 See `SetEffect` for further details.
   513 
   513 
   514 === <tt>!GetHogHat(gearUid)</tt> ===
   514 === <tt>!GetHogHat(gearUid)</tt> ===
   515 Returns the hat of the specified hedgehog gear.
   515 Returns the hat of the specified hedgehog gear.
   516 
   516 
   517 === <tt>!GetHogFlag(gearUid)</tt> (0.9.22) ===
   517 === <tt>!GetHogFlag(gearUid)</tt> ===
   518 Returns the name of the flag of the team of the specified hedgehog gear.
   518 Returns the name of the flag of the team of the specified hedgehog gear.
   519 
   519 
   520 === <tt>!GetHogFort(gearUid)</tt> (0.9.23) ===
   520 === <tt>!GetHogFort(gearUid)</tt> (0.9.23) ===
   521 Returns the name of the fort of the team of the specified hedgehog gear.
   521 Returns the name of the fort of the team of the specified hedgehog gear.
   522 
   522 
   523 === <tt>!GetHogGrave(gearUid)</tt> (0.9.22) ===
   523 === <tt>!GetHogGrave(gearUid)</tt> ===
   524 Returns the name of the grave of the team of the specified hedgehog gear.
   524 Returns the name of the grave of the team of the specified hedgehog gear.
   525 
   525 
   526 === <tt>!GetHogVoicepack(gearUid)</tt> (0.9.22) ===
   526 === <tt>!GetHogVoicepack(gearUid)</tt> ===
   527 Returns the name of the voicepack of the team of the specified hedgehog gear.
   527 Returns the name of the voicepack of the team of the specified hedgehog gear.
   528 
   528 
   529 === <tt>!GetAmmoCount(gearUid, ammoType)</tt> (0.9.16) ===
   529 === <tt>!GetAmmoCount(gearUid, ammoType)</tt> ===
   530 Returns the ammo count of the specified ammo type for the specified hedgehog gear.
   530 Returns the ammo count of the specified ammo type for the specified hedgehog gear.
   531 
   531 
   532 === <tt>!IsHogLocal(gearUid)</tt> (0.9.23) ===
   532 === <tt>!IsHogLocal(gearUid)</tt> (0.9.23) ===
   533 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.
   533 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.
   534 
   534 
   535 This is perfect to hide certain captions like weapon messages from enemy eyes.
   535 This is perfect to hide certain captions like weapon messages from enemy eyes.
   536 
   536 
   537 === <tt>!GetGearTarget(gearUid, x, y)  (0.9.16)</tt> ===
   537 === <tt>!GetGearTarget(gearUid, x, y) </tt> ===
   538 Returns the x and y coordinate of target-based weapons/utilities. 
   538 Returns the x and y coordinate of target-based weapons/utilities. 
   539 <b>Note:</b>: This can’t be used in `onGearAdd()` but must be called after gear creation. 
   539 <b>Note:</b>: This can’t be used in `onGearAdd()` but must be called after gear creation. 
   540 
   540 
   541 === <tt>GetX(gearUid)</tt> ===
   541 === <tt>GetX(gearUid)</tt> ===
   542 Returns x coordinate of the gear.
   542 Returns x coordinate of the gear.
   608 === <tt>!GetGearPos(gearUid)</tt> ===
   608 === <tt>!GetGearPos(gearUid)</tt> ===
   609 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. 
   609 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. 
   610 
   610 
   611 *Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that.
   611 *Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that.
   612 
   612 
   613 === <tt>!GetGearValues(gearUid)</tt> (0.9.22) ===
   613 === <tt>!GetGearValues(gearUid)</tt> ===
   614 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.
   614 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.
   615 
   615 
   616 This is returned (all variables are integers):
   616 This is returned (all variables are integers):
   617 
   617 
   618 `Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom`
   618 `Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom`
   619 
       
   620 Boom is 0.9.23+
       
   621 
   619 
   622 A rough description of some of the parameters:
   620 A rough description of some of the parameters:
   623 
   621 
   624  * `Radius`: Effect or collision radius, most of the time
   622  * `Radius`: Effect or collision radius, most of the time
   625  * `ImpactSound`: Sound it makes on a collision (see [Sounds])
   623  * `ImpactSound`: Sound it makes on a collision (see [Sounds])
   626  * `Tint`: Used by some gear types to determine its colorization. The color is in RGBA format.
   624  * `Tint`: Used by some gear types to determine its colorization. The color is in RGBA format.
   627  * `Boom`: Used by most gears to determine the damage dealt. (0.9.23+)
   625  * `Boom`: Used by most gears to determine the damage dealt.
   628 
   626 
   629 Example:
   627 Example:
   630 <code language="lua">
   628 <code language="lua">
   631 -- Get all values in a single line of code (omit Boom in 0.9.22) :
   629 -- Get all values in a single line of code:
   632 local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom = GetGearValues(myGear)
   630 local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom = GetGearValues(myGear)
   633 </code>
   631 </code>
   634 
   632 
   635 === <tt>!GetVisualGearValues(vgUid)</tt> ===
   633 === <tt>!GetVisualGearValues(vgUid)</tt> ===
   636 This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values:
   634 This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values:
   686 Example:
   684 Example:
   687 
   685 
   688 <code language="lua">    vgear = AddVisualGear(...)
   686 <code language="lua">    vgear = AddVisualGear(...)
   689     DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code>
   687     DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code>
   690 
   688 
   691 === <tt>!SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)</tt> (0.9.22) ===
   689 === <tt>!SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)</tt> ===
   692 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.  Boom is 0.9.23+.
   690 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.
   693 
   691 
   694 Set `nil` for each value you do not want to change.
   692 Set `nil` for each value you do not want to change.
   695 
   693 
   696 Example:
   694 Example:
   697 <code language="lua">
   695 <code language="lua">
   732     SetVisualGearValues(circleUid, 1000, 1000)</code>
   730     SetVisualGearValues(circleUid, 1000, 1000)</code>
   733 <code language="lua">  -- set the tint of a visual gear to bright red.
   731 <code language="lua">  -- set the tint of a visual gear to bright red.
   734     SetVisualGearValues(circleUid, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff0000ff)</code>
   732     SetVisualGearValues(circleUid, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff0000ff)</code>
   735 
   733 
   736 
   734 
   737 === <tt>!FindPlace(gearUid, fall, left, right, tryHarder) (0.9.16)</tt> ===
   735 === <tt>!FindPlace(gearUid, fall, left, right[, tryHarder])</tt> ===
   738 Finds a place for the specified gear between x=`left` and x=`right` and places it there. 0.9.16 adds an optional fifth parameter, `tryHarder`. Setting to `true`/`false` will determine whether the engine attempts to make additional passes, even attempting to place gears on top of each other.
   736 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.
   739 
   737 
   740 Example:
   738 Example:
   741 
   739 
   742 <code language="lua">    gear = AddGear(...)
   740 <code language="lua">    gear = AddGear(...)
   743     FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code>
   741     FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code>
   744 === <tt>!HogSay(gearUid, text, manner [,vgState])</tt> ===
   742 === <tt>!HogSay(gearUid, text, manner [,vgState])</tt> ===
   745 Makes the specified gear say, think, or shout some text in a comic-style speech or thought bubble. In 0.9.21 `gearUid` is _not_ limited to hedgehogs, altough the function name suggests otherwise.
   743 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.
   746 
   744 
   747 The `manner` parameter specifies the type of the bubble and can have one of these values:
   745 The `manner` parameter specifies the type of the bubble and can have one of these values:
   748 
   746 
   749 || *Value of `manner`* || *Looks* ||
   747 || *Value of `manner`* || *Looks* ||
   750 || `SAY_THINK` || Thought bubble ||
   748 || `SAY_THINK` || Thought bubble ||
   751 || `SAY_SAY` || Speech bubble ||
   749 || `SAY_SAY` || Speech bubble ||
   752 || `SAY_SHOUT` || Exclamatory bubble (denotes shouting) ||
   750 || `SAY_SHOUT` || Exclamatory bubble (denotes shouting) ||
   753 
   751 
   754 As of 0.9.21, 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.
   752 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.
   755 
   753 
   756 || *Value of `vgState`* || *Effect* ||
   754 || *Value of `vgState`* || *Effect* ||
   757 || `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. ||
   755 || `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. ||
   758 || `1` || The bubble is drawn translucent. ||
   756 || `1` || The bubble is drawn translucent. ||
   759 || `2` || The bubble is drawn fully opaque. ||
   757 || `2` || The bubble is drawn fully opaque. ||
   876         if (GetGearType(gear) == gtHedgehog) and (GetHogLevel(gear) > 0) then
   874         if (GetGearType(gear) == gtHedgehog) and (GetHogLevel(gear) > 0) then
   877             SetEffect(gear, hePoisoned, 1)
   875             SetEffect(gear, hePoisoned, 1)
   878         end
   876         end
   879     end</code>
   877     end</code>
   880 
   878 
   881 *Historic note*: prior to the ice-gun release, 0.9.19 (commit r10a0a31804f3) `effectState` was of boolean type (`true` = effect enabled, `false` = effect disabled)
       
   882 
       
   883 === <tt>CopyPV(gearUid, gearUid)</tt> ===
   879 === <tt>CopyPV(gearUid, gearUid)</tt> ===
   884 This sets the position and velocity of the second gear to the first one.
   880 This sets the position and velocity of the second gear to the first one.
   885 
   881 
   886 === <tt>!FollowGear(gearUid)</tt> ===
   882 === <tt>!FollowGear(gearUid)</tt> ===
   887 Makes the game client follow the specifiec gear.
   883 Makes the game client follow the specifiec gear.
   900 <code language="lua">
   896 <code language="lua">
   901   AddAmmo(CurrentHedgehog, amBazooka, 1) -- give the CurrentHedgehog a bazooka
   897   AddAmmo(CurrentHedgehog, amBazooka, 1) -- give the CurrentHedgehog a bazooka
   902   SetWeapon(amBazooka) -- select the Bazooka.</code>
   898   SetWeapon(amBazooka) -- select the Bazooka.</code>
   903 
   899 
   904 
   900 
   905 === <tt>!SetNextWeapon()</tt> (0.9.21) ===
   901 === <tt>!SetNextWeapon()</tt> ===
   906 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.
   902 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.
   907 
   903 
   908 
   904 
   909 === <tt>!SetHogHat(gearUid, hat)</tt> ===
   905 === <tt>!SetHogHat(gearUid, hat)</tt> ===
   910 Sets the hat of the specified hedgehog gear.
   906 Sets the hat of the specified hedgehog gear.
   911 
   907 
   912 === <tt>!SetGearTarget(gearUid, x, y) (0.9.16)</tt> ===
   908 === <tt>!SetGearTarget(gearUid, x, y)</tt> ===
   913 Sets the x and y coordinate of target-based weapons/utilities.
   909 Sets the x and y coordinate of target-based weapons/utilities.
   914 *Note*: This can’t be used in onGearAdd() but must be called after gear creation.
   910 *Note*: This can’t be used in onGearAdd() but must be called after gear creation.
   915 
   911 
   916 === <tt>!SetState(gearUid, state)</tt> ===
   912 === <tt>!SetState(gearUid, state)</tt> ===
   917 Sets the state of the specified gear to the specified `state`. This is a bitmask made out of the variables as seen in [States].
   913 Sets the state of the specified gear to the specified `state`. This is a bitmask made out of the variables as seen in [States].
   968 
   964 
   969 <code language="lua">
   965 <code language="lua">
   970 SetGearAIHints(uselessHog, aihDoesntMatter)
   966 SetGearAIHints(uselessHog, aihDoesntMatter)
   971 -- This makes AI hogs stop caring about attacking uselessHog</code>
   967 -- This makes AI hogs stop caring about attacking uselessHog</code>
   972 
   968 
   973 === <tt>!SetGearPos(gearUid, value) (0.9.18-dev)</tt> ===
   969 === <tt>!SetGearPos(gearUid, value)</tt> ===
   974 Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information.
   970 Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information.
   975 
   971 
   976 == Gameplay functions ==
   972 == Gameplay functions ==
   977 
   973 
   978 === `GameFlags` functions ===
   974 === `GameFlags` functions ===
  1005 Sets the current wind in the range of -100 to 100 inclusive. Use together with `gfDisableWind` for full control.
  1001 Sets the current wind in the range of -100 to 100 inclusive. Use together with `gfDisableWind` for full control.
  1006 
  1002 
  1007 ==== <tt>!GetWind()</tt> (0.9.24) ====
  1003 ==== <tt>!GetWind()</tt> (0.9.24) ====
  1008 Returns current wind, expressed as a floating point number between -100 to 100 inclusive. Note there may be rounding errors.
  1004 Returns current wind, expressed as a floating point number between -100 to 100 inclusive. Note there may be rounding errors.
  1009 
  1005 
  1010 ==== <tt>!SetMaxBuildDistance(distInPx)</tt> (0.9.22) ====
  1006 ==== <tt>!SetMaxBuildDistance(distInPx)</tt> ====
  1011 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.
  1007 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.
  1012 
  1008 
  1013 ==== `EndTurn([noTaunts])` (0.9.23) ====
  1009 ==== `EndTurn([noTaunts])` (0.9.23) ====
  1014 Ends the current turn.
  1010 Ends the current turn.
  1015 
  1011 
  1059 Example:
  1055 Example:
  1060 <code language="lua">
  1056 <code language="lua">
  1061 -- Appends a text to the ammo tooltip of the bazooka but leaves name and main description intact
  1057 -- Appends a text to the ammo tooltip of the bazooka but leaves name and main description intact
  1062 SetAmmoTexts(amBazooka, "This weapon deals double the damage than usually.")</code>
  1058 SetAmmoTexts(amBazooka, "This weapon deals double the damage than usually.")</code>
  1063 
  1059 
  1064 ==== <tt>!AddAmmo(gearUid, ammoType, ammoCount) (0.9.16) </tt> ====
  1060 ==== <tt>!AddAmmo(gearUid, ammoType, ammoCount)</tt> ====
  1065 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 100 will give infinite ammo.
  1061 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 100 will give infinite ammo.
  1066 
  1062 
  1067 ==== <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> (0.9.23) ====
  1063 ==== <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> (0.9.23) ====
  1068 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`.
  1064 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`.
  1069 
  1065 
  1070 === Map ===
  1066 === Map ===
  1071 ==== <tt>!MapHasBorder()</tt> ====
  1067 ==== <tt>!MapHasBorder()</tt> ====
  1072 Returns `true`/`false` if the map has a border or not.
  1068 Returns `true`/`false` if the map has a border or not.
  1073 
  1069 
  1074 ==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) </tt> ====
  1070 ==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly)</tt> ====
  1075 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.).
  1071 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.).
  1076 
  1072 
  1077 ==== <tt>!PlaceGirder(x, y, frameIdx)</tt> (0.9.16) ====
  1073 ==== <tt>!PlaceGirder(x, y, frameIdx)</tt> ====
  1078 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.
  1074 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.
  1079 
  1075 
  1080 These are the accepted values for `frameIdx`:
  1076 These are the accepted values for `frameIdx`:
  1081 
  1077 
  1082 || *`frameIdx`* || *Length* || *Orientation* ||
  1078 || *`frameIdx`* || *Length* || *Orientation* ||
  1112  * `sprHHTelepMask`
  1108  * `sprHHTelepMask`
  1113  * `sprTurnsLeft`
  1109  * `sprTurnsLeft`
  1114  * `sprSpeechCorner`
  1110  * `sprSpeechCorner`
  1115  * `sprSpeechEdge`
  1111  * `sprSpeechEdge`
  1116  * `sprSpeechTail`
  1112  * `sprSpeechTail`
  1117  * `sprTargetBee` (since 0.9.23)
  1113  * `sprTargetBee`
  1118  * `sprThoughtCorner`
  1114  * `sprThoughtCorner`
  1119  * `sprThoughtEdge`
  1115  * `sprThoughtEdge`
  1120  * `sprThoughtTail`
  1116  * `sprThoughtTail`
  1121  * `sprShoutCorner`
  1117  * `sprShoutCorner`
  1122  * `sprShoutEdge`
  1118  * `sprShoutEdge`
  1148 <code language="lua">EraseSprite(2836, 634, sprAmGirder, 5)
  1144 <code language="lua">EraseSprite(2836, 634, sprAmGirder, 5)
  1149 -- Removes the girder sprite at (2836, 634). The frameIdx 5 is for the long decreasing right girder.</code>
  1145 -- Removes the girder sprite at (2836, 634). The frameIdx 5 is for the long decreasing right girder.</code>
  1150 <code language="lua">EraseSprite(1411, 625, sprAmRubber, 1, true, true, nil, nil, lfIndestructible)
  1146 <code language="lua">EraseSprite(1411, 625, sprAmRubber, 1, true, true, nil, nil, lfIndestructible)
  1151 -- Removes indestructibility from a rubber band sprite at (2836, 634). The frameIdx 1 is for the decreasing right rubber band.</code>
  1147 -- Removes indestructibility from a rubber band sprite at (2836, 634). The frameIdx 1 is for the decreasing right rubber band.</code>
  1152 
  1148 
  1153 ==== <tt>!AddPoint(x, y [, width [, erase] ])</tt> (0.9.21) ====
  1149 ==== <tt>!AddPoint(x, y [, width [, erase] ])</tt> ====
  1154 This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”.
  1150 This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”.
  1155 
  1151 
  1156 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).
  1152 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).
  1157 
  1153 
  1158 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.
  1154 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.
  1159 
  1155 
  1160 ==== <tt>!FlushPoints()</tt> (0.9.21) ====
  1156 ==== <tt>!FlushPoints()</tt> ====
  1161 Makes sure that all the points/lines specified using `AddPoint` are actually applied to the map. This function must be called within `onGameInit`.
  1157 Makes sure that all the points/lines specified using `AddPoint` are actually applied to the map. This function must be called within `onGameInit`.
  1162 
  1158 
  1163 === Current hedgehog ===
  1159 === Current hedgehog ===
  1164 
  1160 
  1165 ==== <tt>!GetCurAmmoType()</tt> (0.9.16) ====
  1161 ==== <tt>!GetCurAmmoType()</tt> ====
  1166 Returns the currently selected [AmmoTypes Ammo Type].
  1162 Returns the currently selected [AmmoTypes Ammo Type].
  1167 
  1163 
  1168 ==== <tt>!SwitchHog(gearUid)</tt> (0.9.16) ====
  1164 ==== <tt>!SwitchHog(gearUid)</tt> ====
  1169 This function will switch to the hedgehog with the specifiedd `gearUid`.
  1165 This function will switch to the hedgehog with the specifiedd `gearUid`.
  1170 
  1166 
  1171 ==== <tt>!SetInputMask(mask)</tt> ====
  1167 ==== <tt>!SetInputMask(mask)</tt> ====
  1172 Masks specified player input. This means that Hedgewars ignores certain player inputs, such as walking or jumping.
  1168 Masks specified player input. This means that Hedgewars ignores certain player inputs, such as walking or jumping.
  1173 
  1169 
  1292 
  1288 
  1293 `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.
  1289 `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.
  1294 
  1290 
  1295 `text` uses some special characters for formatting: `|` is used for a line break, and everything written before and including a `:` in a line is written in a lighter color.
  1291 `text` uses some special characters for formatting: `|` is used for a line break, and everything written before and including a `:` in a line is written in a lighter color.
  1296 
  1292 
  1297 As of version 0.9.22, `icon` accepts the following values:
  1293 `icon` accepts the following values:
  1298 
  1294 
  1299 || *`icon`* || *What is shown* ||
  1295 || *`icon`* || *What is shown* ||
  1300 || _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. ||
  1296 || _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. ||
  1301 || `0` || Golden crown ||
  1297 || `0` || Golden crown ||
  1302 || `1` || Target ||
  1298 || `1` || Target ||
  1305 || `4` || Golden star ||
  1301 || `4` || Golden star ||
  1306 || `5` || Utility crate ||
  1302 || `5` || Utility crate ||
  1307 || `6` || Health crate ||
  1303 || `6` || Health crate ||
  1308 || `7` || Ammo crate ||
  1304 || `7` || Ammo crate ||
  1309 || `8` || Barrel ||
  1305 || `8` || Barrel ||
  1310 || `9` || Dud mine (0.9.23) ||
  1306 || `9` || Dud mine ||
  1311 
  1307 
  1312 Example:
  1308 Example:
  1313 <code language="lua">
  1309 <code language="lua">
  1314 ShowMission(loc("Nobody Laugh"), loc("User Challenge"), loc("Eliminate the enemy before the time runs out"), 0, 0)
  1310 ShowMission(loc("Nobody Laugh"), loc("User Challenge"), loc("Eliminate the enemy before the time runs out"), 0, 0)
  1315 </code>
  1311 </code>
  1345 <code language="lua">
  1341 <code language="lua">
  1346 HedgewarsScriptLoad("/Scripts/Locale.lua")  -- loads locale library
  1342 HedgewarsScriptLoad("/Scripts/Locale.lua")  -- loads locale library
  1347 </code>
  1343 </code>
  1348 
  1344 
  1349 == Stats functions ==
  1345 == Stats functions ==
  1350 === <tt>!SendStat(TStatInfoType, statMessage[, teamName])</tt> (0.9.20) ===
  1346 === <tt>!SendStat(TStatInfoType, statMessage[, teamName])</tt> ===
  1351 
  1347 
  1352 This function allows to change the details of the stats screen seen after the end of a game.
  1348 This function allows to change the details of the stats screen seen after the end of a game.
  1353 
  1349 
  1354 `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`.
  1350 `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`.
  1355 
  1351 
  1407 
  1403 
  1408   * 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.)
  1404   * 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.)
  1409   * Calling just `EndGame()` won’t produce any stats.
  1405   * Calling just `EndGame()` won’t produce any stats.
  1410   * If one would like to produce a custom graph see also `SendHealthStatsOff()`.
  1406   * If one would like to produce a custom graph see also `SendHealthStatsOff()`.
  1411 
  1407 
  1412 === <tt>!SendHealthStatsOff()</tt> (0.9.20) ===
  1408 === <tt>!SendHealthStatsOff()</tt> ===
  1413 Prevents the engine of sending health stats to the frontend. 
  1409 Prevents the engine of sending health stats to the frontend. 
  1414 
  1410 
  1415 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.
  1411 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.
  1416 
  1412 
  1417 === <tt>!SendAchievementsStatsOff()</tt> (0.9.23) ===
  1413 === <tt>!SendAchievementsStatsOff()</tt> (0.9.23) ===