LuaGears.wiki
author alfadur
Mon, 07 Sep 2020 01:16:51 +0300
changeset 2186 08ee59cebec7
parent 2180 ce320d08ddf7
child 2233 fbe2095f05e4
permissions -rw-r--r--
fix package syntax
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1759
6725a497c482 LuaGears: Fix summary
Wuzzy
parents: 1758
diff changeset
     1
#summary List of gear-related functions in the Lua API
1841
2c6019a41474 LuaGears: Add label
Wuzzy
parents: 1832
diff changeset
     2
#labels !LuaFunctions
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
     3
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
     4
= Lua API: Gear functions =
2089
375b9861ab91 LuaGears: add newline
Wuzzy
parents: 2077
diff changeset
     5
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
     6
This is a list of all functions in the [LuaAPI Lua API] that are related to gears and visual gears.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
     7
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
     8
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. 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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
     9
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    10
Refer to [LuaGuide] for a more detailed introduction into gears.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    11
1758
eda4a2277089 LuaGears: Fix syntax
Wuzzy
parents: 1755
diff changeset
    12
<wiki:toc max_depth="3"/>
1755
b3ce3b8bc36d LuaGears: Add TOC
Wuzzy
parents: 1749
diff changeset
    13
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    14
== Creation ==
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    15
1832
d975c5b3bc4c LuaGears: Remove mistake from previous commit (test was successful)
Wuzzy
parents: 1831
diff changeset
    16
=== `AddGear(x, y, gearType, state, dx, dy, timer)` ===
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    17
This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]).
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    18
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]. `timer` is the initial timer value of the gear. If a particular gear value does not matter, use `0`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    19
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    20
Position, velocity, state and timer can be changed afterwards with the various setter functions.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    21
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    22
Note: If you want to create a hedgehog (`gtHedgehog`), you must call `AddHog` or `AddMissionHog` instead. If you want to spawn a crate (`gtCase`), you must call one of the several “Spawn*Crate” functions (e.g. `SpawnSupplyCrate`) below instead.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    23
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    24
Example:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    25
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    26
<code language="lua">    -- Spawn a target at (0,0) and place it randomly
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    27
    local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) -- also use 0 for velocity. Also 0 for state and timer because they don't matter.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    28
    FindPlace(gear, true, 0, LAND_WIDTH)</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    29
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
    30
=== `AddVisualGear(x, y, visualGearType, state, critical [, layer])` ===
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
    31
This attempts to create a new visual gear at position x,y (measured from top left) of kind `visualGearType` (see [VisualGearTypes Visual Gear Types]).
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    32
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    33
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`.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    34
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    35
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).
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    36
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    37
You can set an optional `layer` to specify which visual gears get drawn on top.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    38
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    39
Most visual gears delete themselves eventually.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    40
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    41
*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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    42
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    43
*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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    44
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    45
Example:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    46
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    47
<code language="lua">  -- adds an non-critical explosion at position 1000,1000. Returns 0 if it was not created.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    48
    local vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) 
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    49
</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    50
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
    51
=== `AddHog(hogname, botlevel, health, hat)` ===
1783
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    52
Adds a new hedgehog for current team (last created one with the `AddTeam` function), with a bot level, an initial health and a hat.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    53
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    54
`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.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    55
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    56
Returns the gear ID.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    57
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    58
*Warning*: This only works in singleplayer mode (e.g. missions). Also, Hedgewars only supports up to 64 hedgehogs in a game.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    59
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    60
Example:
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    61
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    62
<code language="lua">    local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    63
    SetGearPosition(player, 1500, 1000)
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    64
    -- hint: If you don't call `SetGearPosition`, the hog spawns randomly</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    65
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
    66
=== `AddMissionHog(health)` (0.9.25) ===
1783
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    67
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`.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    68
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    69
The name and hat match the player's team definition. The hog is also always player-controlled.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    70
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    71
Examples:
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    72
<code language="lua">-- Add player team with 3 hogs
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    73
AddMissionTeam(-1)
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    74
AddMissionHog(100)
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    75
AddMissionHog(100)
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    76
AddMissionHog(100)</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    77
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    78
<code language="lua">-- You can also mix mission hogs with “hardcoded” hogs.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    79
-- This adds a player team with 2 hogs taken from the player team and 1 hog with a hardcoded name, botlevel and hat.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    80
AddMissionTeam(-2)
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    81
AddMissionHog(100)
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    82
AddMissionHog(100)
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    83
AddHog("My Hardcoded Hog", 0, 100, "NoHat")
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    84
</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
    85
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
    86
=== `SpawnHealthCrate(x, y, [, health])` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    87
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`.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    88
2077
514babfbad9e Remove outdated legacy hints as clutter
Wuzzy <almikes@aol.com>
parents: 2047
diff changeset
    89
=== `SpawnSupplyCrate(x, y, ammoType [, amount])` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    90
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    91
Otherwise, this function behaves like `SpawnAmmoCrate`.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    92
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
    93
=== `SpawnAmmoCrate(x, y, ammoType [, amount])` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    94
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    95
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    96
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    97
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:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    98
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
    99
Example:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   100
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   101
<code language="lua">    SetAmmo(amGrenade, 0, 0, 0, 1) -- grenade ammo crates now contain 1 grenade each
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   102
    SpawnAmmoCrate(0, 0, amGrenade) -- spawn grenade ammo crate at random position</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   103
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   104
=== `SpawnUtilityCrate(x, y, ammoType [, amount])` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   105
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   106
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   107
Example:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   108
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   109
<code language="lua">    SetAmmo(amLaserSight, 0, 0, 0, 1)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   110
    SpawnUtilityCrate(0, 0, amLaserSight)</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   111
1984
48fb7b41cccf LuaGears: SpawnFake*Crate optional arguments
Wuzzy
parents: 1982
diff changeset
   112
=== `SpawnFakeAmmoCrate(x, y [, explode [, poison]]) ` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   113
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).
1984
48fb7b41cccf LuaGears: SpawnFake*Crate optional arguments
Wuzzy
parents: 1982
diff changeset
   114
48fb7b41cccf LuaGears: SpawnFake*Crate optional arguments
Wuzzy
parents: 1982
diff changeset
   115
`explode` and `poison` are booleans. They are optional since 1.0.0 but mandatory until 0.9.25.
48fb7b41cccf LuaGears: SpawnFake*Crate optional arguments
Wuzzy
parents: 1982
diff changeset
   116
48fb7b41cccf LuaGears: SpawnFake*Crate optional arguments
Wuzzy
parents: 1982
diff changeset
   117
If `explode` is `true`, the crate will explode when collected (default: `false`).
48fb7b41cccf LuaGears: SpawnFake*Crate optional arguments
Wuzzy
parents: 1982
diff changeset
   118
If `poison` is `true`, the collector will be poisoned (default: `false`).
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   119
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   120
Example:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   121
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   122
<code language="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   123
</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   124
1984
48fb7b41cccf LuaGears: SpawnFake*Crate optional arguments
Wuzzy
parents: 1982
diff changeset
   125
=== `SpawnFakeHealthCrate(x, y [, explode [, poison]]) ` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   126
Same as `SpawnFakeAmmoCrate`, except the crate will look like a health crate.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   127
1984
48fb7b41cccf LuaGears: SpawnFake*Crate optional arguments
Wuzzy
parents: 1982
diff changeset
   128
=== `SpawnFakeUtilityCrate(x, y [, explode [, poison]]) ` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   129
Same as `SpawnFakeAmmoCrate`, except the crate will look like an utility crate.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   130
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   131
== Position and velocity ==
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   132
=== `GetGearPosition(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   133
Returns x,y coordinates for the specified gear. Not to be confused with `GetGearPos`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   134
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   135
=== `GetX(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   136
Returns x coordinate of the gear.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   137
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   138
=== `GetY(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   139
Returns y coordinate of the gear.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   140
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   141
=== `SetGearPosition(gearUid, x, y)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   142
Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   143
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   144
=== `GetGearVelocity(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   145
Returns a tuple of dx,dy values for the specified gear.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   146
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   147
=== `SetGearVelocity(gearUid, dx, dy)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   148
Gives the specified gear the velocity of `dx`, `dy`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   149
1793
b549350dca64 LuaGears: Update arg names for CopyPV
Wuzzy
parents: 1792
diff changeset
   150
=== `CopyPV(fromGearUid, toGearUid)` ===
b549350dca64 LuaGears: Update arg names for CopyPV
Wuzzy
parents: 1792
diff changeset
   151
When given two gears as arguments, this sets the position and velocity of `toGearUid` to the position and velocity of `fromGearUid`.
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   152
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   153
=== `FindPlace(gearUid, fall, left, right[, tryHarder])` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   154
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   155
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   156
Example:
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   157
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   158
<code language="lua">    gear = AddGear(...)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   159
    FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   160
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   161
== General gear properties ==
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   162
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   163
=== `GetGearType(gearUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   164
This function returns the [GearTypes gear type] for the specified gear, if it exists.  If it doesn't exist, `nil` is returned.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   165
2077
514babfbad9e Remove outdated legacy hints as clutter
Wuzzy <almikes@aol.com>
parents: 2047
diff changeset
   166
=== `GetVisualGearType(vgUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   167
This function returns the [VisualGearTypes visual gear type] for the specified visual gear, if it exists.  If it doesn't exist, `nil` is returned.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   168
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   169
=== `GetState(gearUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   170
Returns the state of the gear. The gear state is a bitmask which is built out of the variables as shown in [States].
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   171
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   172
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   173
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   174
Examples:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   175
<code language="lua">
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   176
local state = GetState(gear)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   177
--[[ Stores the full raw bitmask of gear in state. Usually
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   178
useless on its own. ]]
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   179
</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   180
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   181
<code language="lua">
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   182
isDrowning = band(GetState(CurrentHedgehog),gstDrowning) ~= 0
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   183
--[[ GetState(CurrentHedgehog) returns the state bitmask of
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   184
CurrentHedgehog, gstDrowning is a bitmask where only the
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   185
“drowning” bit is set. band does a bitwise AND on both, if
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   186
it returns a non-zero value, the hedgehog is drowning.]]
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   187
</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   188
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   189
<code language="lua">
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   190
SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstInvisible))
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   191
--[[ first the state bitmask of CurrentHedgehog is bitwise ORed with
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   192
the gstInvisible flag, thus making the bit responsible for
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   193
invisiblity to become 1. Then the new bitmask is applied to
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   194
CurrentHedgehog, thus making it invisible.]]
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   195
</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   196
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   197
=== `SetState(gearUid, state)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   198
Sets the state of the specified gear to the specified `state`. This is a bitmask made out of the variables as seen in [States].
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   199
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   200
This function is often used together with `GetState` and the bitmask utility functions `band` and `bnot` in order to manipulate a single flag.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   201
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   202
Examples:
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   203
<code language="lua">
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   204
SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstInvisible))
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   205
--[[ first the state bitmask of CurrentHedgehog is bitwise ORed with
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   206
the gstInvisible flag, thus making the bit responsible for
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   207
invisiblity to become 1. Then the new bitmask is applied to
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   208
CurrentHedgehog, thus making it invisible. ]]
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   209
</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   210
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   211
<code language="lua">
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   212
SetState(CurrentHedgehog, band(GetState(CurrentHedgehog), bnot(gstInvisible)))
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   213
--[[ The reverse of the above: This function toggles CurrentHedgehog’s
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   214
gstInvisible flag off, thus making it visible again. ]]
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   215
</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   216
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   217
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   218
=== `GetGearMessage(gearUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   219
Returns the message of the gear. This is a bitmask built out of flags seen in [GearMessages].
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   220
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   221
=== `SetGearMessage(gearUid, message)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   222
Sets the gear messages of the specified gear. `message` is a bitmask built out of flags seen in [GearMessages].
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   223
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   224
=== `GetTag(gearUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   225
Returns the tag of the specified gear (by `gearUid`). 
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   226
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   227
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   228
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   229
Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. 
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   230
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   231
<code language="lua">
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   232
-- This adds a ball (the one from the ballgun) at (123, 456):
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   233
ball = AddGear(123, 456, gtBall, 0, 0, 0, 0)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   234
-- The tag of a ball defines its color. It will automatically chosen at random when created.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   235
colorTag = GetTag(ball)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   236
-- Now colorTag stores the tag of ball (in this case a number denoting its color)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   237
</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   238
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   239
The meaning of tags are described in [GearTypes].
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   240
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   241
=== `SetTag(gearUid, tag)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   242
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   243
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   244
Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. 
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   245
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   246
<code language="lua">
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   247
-- This adds a ball (the one from the ballgun) at (123, 456):
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   248
ball = AddGear(123, 456, gtBall, 0, 0, 0, 0)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   249
-- This sets the tag of the gear. For gtBall, the tag specified the color. “8” is the color white.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   250
SetTag(ball, 8) -- 
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   251
</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   252
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   253
The meaning of tags are described in [GearTypes].
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   254
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   255
=== `GetTimer(gearUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   256
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   257
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   258
=== `SetTimer(gearUid, timer)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   259
Sets the timer of the specified gear. Also see `GetTimer`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   260
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   261
=== `GetHealth(gearUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   262
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   263
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   264
=== `SetHealth(gearUid, health)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   265
Sets the health of the specified gear. The “health” of a gear can refer to many things, depending on the gear type.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   266
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   267
*Hint*: If you like to increase the health of a hedgehog with nice visual effects, consider using `HealHog` instead.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   268
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   269
Use cases:
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   270
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   271
  * Setting the health of a hedgehog (`gtHedgehog`) to 99
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   272
  * Starting the RC Plane (`gtRCPlane`) with 10 bombs
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   273
  * Starting flying saucer (`gtJetpack`) with only 50% fuel
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   274
  * Setting all the mines (`gtMine`) to duds
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   275
  * And more!
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   276
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   277
See [GearTypes] for a full description.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   278
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   279
<code language="lua">    function onGearAdd(gear)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   280
       if (GetGearType(gear) == gtHedgehog) then
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   281
            -- Set hedgehog health to 99
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   282
            SetHealth(gear, 99)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   283
       end
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   284
       if (GetGearType(gear) == gtRCPlaane) then
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   285
            -- Give the plane 10 bombs
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   286
            SetHealth(gear, 10)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   287
       end
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   288
       if (GetGearType(gear) == gtJetpack) then
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   289
            -- Set fuel to 50% only
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   290
            SetHealth(gear, 1000)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   291
       end
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   292
       if (GetGearType(gear) == gtMine) then
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   293
            -- Turn mine into dud
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   294
            SetHealth(gear, 0)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   295
       end
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   296
    end</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   297
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   298
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   299
=== `GetGearPos(gearUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   300
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. 
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   301
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   302
*Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   303
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   304
=== `SetGearPos(gearUid, value)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   305
Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   306
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   307
=== `GetGearCollisionMask(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   308
Returns the current collision mask of the given gear. See `SetGearCollisionMask` for an explanation of the mask.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   309
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   310
=== `SetGearCollisionMask(gearUid, mask)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   311
Set the collision mask of the given gear with `gearUid`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   312
The collision mask defines with which gears and terrain types the gear can collide.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   313
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   314
`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:
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   315
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   316
|| *Identifier* || *Collision with …* ||
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   317
|| `lfLandMask` || Terrain ||
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   318
|| `lfCurHogCrate` || Current hedgehog, and crates ||
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   319
|| `lfHHMask` || Any hedgehogs ||
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   320
|| `lfNotHHObjMask` || Objects, not hogs (e.g. mines, explosives) ||
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   321
|| `lfAllObjMask` || Hedgehogs and objects ||
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   322
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   323
Beware, the collision mask is often set by the engine as well.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   324
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   325
Examples:
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   326
<code language="lua">SetGearCollisionMask(gear, bnot(lfCurHogCrate))
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   327
-- Ignore collision with current hedgehog</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   328
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   329
<code language="lua">SetGearCollisionMask(gear, 0xFFFF)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   330
-- Collide with everything</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   331
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   332
<code language="lua">SetGearCollisionMask(gear, lfAllObjMask)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   333
-- Collide with hedgehogs and objects</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   334
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   335
<code language="lua">SetGearCollisionMask(gear, 0x0000)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   336
-- Collide with nothing</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   337
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   338
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):
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   339
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   340
[https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uConsts.pas#l112]
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   341
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   342
=== `GetGearRadius(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   343
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   344
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   345
To set the `Radius` value, use `SetGearValues`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   346
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   347
=== `GetFlightTime(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   348
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   349
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   350
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   351
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   352
=== `SetFlightTime(gearUid, flighttime)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   353
Sets the `FlightTime` of the given gear to `flighttime`. The meaning of `FlightTime` is explained in the section `GetFlightTime`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   354
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   355
=== `GetGearElasticity(gearUid) ` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   356
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   357
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   358
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   359
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   360
=== `SetGearElasticity(gearUid, Elasticity) ` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   361
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`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   362
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   363
=== `GetGearFriction(gearUid) ` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   364
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   365
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   366
=== `SetGearFriction(gearUid, Friction) ` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   367
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   368
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   369
=== `GetGearTarget(gearUid, x, y) ` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   370
Returns the x and y coordinate of target-based weapons/utilities. 
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   371
<b>Note:</b>: This can’t be used in `onGearAdd()` but must be called after gear creation. 
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   372
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   373
=== `SetGearTarget(gearUid, x, y)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   374
Sets the x and y coordinate of target-based weapons/utilities.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   375
*Note*: This can’t be used in onGearAdd() but must be called after gear creation.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   376
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   377
=== `GetGearValues(gearUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   378
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   379
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   380
This is returned (all variables are integers):
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   381
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   382
`Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom`
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   383
2160
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   384
That the concrete meaning of each of this variables depends on the gear type and can vary wildly. For most gear types, many of these variables are unused and have no effect.
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   385
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   386
Here's an overview of the purpose of these variables:
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   387
2160
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   388
 * `Angle`: Angle the gear was launched in (usually)
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   389
 * `Power`: Power the gear was launched in (usually)
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   390
 * `WDTimer`: An alternative timer variable, used by some more complex gears like air mines
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   391
 * `Radius`: Effect or collision radius, most of the time
2160
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   392
 * `Density`: A high density makes the gear less prone to being pushed by forces, like explosions, wind and stuff. Gears with a higher density also make a larger splash
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   393
 * `Karma`: Used to track karma damage for hedgehogs in the Karma game modifier, but abused for different purposes for other gears, too
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   394
 * `DirAngle`: ???
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   395
 * `AdvBounce`: ???
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   396
 * `ImpactSound`: Sound it makes on a collision (see [Sounds])
1947
3cc17b9eed3f LuaGears: nImpactSounds: Add link
Wuzzy
parents: 1946
diff changeset
   397
 * `nImpactSounds`: Must be used together with `ImpactSound`. Number of different impact sounds to use. `0`: Disable impact sound. `1`: Use sound selected in `ImpactSound`. `2` or higher: Uses a random impact sound each impact. The first possible sound is `ImpactSound`, the second possible sound is `ImpactSound+1`, and so on. The order of sounds is specified at [https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uTypes.pas#l120]. For example, if `ImpactSound` is `sndHellishImpact1` and `nImpactSounds` equals 4, the impact sounds will be `sndHellishImpact1` to `sndHellishImpact4`
2160
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   398
 * `Tint`: Colorization of gear. The color is in RGBA format. Not supported by all gears.
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   399
 * `Damage`: Amount of damage taken by gear. Only used by a few gears.
9d683fe2f4f9 LuaGears: Document most GetGearValues vars
Wuzzy
parents: 2123
diff changeset
   400
 * `Boom`: Used by most gears to determine the potential damage / explosion size
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   401
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   402
Example:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   403
<code language="lua">
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   404
-- Get all values in a single line of code:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   405
local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom, Scale = GetGearValues(myGear)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   406
</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   407
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   408
=== `SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   409
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   410
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   411
Set `nil` for each value you do not want to change.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   412
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   413
Example:
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   414
<code language="lua">
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   415
-- Paints all RC planes into a white color
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   416
function onGearAdd(gear)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   417
    if GetGearType(gear) == gtRCPlane then
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   418
         SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFFFFFFFF)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   419
    end
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   420
end
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   421
</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   422
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   423
=== `GetVisualGearValues(vgUid)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   424
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:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   425
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   426
`X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale`
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   427
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   428
The meaning of these values is the same as in `SetVisualGearValues`.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   429
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   430
If the visual gear does not exist, `nil` is returned. Always check the result for `nil` before you plug in the values anywhere.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   431
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   432
Most visual gears require little to no modification of parameters.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   433
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   434
Example:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   435
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   436
<code language="lua">-- Return visual gear values
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   437
local X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale = GetVisualGearValues(vgUid)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   438
</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   439
1849
60249ab531df LuaGears: Fix syntax of SetVisualGearValues
Wuzzy
parents: 1841
diff changeset
   440
=== `SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale)` ===
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   441
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   442
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   443
All visual gear values are numbers. Each visual gear may be using these parameters differently, but the *usual* meaning of these is the following:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   444
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   445
 * `X`, `Y`: Position
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   446
 * `dX`, `dY`: Speed along the X and Y axis
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   447
 * `Angle`: Current rotation
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   448
 * `Frame`: Image frame, if using a sprite sheet
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   449
 * `FrameTicks` is usually an animation counter
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   450
 * `State`: Helper value to save some internal state
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   451
 * `Timer`: Time in milliseconds until it expires
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   452
 * `Tint`: RGBA color
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   453
 * `Scale` is a scale factor (not used by all visual gears)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   454
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   455
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   456
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   457
Note that most visual gears require little to no modification of their values.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   458
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   459
*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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   460
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   461
Example 1:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   462
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   463
<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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   464
    SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff)</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   465
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   466
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   467
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   468
Example 2:
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   469
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   470
<code language="lua">  -- set a visual gear to position 1000,1000
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   471
    SetVisualGearValues(circleUid, 1000, 1000)</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   472
<code language="lua">  -- set the tint of a visual gear to bright red.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   473
    SetVisualGearValues(circleUid, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff0000ff)</code>
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   474
    
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   475
=== `SetGearAIHints(gearUid, aiHint)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   476
Set some behaviour hints for computer-controlled hedgehogs for any given gear with `gearUid`.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   477
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   478
Set `aiHint` to either of:
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   479
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   480
 * `aihUsualProcessing`: AI hogs treat this gear the usual way. This is the default.
2180
ce320d08ddf7 LuaGears: Update aihDoesntMatter
Wuzzy
parents: 2160
diff changeset
   481
 * `aihDoesntMatter`: AI hogs don't bother attacking this gear intentionally, or don't bother collecting it if it's a crate
1982
f595ecf7922a LuaGears: Add mention of aihAmmosChanged
Wuzzy
parents: 1979
diff changeset
   482
<wiki:comment>aihAmmosChanged is intentionally not included. This AI hint is for internal use only.</wiki:comment>
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   483
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   484
Example:
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   485
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   486
<code language="lua">
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   487
SetGearAIHints(uselessHog, aihDoesntMatter)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   488
-- This makes AI hogs stop caring about attacking uselessHog</code>
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   489
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   490
== Hedgehog-specific gear properties ==
1939
0cb80de3d5bb LuaGears: Ad IsHogAlive
Wuzzy
parents: 1905
diff changeset
   491
=== `IsHogAlive(gearUid)` (1.0.0) ===
0cb80de3d5bb LuaGears: Ad IsHogAlive
Wuzzy
parents: 1905
diff changeset
   492
Returns `true` if specified gear is a hedgehog, alive, not about to die and not hidden. Returns `false` otherwise.
0cb80de3d5bb LuaGears: Ad IsHogAlive
Wuzzy
parents: 1905
diff changeset
   493
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   494
=== `GetHogName(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   495
Returns the name of the specified hedgehog gear.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   496
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   497
=== `SetHogName(gearUid, name)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   498
Sets the name of the specified hedgehog gear.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   499
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   500
=== `GetHogTeamName(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   501
Returns the name of the specified gear’s team. `gearUid` can be a hedgehog or a grave.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   502
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   503
=== `SetHogTeamName(gearUid, name)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   504
Sets the team name of the specified gear. The gear can be a hedgehog or grave.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   505
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   506
=== `GetHogClan(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   507
Returns the clan ID of the specified hedgehog gear.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   508
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   509
=== `GetHogLevel(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   510
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.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   511
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   512
=== `SetHogLevel(gearUid, level)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   513
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.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   514
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   515
=== `GetEffect(gearUid, effect)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   516
Returns the state of given effect for the given hedgehog gear.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   517
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   518
See `SetEffect` for further details.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   519
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   520
=== `SetEffect(gearUid, effect, effectState)` ===
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   521
Sets the state for one of the effects `heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen` for the specified hedgehog gear.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   522
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.
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   523
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   524
|| *`effect`* || *Description* || *`effectState`* ||
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   525
|| `heInvulnerable` || Wether hog is invulnerable || Any non-zero value turns on invulnerability. `0` turns it off. ||
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   526
|| `hePoisoned` || Poison damage, damages hog each turn. || Amount of damage per turn. Use `0` to disable poisoning. ||
1979
ee5aa6812f52 LuaGears: heResurrectable fail
Wuzzy
parents: 1947
diff changeset
   527
|| `heResurrectable` || Whether to resurrect the hog on death || With a non-zero value, the hedgehog will be resurrected and teleported to a random safe location on death. Resurrection may fail and the hedgehog can still die when there is no or very, very little land left. `0` disables this. ||
2123
7df4304efaef LuaGears: Explain heResurrected better
Wuzzy
parents: 2089
diff changeset
   528
|| `heResurrected` || Whether the hedgehog has been resurrected by the Resurrector utility (resurrection by `heResurrectable` does not count). This is only a subtle graphical effect. || With a non-zero value, the hedgehog was resurrected, `0` otherwise. ||
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   529
|| `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. ||
2077
514babfbad9e Remove outdated legacy hints as clutter
Wuzzy <almikes@aol.com>
parents: 2047
diff changeset
   530
|| `heArtillery` || If enabled, the hedgehog can't walk. || `0` = disabled. `1` = permanently enabled. `2` = temporarily enabled (used by sniper rifle between shots) ||
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   531
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   532
Example (sets all bots poisoned with poison damage of 1):
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   533
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   534
<code language="lua">    function onGearAdd(gear)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   535
        if (GetGearType(gear) == gtHedgehog) and (GetHogLevel(gear) > 0) then
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   536
            SetEffect(gear, hePoisoned, 1)
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   537
        end
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   538
    end</code>
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   539
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   540
=== `GetHogHat(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   541
Returns the hat of the specified hedgehog gear.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   542
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   543
=== `SetHogHat(gearUid, hat)` ===
1905
f94d74ad5939 LuaGears: Update SetHogHat
Wuzzy
parents: 1849
diff changeset
   544
Sets the hat of the specified hedgehog gear. `hat` is the hat name, which equals the file name (case-sensitively) without the file name suffix. If the hat file can not be found on the local computer, the hog will wear no hat.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   545
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   546
=== `GetHogFlag(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   547
Returns the name of the flag of the team of the specified hedgehog gear.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   548
2077
514babfbad9e Remove outdated legacy hints as clutter
Wuzzy <almikes@aol.com>
parents: 2047
diff changeset
   549
=== `GetHogFort(gearUid)` ===
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   550
Returns the name of the fort of the team of the specified hedgehog gear.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   551
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   552
=== `GetHogGrave(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   553
Returns the name of the grave of the team of the specified hedgehog gear.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   554
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   555
=== `GetHogVoicepack(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   556
Returns the name of the voicepack of the team of the specified hedgehog gear.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   557
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   558
=== `GetAmmoCount(gearUid, ammoType)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   559
Returns the ammo count of the specified ammo type for the specified hedgehog gear. If infinite, returns `AMMO_INFINITE`.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   560
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   561
=== `GetAmmoTimer(gearUid, ammoType)` (0.9.25) ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   562
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   563
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   564
Example:
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   565
<code lang="lua">GetAmmoTimer(CurrentHedgehog, amGrenade)
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   566
-- May return 1000, 2000, 3000, 4000 or 5000</code>
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   567
2077
514babfbad9e Remove outdated legacy hints as clutter
Wuzzy <almikes@aol.com>
parents: 2047
diff changeset
   568
=== `HealHog(gearUid, healthBoost[, showMessage[, tint]])` ===
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   569
Convenience function to increase the health of a hedgehog with default visual effects.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   570
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   571
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.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   572
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   573
If `showMessage` is false, no message is shown. With `tint` you can set the RGBA color of the particles (default: `0x00FF00FF`).
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   574
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   575
This function does not affect the poison state, however (see `SetEffect`).
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   576
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   577
=== `HogTurnLeft(gearUid, boolean)` ===
1783
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   578
Faces the specified hog left or right.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   579
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   580
Example:
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   581
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   582
<code language="lua">    HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left 
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   583
    HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   584
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   585
=== `IsHogHidden(gearUid)` (0.9.25) ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   586
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.
1749
91756d20ce3e Separate core Lua stuff into new Lua pages for better maintainability. Main LuaAPI page not touched yet
Wuzzy <almikes@aol.com>
parents:
diff changeset
   587
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   588
=== `HideHog(gearUid)` ===
2077
514babfbad9e Remove outdated legacy hints as clutter
Wuzzy <almikes@aol.com>
parents: 2047
diff changeset
   589
Removes a hedgehog from the map. The hidden hedgehog can be restored with `RestoreHog(gearUid)`. Returns `true` on success and `false` on failure (if gear does not exist / hog is already hidden). You must not hide all hogs at once.
1783
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   590
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   591
Example: 
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   592
1825
1d2aeacbdd8e LuaGears: Add usage warning for HideHog
Wuzzy
parents: 1793
diff changeset
   593
<code language="lua">    local gear = AddHog(...)
1783
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   594
     HideHog(gear) -- Hide the newly created gear.</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   595
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   596
=== `RestoreHog(gearUid)` ===
1783
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   597
Restores a previously hidden hedgehog.  Nothing happens if the hedgehog does not exist or is not hidden.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   598
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   599
Example: 
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   600
1825
1d2aeacbdd8e LuaGears: Add usage warning for HideHog
Wuzzy
parents: 1793
diff changeset
   601
<code language="lua">    local gear = AddHog(...)
1783
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   602
     HideHog(gear) -- Hide the newly created gear.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   603
     RestoreHog(gear) -- Restore the newly hidden gear.</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   604
2077
514babfbad9e Remove outdated legacy hints as clutter
Wuzzy <almikes@aol.com>
parents: 2047
diff changeset
   605
=== `IsHogLocal(gearUid)` ===
1986
399ccb203f0d LuaGears: Special IsHogLocal behaviour
Wuzzy
parents: 1984
diff changeset
   606
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.
399ccb203f0d LuaGears: Special IsHogLocal behaviour
Wuzzy
parents: 1984
diff changeset
   607
399ccb203f0d LuaGears: Special IsHogLocal behaviour
Wuzzy
parents: 1984
diff changeset
   608
If the game has a mission team (see `AddMissionTeam`), this function behaves a little different: It only may return `true` for hogs in the same clan as the mission team and always returns `false` for hogs from other clans.
399ccb203f0d LuaGears: Special IsHogLocal behaviour
Wuzzy
parents: 1984
diff changeset
   609
399ccb203f0d LuaGears: Special IsHogLocal behaviour
Wuzzy
parents: 1984
diff changeset
   610
Returns `nil` if `gearUid` is invalid.
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   611
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   612
This is perfect to hide certain captions like weapon messages from enemy eyes.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   613
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   614
== Special gear actions ==
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   615
=== `GetFollowGear()` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   616
Returns the uid of the gear that is currently being followed.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   617
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   618
=== `FollowGear(gearUid)` ===
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   619
Makes the game client follow the specifiec gear (if it exists). Does not work for visual gears.
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   620
1784
b08f6f71bfbd LuaGears: fix vgState
Wuzzy
parents: 1783
diff changeset
   621
=== `HogSay(gearUid, text, manner [,vgState])` ===
1783
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   622
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.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   623
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   624
The `manner` parameter specifies the type of the bubble and can have one of these values:
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   625
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   626
|| *Value of `manner`* || *Looks* ||
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   627
|| `SAY_THINK` || Thought bubble ||
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   628
|| `SAY_SAY` || Speech bubble ||
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   629
|| `SAY_SHOUT` || Exclamatory bubble (denotes shouting) ||
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   630
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   631
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.
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   632
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   633
|| *Value of `vgState`* || *Effect* ||
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   634
|| `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. ||
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   635
|| `1` || The bubble is drawn translucent. ||
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   636
|| `2` || The bubble is drawn fully opaque. ||
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   637
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   638
Examples:
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   639
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   640
<code language="lua">HogSay(CurrentHedgehog, "I wonder what to do …", SAY_THINK) -- thought bubble with text “I wonder what to do …”</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   641
<code language="lua">HogSay(CurrentHedgehog, "I'm hungry.", SAY_SAY) -- speech bubble with text “I’m hungry.”</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   642
<code language="lua">HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text “I smell CAKE!”</code>
b25684cd9837 LuaGears: Restructure functions
Wuzzy
parents: 1782
diff changeset
   643
1792
3182a44b158e LuaGears: Restructure entire page
Wuzzy
parents: 1785
diff changeset
   644
== Deletion ==
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   645
=== `DeleteGear(gearUid)` ===
1780
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   646
Deletes a gear.  If the specified gear did not exist, nothing happens.
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   647
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   648
Example:
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   649
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   650
<code language="lua">    gear = AddGear(...)
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   651
    DeleteGear(gear) -- Delete the newly created gear.</code>
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   652
1785
95f3d64144bd LuaGears: Replace <tt> with `
Wuzzy
parents: 1784
diff changeset
   653
=== `DeleteVisualGear(vgUid)` ===
1780
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   654
Deletes a visual gear.  If it does not exist, nothing happens. 
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   655
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   656
Note, most visual gears delete themselves after a while.
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   657
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   658
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   659
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   660
Example:
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   661
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   662
<code language="lua">    vgear = AddVisualGear(...)
1b7b2e1ea829 LuaGears: Add deletion section
Wuzzy
parents: 1759
diff changeset
   663
    DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code>