11 |
11 |
12 == Creation == |
12 == Creation == |
13 |
13 |
14 === `AddGear(x, y, gearType, state, dx, dy, timer)` === |
14 === `AddGear(x, y, gearType, state, dx, dy, timer)` === |
15 This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]). |
15 This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]). |
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]. |
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]. `timer` is the initial timer value of the gear. If a particular gear value does not matter, use `0`. |
|
17 |
|
18 Position, velocity, state and timer can be changed afterwards with the various setter functions. |
17 |
19 |
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. |
20 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. |
19 |
21 |
20 Example: |
22 Example: |
21 |
23 |
22 <code language="lua"> local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
24 <code language="lua"> -- Spawn a target at (0,0) and place it randomly |
|
25 local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) -- also use 0 for velocity. Also 0 for state and timer because they don't matter. |
23 FindPlace(gear, true, 0, LAND_WIDTH)</code> |
26 FindPlace(gear, true, 0, LAND_WIDTH)</code> |
24 |
27 |
25 === `AddVisualGear(x, y, visualGearType, state, critical [, layer])` === |
28 === `AddVisualGear(x, y, visualGearType, state, critical [, layer])` === |
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]). |
29 This attempts to create a new visual gear at position x,y (measured from top left) of kind `visualGearType` (see [VisualGearTypes Visual Gear Types]). |
27 |
30 |