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