# HG changeset patch
# User Wuzzy
# Date 1555507256 -3600
# Node ID 014d1a4a2133337bb8c040e99920fa6f74ef73c0
# Parent b562c672140b40c0dda8904778069e62cedee24a
Sandbox: Edited via web interface
diff -r b562c672140b -r 014d1a4a2133 Sandbox.wiki
--- a/Sandbox.wiki Wed Apr 17 14:15:28 2019 +0100
+++ b/Sandbox.wiki Wed Apr 17 14:20:56 2019 +0100
@@ -1,23 +1,29 @@
#summary List of gear-related functions in the Lua API
= Lua API: Gear functions =
-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.
+This is a list of all functions in the [LuaAPI Lua API] that are related to gears and visual gears.
+
+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.
+
+Refer to [LuaGuide] for a more detailed introduction into gears.
== Creation ==
=== `AddGear(x, y, gearType, state, dx, dy, timer)` ===
-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.
+This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]).
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].
+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.
+
Example:
local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
FindPlace(gear, true, 0, LAND_WIDTH)
=== `AddVisualGear(x, y, visualGearType, state, critical [, layer])` ===
-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.
+This attempts to create a new visual gear at position x,y (measured from top left) of kind `visualGearType` (see [VisualGearTypes Visual Gear Types]).
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`.