LuaEvents.wiki
changeset 1770 729bef6b40da
parent 1769 bae9bae61cda
child 1774 086bebb89963
equal deleted inserted replaced
1769:bae9bae61cda 1770:729bef6b40da
     3 = Lua API: Event handlers =
     3 = Lua API: Event handlers =
     4 Event handlers are [LuaAPI Lua] functions that Hedgewars calls on certain events. Lua scripts are supposed to _define_ these functions to do something. The functions are then _called_ by Hedgewars when a certain event has occured. For an example of how this works, see [LuaGuide].
     4 Event handlers are [LuaAPI Lua] functions that Hedgewars calls on certain events. Lua scripts are supposed to _define_ these functions to do something. The functions are then _called_ by Hedgewars when a certain event has occured. For an example of how this works, see [LuaGuide].
     5 
     5 
     6 This page is a list of all supported event handlers in Hedgewars.
     6 This page is a list of all supported event handlers in Hedgewars.
     7 
     7 
     8 <wiki:toc max_depth="2" />
     8 <wiki:toc max_depth="3" />
     9 
     9 
    10 == <tt>onGameInit()</tt> ==
    10 == Initialization ==
       
    11 === <tt>onGameInit()</tt> ===
    11 This function is called before the game loads its resources. One can read and modify various [LuaGlobals#Game_variables game variables] here. These variables will become globally available after `onGameInit` has been invoked, but changing them has only an effect in `onGameInit`.
    12 This function is called before the game loads its resources. One can read and modify various [LuaGlobals#Game_variables game variables] here. These variables will become globally available after `onGameInit` has been invoked, but changing them has only an effect in `onGameInit`.
    12 Most game 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.
    13 Most game 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.
    13 
    14 
    14 For a list of game variables that can be set here, see [LuaGlobals#Game_variables].
    15 For a list of game variables that can be set here, see [LuaGlobals#Game_variables].
    15 
    16 
    16 == <tt>onGameStart()</tt> ==
    17 === <tt>onGameStart()</tt> ===
    17 This function is called when the first round starts.
    18 This function is called when the first round starts.
    18 
    19 
    19 Can be used to show the mission and for more setup, for example initial target spawning.
    20 Can be used to show the mission and for more setup, for example initial target spawning.
    20 
    21 
    21 At this stage, the global variables `LeftX`, `RightX`, `TopY`, `LAND_WIDTH` and `LAND_HEIGHT` become available.
    22 At this stage, the global variables `LeftX`, `RightX`, `TopY`, `LAND_WIDTH` and `LAND_HEIGHT` become available.
    22 
    23 
    23 == <tt>onPreviewInit()</tt> ==
    24 === <tt>onPreviewInit()</tt> ===
    24 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.
    25 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.
    25 
    26 
    26 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.
    27 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.
    27 
    28 
    28 == <tt>onParameters()</tt> ==
    29 === <tt>onParameters()</tt> ===
    29 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`.
    30 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`.
    30 
    31 
    31 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.
    32 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.
    32 
    33 
    33 *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).
    34 *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).
    34 
    35 
    35 *Tip*: If you use this callback, make sure to document the interpretation of the parameters so others know how to set the parameters properly.
    36 *Tip*: If you use this callback, make sure to document the interpretation of the parameters so others know how to set the parameters properly.
    36 
    37 
    37 == <tt>onGameTick()</tt> ==
    38 === <tt>onAmmoStoreInit()</tt> ===
    38 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`.
       
    39 
       
    40 == <tt>onGameTick20()</tt> ==
       
    41 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.
       
    42 
       
    43 == <tt>onNewTurn()</tt> ==
       
    44 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`)
       
    45 
       
    46 == <tt>onCaseDrop(gear)</tt> (1.0.0) ==
       
    47 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.
       
    48 
       
    49 If a crate was dropped, `gear` is the crate gear that was dropped, if no crate was dropped, `gear` is `nil`.
       
    50 
       
    51 This function is useful to add custom crate drops as well.
       
    52 
       
    53 == <tt>onEndTurn()</tt> (0.9.24) ==
       
    54 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.
       
    55 
       
    56 `CurrentHedgehog` holds the gear ID of the hedgehog whose turn just ended.
       
    57 
       
    58 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.
       
    59 
       
    60 Because this function is called *before* victories are checked, this is useful to set up your victory conditions here.
       
    61 
       
    62 == <tt>onSkipTurn()</tt> (0.9.24) ==
       
    63 This function calls when a hog skips its turn.
       
    64 
       
    65 == <tt>onGameResult(winningClan)</tt> (0.9.25) ==
       
    66 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.
       
    67 
       
    68 == <tt>onSuddenDeath()</tt> ==
       
    69 This function is called on the start of Sudden Death.
       
    70 
       
    71 == <tt>onGearAdd(gearUid)</tt> ==
       
    72 This function is called when a new gear is added. Useful in combination with `GetGearType(gearUid)`.
       
    73 
       
    74 == <tt>onGearDelete(gearUid)</tt> ==
       
    75 This function is called when a new gear is deleted. Useful in combination with `GetGearType(gearUid)`.
       
    76 
       
    77 == <tt>onVisualGearAdd(vgUid)</tt> ==
       
    78 This function is called when a new visual gear is added. Useful in combination with `GetVisualGearType(vgUid)`.
       
    79 
       
    80 == <tt>onVisualGearDelete(vgUid)</tt> ==
       
    81 This function is called when a new visual gear is deleted. Useful in combination with `GetVisualGearType(vgUid)`.
       
    82 
       
    83 == <tt>onGearDamage(gearUid, damage)</tt> ==
       
    84 This function is called when a gear is damaged.
       
    85 
       
    86 Example:
       
    87 
       
    88 <code language="lua">    function onGearDamage(gear, damage)
       
    89         if (GetGearType(gear) == gtHedgehog) then
       
    90             -- adds a message saying, e.g. "Hoggy H took 25 points of damage"
       
    91             AddCaption(GetHogName(gear) .. ' took ' .. damage .. ' points of damage')
       
    92         end
       
    93     end</code>
       
    94 == <tt>onGearResurrect(gearUid, spawnedVGear) </tt> ==
       
    95 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.
       
    96 
       
    97 `spawnedVGear` is a visual gear handle of the “resurrection effect”. You can use this handle to modify or delete the resurrection animation.
       
    98 
       
    99 == <tt>onAmmoStoreInit()</tt> ==
       
   100 This function is called when the game is initialized to request the available ammo and ammo probabilities. Use `SetAmmo` here.
    39 This function is called when the game is initialized to request the available ammo and ammo probabilities. Use `SetAmmo` here.
   101 
    40 
   102 == <tt>onNewAmmoStore(team/clan index, hog index)</tt> ==
    41 === <tt>onNewAmmoStore(team/clan index, hog index)</tt> ===
   103 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.
    42 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.
   104 If `gfSharedAmmo` is set, the parameters passed are the clan index, and `-1`, and the function will be called once for each clan.
    43 If `gfSharedAmmo` is set, the parameters passed are the clan index, and `-1`, and the function will be called once for each clan.
   105 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.
    44 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.
   106 If neither is set, the parameters passed are the team index and `-1`, and the function will be called once for each team.
    45 If neither is set, the parameters passed are the team index and `-1`, and the function will be called once for each team.
   107 
    46 
   108 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.
    47 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.
   109 If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from `onAmmoStoreInit` are ignored.
    48 If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from `onAmmoStoreInit` are ignored.
   110 
    49 
   111 == <tt>onGearWaterSkip(gear)</tt> ==
    50 == Game events ==
   112 This function is called when the gear `gear` skips over water.
    51 === <tt>onGameTick()</tt> ===
   113 
    52 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`.
   114 == <tt>onScreenResize()</tt> ==
    53 
   115 This function is called when you resize the screen. Useful place to put a redraw function for any `vgtHealthTags` you're using.
    54 === <tt>onGameTick20()</tt> ===
   116 
    55 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.
   117 == <tt>onAttack()</tt> ==
    56 
       
    57 === <tt>onNewTurn()</tt> ===
       
    58 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`)
       
    59 
       
    60 === <tt>onEndTurn()</tt> (0.9.24) ===
       
    61 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.
       
    62 
       
    63 `CurrentHedgehog` holds the gear ID of the hedgehog whose turn just ended.
       
    64 
       
    65 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.
       
    66 
       
    67 Because this function is called *before* victories are checked, this is useful to set up your victory conditions here.
       
    68 
       
    69 === <tt>onSkipTurn()</tt> (0.9.24) ===
       
    70 This function calls when a hog skips its turn.
       
    71 
       
    72 === <tt>onCaseDrop(gear)</tt> (1.0.0) ===
       
    73 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.
       
    74 
       
    75 If a crate was dropped, `gear` is the crate gear that was dropped, if no crate was dropped, `gear` is `nil`.
       
    76 
       
    77 This function is useful to add custom crate drops as well.
       
    78 
       
    79 === <tt>onGameResult(winningClan)</tt> (0.9.25) ===
       
    80 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.
       
    81 
       
    82 === <tt>onSuddenDeath()</tt> ===
       
    83 This function is called on the start of Sudden Death.
       
    84 
       
    85 === <tt>onUsedAmmo(ammoType)</tt> ===
       
    86 Called after a weapon has been used completely, with `ammoType` as the used ammo type.
       
    87 
       
    88 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.
       
    89 
       
    90 *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.
       
    91 
       
    92 == Controls ==
       
    93 === <tt>onAttack()</tt> ===
   118 This function is called when your Hedgehog attacks.
    94 This function is called when your Hedgehog attacks.
   119 
    95 
   120 == <tt>onHJump()</tt> ==
    96 === <tt>onHJump()</tt> ===
   121 This function is called when you press the high jump key.
    97 This function is called when you press the high jump key.
   122 
    98 
   123 == <tt>onLJump()</tt> ==
    99 === <tt>onLJump()</tt> ===
   124 This function is called when you press the long jump key.
   100 This function is called when you press the long jump key.
   125 
   101 
   126 == <tt>onPrecise()</tt> ==
   102 === <tt>onPrecise()</tt> ===
   127 This function is called when you press the precise key.
   103 This function is called when you press the precise key.
   128 
   104 
   129 == <tt>onLeft()</tt> ==
   105 === <tt>onLeft()</tt> ===
   130 This function is called when you press the left key.
   106 This function is called when you press the left key.
   131 
   107 
   132 == <tt>onRight()</tt> ==
   108 === <tt>onRight()</tt> ===
   133 This function is called when you press the right key.
   109 This function is called when you press the right key.
   134 
   110 
   135 == <tt>onUp()</tt> ==
   111 === <tt>onUp()</tt> ===
   136 This function is called when you press the up key.
   112 This function is called when you press the up key.
   137 
   113 
   138 == <tt>onDown()</tt> ==
   114 === <tt>onDown()</tt> ===
   139 This function is called when you press the down key.
   115 This function is called when you press the down key.
   140 
   116 
   141 == <tt>onAttackUp()</tt> ==
   117 === <tt>onAttackUp()</tt> ===
   142 This function is called when you release the attack key.
   118 This function is called when you release the attack key.
   143 
   119 
   144 == <tt>onDownUp()</tt> ==
   120 === <tt>onDownUp()</tt> ===
   145 This function is called when you release the down key.
   121 This function is called when you release the down key.
   146  
   122  
   147 == <tt>onHogAttack(ammoType)</tt> ==
   123 === <tt>onHogAttack(ammoType)</tt> ===
   148 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. 
   124 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. 
   149 
   125 
   150 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.
   126 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.
   151 
   127 
   152 == <tt>onLeftUp()</tt> ==
   128 === <tt>onLeftUp()</tt> ===
   153 This function is called when you release the left key.
   129 This function is called when you release the left key.
   154 
   130 
   155 == <tt>onPreciseUp()</tt> ==
   131 === <tt>onPreciseUp()</tt> ===
   156 This function is called when you release the precise key.
   132 This function is called when you release the precise key.
   157 
   133 
   158 == <tt>onRightUp()</tt> ==
   134 === <tt>onRightUp()</tt> ===
   159 This function is called when you release the right key.
   135 This function is called when you release the right key.
   160 
   136 
   161 == <tt>onSetWeapon(msgParam)</tt> ==
   137 === <tt>onSetWeapon(msgParam)</tt> ===
   162 It is get called when a weapon is selected or switched.
   138 It is get called when a weapon is selected or switched.
   163 
   139 
   164 `msgParam` tells you which ammo type was selected.
   140 `msgParam` tells you which ammo type was selected.
   165 
   141 
   166 == <tt>onSlot(msgParam)</tt> ==
   142 === <tt>onSlot(msgParam)</tt> ===
   167 This function is called when one of the weapon slot keys has been pressed.
   143 This function is called when one of the weapon slot keys has been pressed.
   168 
   144 
   169 `msgParam` tells the slot number minus 1 (i.e. `0` is for slot number 1, `1` is for slot number 2, etc.).
   145 `msgParam` tells the slot number minus 1 (i.e. `0` is for slot number 1, `1` is for slot number 2, etc.).
   170 
   146 
   171 == <tt>onSwitch()</tt> ==
   147 === <tt>onSwitch()</tt> ===
   172 This function is called when a hog is switched to another.
   148 This function is called when a hog is switched to another.
   173 
   149 
   174 == <tt>onTaunt(msgParam)</tt> ==
   150 === <tt>onTaunt(msgParam)</tt> ===
   175 This function is called when the player uses an animated emote for example by using the chat commands `/wave`, `/juggle`, etc.
   151 This function is called when the player uses an animated emote for example by using the chat commands `/wave`, `/juggle`, etc.
   176 
   152 
   177 `msgParam` tells you which animation was played:
   153 `msgParam` tells you which animation was played:
   178 
   154 
   179 || *`msgParam`* || *Animation* || *Associated chat command* ||
   155 || *`msgParam`* || *Animation* || *Associated chat command* ||
   183 || 3 || Stupid winner's grin / “Awesome” face || `/hurrah` ||
   159 || 3 || Stupid winner's grin / “Awesome” face || `/hurrah` ||
   184 || 4 || Peeing || `/ilovelotsoflemonade` ||
   160 || 4 || Peeing || `/ilovelotsoflemonade` ||
   185 || 5 || Shrug || `/shrug` ||
   161 || 5 || Shrug || `/shrug` ||
   186 || 6 || Juggling || `/juggle` ||
   162 || 6 || Juggling || `/juggle` ||
   187 
   163 
   188 == <tt>onTimer(msgParam)</tt> ==
   164 === <tt>onTimer(msgParam)</tt> ===
   189 This function is called when one of the timer keys is pressed.
   165 This function is called when one of the timer keys is pressed.
   190 
   166 
   191 `msgParams` tells the set timer in seconds (i.e. `3` for the 3 seconds timer key).
   167 `msgParams` tells the set timer in seconds (i.e. `3` for the 3 seconds timer key).
   192 
   168 
   193 == <tt>onUpUp()</tt> ==
   169 === <tt>onUpUp()</tt> ===
   194 This function is called when you release the up key.
   170 This function is called when you release the up key.
   195 
   171 
   196 == <tt>onUsedAmmo(ammoType)</tt> ==
   172 === <tt>onScreenResize()</tt> ===
   197 Called after a weapon has been used completely, with `ammoType` as the used ammo type.
   173 This function is called when you resize the screen. Useful place to put a redraw function for any `vgtHealthTags` you're using.
   198 
   174 
   199 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.
   175 == Gears ==
   200 
   176 === <tt>onGearAdd(gearUid)</tt> ===
   201 *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.
   177 This function is called when a new gear is added. Useful in combination with `GetGearType(gearUid)`.
   202 
   178 
   203 == <tt>onHogHide(gearUid)</tt> ==
   179 === <tt>onGearDelete(gearUid)</tt> ===
       
   180 This function is called when a new gear is deleted. Useful in combination with `GetGearType(gearUid)`.
       
   181 
       
   182 === <tt>onVisualGearAdd(vgUid)</tt> ===
       
   183 This function is called when a new visual gear is added. Useful in combination with `GetVisualGearType(vgUid)`.
       
   184 
       
   185 === <tt>onVisualGearDelete(vgUid)</tt> ===
       
   186 This function is called when a new visual gear is deleted. Useful in combination with `GetVisualGearType(vgUid)`.
       
   187 
       
   188 === <tt>onGearDamage(gearUid, damage)</tt> ===
       
   189 This function is called when a gear is damaged.
       
   190 
       
   191 Example:
       
   192 
       
   193 <code language="lua">    function onGearDamage(gear, damage)
       
   194         if (GetGearType(gear) === gtHedgehog) then
       
   195             -- adds a message saying, e.g. "Hoggy H took 25 points of damage"
       
   196             AddCaption(GetHogName(gear) .. ' took ' .. damage .. ' points of damage')
       
   197         end
       
   198     end</code>
       
   199 === <tt>onGearResurrect(gearUid, spawnedVGear) </tt> ===
       
   200 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.
       
   201 
       
   202 `spawnedVGear` is a visual gear handle of the “resurrection effect”. You can use this handle to modify or delete the resurrection animation.
       
   203 
       
   204 === <tt>onGearWaterSkip(gear)</tt> ===
       
   205 This function is called when the gear `gear` skips over water.
       
   206 
       
   207 === <tt>onHogHide(gearUid)</tt> ===
   204 This function is called when a hedgehog with the gear ID `gearUid` is hidden (removed from the map).
   208 This function is called when a hedgehog with the gear ID `gearUid` is hidden (removed from the map).
   205 
   209 
   206 == <tt>onHogRestore(gearUid)</tt> ==
   210 === <tt>onHogRestore(gearUid)</tt> ===
   207 This function is called when a hedgehog with the specified gear ID `gearUid` is restored (unhidden).
   211 This function is called when a hedgehog with the specified gear ID `gearUid` is restored (unhidden).
   208 
   212 
   209 == <tt>onSpritePlacement(spriteId, centerX, centerY)</tt> ==
   213 == Map changes ==
       
   214 === <tt>onSpritePlacement(spriteId, centerX, centerY)</tt> ===
   210 This function is called when a [Sprites Sprite] has been placed.
   215 This function is called when a [Sprites Sprite] has been placed.
   211 
   216 
   212 `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.
   217 `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.
   213 
   218 
   214 == <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> ==
   219 === <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> ===
   215 This function is called when a girder has been placed.
   220 This function is called when a girder has been placed.
   216 
   221 
   217 `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.
   222 `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.
   218 
   223 
   219 == <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> ==
   224 === <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> ===
   220 This function is called when a rubber has been placed.
   225 This function is called when a rubber has been placed.
   221 
   226 
   222 `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.
   227 `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.
   223 
   228 
   224 == <tt>onSpecialPoint(x, y, flags)</tt> ==
   229 === <tt>onSpecialPoint(x, y, flags)</tt> ===
   225 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.
   230 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.
   226 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.
   231 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.
   227 
   232 
   228 This function is used in Racer and !TechRacer to define waypoints.
   233 This function is used in Racer and !TechRacer to define waypoints.
   229 
   234 
   230 == <tt>onAchievementsDeclaration()</tt> ==
   235 == Achievements ==
       
   236 === <tt>onAchievementsDeclaration()</tt> ===
   231 This function is called after the stats for the stats screen (after the game) have been generated. You are supposed to call `DeclareAchievement` here.
   237 This function is called after the stats for the stats screen (after the game) have been generated. You are supposed to call `DeclareAchievement` here.
   232