LuaGameplay.wiki
changeset 2232 09bf7a4d5411
parent 2188 a6f98b1311f6
child 2254 6f6f15fb33d5
equal deleted inserted replaced
2231:f00c578955f7 2232:09bf7a4d5411
    29 === `EndTurn([noTaunts])` ===
    29 === `EndTurn([noTaunts])` ===
    30 Ends the current turn immediately.
    30 Ends the current turn immediately.
    31 
    31 
    32 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.
    32 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.
    33 
    33 
    34 === <tt>Retreat(time [, respectGetAwayTimeFactor)</tt> (0.9.25) ===
    34 === <tt>Retreat(time [, respectGetAwayTimeFactor)</tt> ===
    35 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.
    35 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.
    36 
    36 
    37 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`.
    37 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`.
    38 
    38 
    39 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 a turn, the ready phase continues normally, but the turn will begin in the retreat phase instead.
    39 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 a turn, the ready phase continues normally, but the turn will begin in the retreat phase instead.
    40 
    40 
    41 Note: If you want the turn to end instantly, it is recommended to use `EndTurn` instead.
    41 Note: If you want the turn to end instantly, it is recommended to use `EndTurn` instead.
    42 
    42 
    43 === <tt>!SetTurnTimeLeft(newTurnTimeLeft)</tt> (0.9.25) ===
    43 === <tt>!SetTurnTimeLeft(newTurnTimeLeft)</tt> ===
    44 Set the remaining turn time in milliseconds. The current remaining turn time can be read from the variable `TurnTimeLeft`.
    44 Set the remaining turn time in milliseconds. The current remaining turn time can be read from the variable `TurnTimeLeft`.
    45 
    45 
    46 === <tt>!SetReadyTimeLeft(newReadyTimeLeft)</tt> (0.9.25) ===
    46 === <tt>!SetReadyTimeLeft(newReadyTimeLeft)</tt> ===
    47 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`.
    47 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`.
    48 
    48 
    49 === <tt>!SetTurnTimePaused(isPaused)</tt> (1.0.0) ===
    49 === <tt>!SetTurnTimePaused(isPaused)</tt> ===
    50 Pauses the turn time indefinitely if `isPaused` is set to `true`, disabled the turn time pause if `isPaused` is set to `false`.
    50 Pauses the turn time indefinitely if `isPaused` is set to `true`, disabled the turn time pause if `isPaused` is set to `false`.
    51 
    51 
    52 === <tt>!GetTurnTimePaused()</tt> (1.0.0) ===
    52 === <tt>!GetTurnTimePaused()</tt> ===
    53 Returns `true` if the turn time is currently paused by `SetTurnTimePaused`, otherwise returns `false`.
    53 Returns `true` if the turn time is currently paused by `SetTurnTimePaused`, otherwise returns `false`.
    54 
    54 
    55 === <tt>!EndGame()</tt> ===
    55 === <tt>!EndGame()</tt> ===
    56 Makes the game end.
    56 Makes the game end.
    57 
    57 
   186 Note: By default, ammo is per-team, so calling `AddAmmo` for a hedgehog will add/set 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`.
   186 Note: By default, ammo is per-team, so calling `AddAmmo` for a hedgehog will add/set 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`.
   187 
   187 
   188 === <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> ===
   188 === <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> ===
   189 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`.
   189 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`.
   190 
   190 
   191 === <tt>!SetAmmoSlot(ammoType, slot)</tt> (1.0.0) ===
   191 === <tt>!SetAmmoSlot(ammoType, slot)</tt> ===
   192 Sets the slot number of `ammoType` to the given `slot` (counting starts from 1).
   192 Sets the slot number of `ammoType` to the given `slot` (counting starts from 1).
   193 
   193 
   194 Use with care! It is your responsibility that each ammo slot does not hold more weapons than the maximum ammo menu width, otherwise, crashes are possible. Test with a full ammo menu to be sure.
   194 Use with care! It is your responsibility that each ammo slot does not hold more weapons than the maximum ammo menu width, otherwise, crashes are possible. Test with a full ammo menu to be sure.
   195 
   195 
   196 Use this function only if you absolutely must! For usability reasons and to help the player's muscle memory, we should normally not re-arrange the weapons. This function was actually only created for the “Frenzy” game style in which we needed to re-arrange the ammo slots to give each weapon an unique ammo slot.
   196 Use this function only if you absolutely must! For usability reasons and to help the player's muscle memory, we should normally not re-arrange the weapons. This function was actually only created for the “Frenzy” game style in which we needed to re-arrange the ammo slots to give each weapon an unique ammo slot.
   337 Returns the current input mask of the player.
   337 Returns the current input mask of the player.
   338 
   338 
   339 === <tt>!SetVampiric(bool)</tt> ===
   339 === <tt>!SetVampiric(bool)</tt> ===
   340 Toggles vampirism mode for this turn. Set `bool` to `true` to enable (same effect as if the hedgehog has used Vampirism), `false` to disable.
   340 Toggles vampirism mode for this turn. Set `bool` to `true` to enable (same effect as if the hedgehog has used Vampirism), `false` to disable.
   341 
   341 
   342 === <tt>!GetVampiric()</tt> (0.9.25) ===
   342 === <tt>!GetVampiric()</tt> ===
   343 Returns true if vampirism mode is currently active.
   343 Returns true if vampirism mode is currently active.
   344 
   344 
   345 === <tt>!SetLaserSight(bool)</tt> ===
   345 === <tt>!SetLaserSight(bool)</tt> ===
   346 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.
   346 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.
   347 
   347 
   348 === <tt>!GetLaserSight()</tt> (0.9.25) ===
   348 === <tt>!GetLaserSight()</tt> ===
   349 Returns true if laser sight (as utility) is currently active. The sniper rifle's built-in laser sight does not count.
   349 Returns true if laser sight (as utility) is currently active. The sniper rifle's built-in laser sight does not count.
   350 
   350 
   351 === <tt>!EnableSwitchHog()</tt> (0.9.25) ===
   351 === <tt>!EnableSwitchHog()</tt> ===
   352 Enable hog switching mode for the current hedgehog. This function should be called while the hedgehog is standing on solid ground (`GetFlightTime` returns 0).
   352 Enable hog switching mode for the current hedgehog. This function should be called while the hedgehog is standing on solid ground (`GetFlightTime` returns 0).
   353 
   353 
   354 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.
   354 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.
   355 
   355 
   356 On success, returns the `gtSwitcher` gear being spawned or, if hog switching mode is already active, returns the exsting gear. On failure, returns `nil`.
   356 On success, returns the `gtSwitcher` gear being spawned or, if hog switching mode is already active, returns the exsting gear. On failure, returns `nil`.
   403 
   403 
   404 <code language="lua">AddTeam("team 1", -1, "Simple", "Tank", "Default_qau", "hedgewars")
   404 <code language="lua">AddTeam("team 1", -1, "Simple", "Tank", "Default_qau", "hedgewars")
   405 --[[ Adds a new team with name “team 1”, the first default color (usually red), the grave “Simple”,
   405 --[[ Adds a new team with name “team 1”, the first default color (usually red), the grave “Simple”,
   406 the fort “Tank” the voicepack “Default” (in the appropriate language version) and the flag “hedgewars”. ]]</code>
   406 the fort “Tank” the voicepack “Default” (in the appropriate language version) and the flag “hedgewars”. ]]</code>
   407 
   407 
   408 === <tt>!AddMissionTeam(color)</tt> (1.0.0) ===
   408 === <tt>!AddMissionTeam(color)</tt> ===
   409 Adds a new team using the player-chosen team identity when playing a singleplayer mission. Does not work in multiplayer.
   409 Adds a new team using the player-chosen team identity when playing a singleplayer mission. Does not work in multiplayer.
   410 
   410 
   411 This function is very similar to `AddTeam`. Team settings like team name and flag will be taken from the player-chosen team.
   411 This function is very similar to `AddTeam`. Team settings like team name and flag will be taken from the player-chosen team.
   412 You only need to specify the clan color, which has the same meaning as in `AddTeam`.
   412 You only need to specify the clan color, which has the same meaning as in `AddTeam`.
   413 
   413 
   440 
   440 
   441 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.
   441 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.
   442 
   442 
   443 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.
   443 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.
   444 
   444 
   445 === <tt>SetTeamPassive(teamname, isPassive)</tt> (1.0.0) ===
   445 === <tt>SetTeamPassive(teamname, isPassive)</tt> ===
   446 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.
   446 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.
   447 
   447 
   448 === <tt>!GetClanColor(clan)</tt> ===
   448 === <tt>!GetClanColor(clan)</tt> ===
   449 Returns the RGBA color of the chosen clan by its number. The color data type is described in [LuaOverview#Color].
   449 Returns the RGBA color of the chosen clan by its number. The color data type is described in [LuaOverview#Color].
   450 
   450 
   460 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].
   460 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].
   461 
   461 
   462 === <tt>!GetCampaignVar(varname)</tt> ===
   462 === <tt>!GetCampaignVar(varname)</tt> ===
   463 Returns the value of the campaign variable `varname` as a string. See also `SaveCampaignVar`.
   463 Returns the value of the campaign variable `varname` as a string. See also `SaveCampaignVar`.
   464 
   464 
   465 === <tt>!SaveMissionVar(varname, value)</tt> (1.0.0) ===
   465 === <tt>!SaveMissionVar(varname, value)</tt> ===
   466 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.
   466 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.
   467 
   467 
   468 === <tt>!GetMissionVar(varname)</tt> (1.0.0) ===
   468 === <tt>!GetMissionVar(varname)</tt> ===
   469 Returns the value of the mission variable `varname` as a string. See also `SaveMissionVar`.
   469 Returns the value of the mission variable `varname` as a string. See also `SaveMissionVar`.
   470 
   470 
   471 == Randomness ==
   471 == Randomness ==
   472 === <tt>!GetRandom(number)</tt> ===
   472 === <tt>!GetRandom(number)</tt> ===
   473 Returns a randomly generated whole number in the range of `0` to `number - 1`. `number` must be a whole number >= 1. This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games.
   473 Returns a randomly generated whole number in the range of `0` to `number - 1`. `number` must be a whole number >= 1. This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games.