Sandbox.wiki
changeset 1789 014d1a4a2133
parent 1788 b562c672140b
child 1790 be31df3b4e3d
equal deleted inserted replaced
1788:b562c672140b 1789:014d1a4a2133
     1 #summary List of gear-related functions in the Lua API
     1 #summary List of gear-related functions in the Lua API
     2 
     2 
     3 = Lua API: Gear functions =
     3 = Lua API: Gear functions =
     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.
     4 This is a list of all functions in the [LuaAPI Lua API] that are related to gears and visual gears.
       
     5 
       
     6 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. Refer to [LuaGuide] for a more detailed introduction into gears. 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.
       
     7 
       
     8 Refer to [LuaGuide] for a more detailed introduction into gears.
     5 
     9 
     6 <wiki:toc max_depth="3"/>
    10 <wiki:toc max_depth="3"/>
     7 
    11 
     8 == Creation ==
    12 == Creation ==
     9 
    13 
    10 === `AddGear(x, y, gearType, state, dx, dy, timer)` ===
    14 === `AddGear(x, y, gearType, state, dx, dy, timer)` ===
    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.
    15 This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]).
    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].
    16 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].
       
    17 
       
    18 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.
    13 
    19 
    14 Example:
    20 Example:
    15 
    21 
    16 <code language="lua">    local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
    22 <code language="lua">    local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
    17     FindPlace(gear, true, 0, LAND_WIDTH)</code>
    23     FindPlace(gear, true, 0, LAND_WIDTH)</code>
    18 
    24 
    19 === `AddVisualGear(x, y, visualGearType, state, critical [, layer])` ===
    25 === `AddVisualGear(x, y, visualGearType, state, critical [, layer])` ===
    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.
    26 This attempts to create a new visual gear at position x,y (measured from top left) of kind `visualGearType` (see [VisualGearTypes Visual Gear Types]).
    21 
    27 
    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`.
    28 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`.
    23 
    29 
    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).
    30 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).
    25 
    31