5 |
5 |
6 <wiki:toc max_depth="3"/> |
6 <wiki:toc max_depth="3"/> |
7 |
7 |
8 == Functions for creating gears == |
8 == Functions for creating gears == |
9 |
9 |
10 === <tt>!AddGear(x, y, gearType, state, dx, dy, timer)</tt> === |
10 === `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. |
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. |
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]. |
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]. |
13 |
13 |
14 Example: |
14 Example: |
15 |
15 |
16 <code language="lua"> local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
16 <code language="lua"> local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
17 FindPlace(gear, true, 0, LAND_WIDTH)</code> |
17 FindPlace(gear, true, 0, LAND_WIDTH)</code> |
18 |
18 |
19 === <tt>!AddVisualGear(x, y, visualGearType, state, critical [, layer])</tt> === |
19 === `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. |
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. |
21 |
21 |
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`. |
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`. |
23 |
23 |
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). |
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). |
70 AddMissionHog(100) |
70 AddMissionHog(100) |
71 AddMissionHog(100) |
71 AddMissionHog(100) |
72 AddHog("My Hardcoded Hog", 0, 100, "NoHat") |
72 AddHog("My Hardcoded Hog", 0, 100, "NoHat") |
73 </code> |
73 </code> |
74 |
74 |
75 === <tt>!SpawnHealthCrate(x, y, [, health])</tt> === |
75 === `SpawnHealthCrate(x, y, [, health])` === |
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`. |
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`. |
77 |
77 |
78 === <tt>!SpawnSupplyCrate(x, y, ammoType [, amount])</tt> (0.9.24) === |
78 === `SpawnSupplyCrate(x, y, ammoType [, amount])` (0.9.24) === |
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. |
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. |
80 Otherwise, this function behaves like `SpawnAmmoCrate`. |
80 Otherwise, this function behaves like `SpawnAmmoCrate`. |
81 |
81 |
82 === <tt>!SpawnAmmoCrate(x, y, ammoType [, amount])</tt> === |
82 === `SpawnAmmoCrate(x, y, ammoType [, amount])` === |
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. |
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. |
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. |
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. |
85 |
85 |
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: |
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: |
87 |
87 |
88 Example: |
88 Example: |
89 |
89 |
90 <code language="lua"> SetAmmo(amGrenade, 0, 0, 0, 1) -- grenade ammo crates now contain 1 grenade each |
90 <code language="lua"> SetAmmo(amGrenade, 0, 0, 0, 1) -- grenade ammo crates now contain 1 grenade each |
91 SpawnAmmoCrate(0, 0, amGrenade) -- spawn grenade ammo crate at random position</code> |
91 SpawnAmmoCrate(0, 0, amGrenade) -- spawn grenade ammo crate at random position</code> |
92 |
92 |
93 === <tt>!SpawnUtilityCrate(x, y, ammoType [, amount])</tt> === |
93 === `SpawnUtilityCrate(x, y, ammoType [, amount])` === |
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. |
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. |
95 |
95 |
96 Example: |
96 Example: |
97 |
97 |
98 <code language="lua"> SetAmmo(amLaserSight, 0, 0, 0, 1) |
98 <code language="lua"> SetAmmo(amLaserSight, 0, 0, 0, 1) |
99 SpawnUtilityCrate(0, 0, amLaserSight)</code> |
99 SpawnUtilityCrate(0, 0, amLaserSight)</code> |
100 |
100 |
101 === <tt>!SpawnFakeAmmoCrate(x, y, explode, poison) </tt> === |
101 === `SpawnFakeAmmoCrate(x, y, explode, poison) ` === |
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). |
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). |
103 `explode` and `poison` are booleans. |
103 `explode` and `poison` are booleans. |
104 If `explode` is `true`, the crate will explode when collected. |
104 If `explode` is `true`, the crate will explode when collected. |
105 If `poison` is `true`, the collector will be poisoned. |
105 If `poison` is `true`, the collector will be poisoned. |
106 |
106 |
107 Example: |
107 Example: |
108 |
108 |
109 <code language="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison. |
109 <code language="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison. |
110 </code> |
110 </code> |
111 |
111 |
112 === <tt>!SpawnFakeHealthCrate(x, y, explode, poison) </tt> === |
112 === `SpawnFakeHealthCrate(x, y, explode, poison) ` === |
113 Same as `SpawnFakeAmmoCrate`, except the crate will look like a health crate. |
113 Same as `SpawnFakeAmmoCrate`, except the crate will look like a health crate. |
114 |
114 |
115 === <tt>!SpawnFakeUtilityCrate(x, y, explode, poison) </tt> === |
115 === `SpawnFakeUtilityCrate(x, y, explode, poison) ` === |
116 Same as `SpawnFakeAmmoCrate`, except the crate will look like an utility crate. |
116 Same as `SpawnFakeAmmoCrate`, except the crate will look like an utility crate. |
117 |
117 |
118 == Functions to get gear properties == |
118 == Functions to get gear properties == |
119 |
119 |
120 === <tt>!GetGearType(gearUid)</tt> === |
120 === `GetGearType(gearUid)` === |
121 This function returns the [GearTypes gear type] for the specified gear, if it exists. If it doesn't exist, `nil` is returned. |
121 This function returns the [GearTypes gear type] for the specified gear, if it exists. If it doesn't exist, `nil` is returned. |
122 |
122 |
123 === <tt>!GetVisualGearType(vgUid)</tt> (0.9.23) === |
123 === `GetVisualGearType(vgUid)` (0.9.23) === |
124 This function returns the [VisualGearTypes visual gear type] for the specified visual gear, if it exists. If it doesn't exist, `nil` is returned. |
124 This function returns the [VisualGearTypes visual gear type] for the specified visual gear, if it exists. If it doesn't exist, `nil` is returned. |
125 |
125 |
126 === <tt>!GetGearPosition(gearUid)</tt> === |
126 === `GetGearPosition(gearUid)` === |
127 Returns x,y coordinates for the specified gear. Not to be confused with `GetGearPos`. |
127 Returns x,y coordinates for the specified gear. Not to be confused with `GetGearPos`. |
128 |
128 |
129 === <tt>GetGearCollisionMask(gearUid)</tt> === |
129 === `GetGearCollisionMask(gearUid)` === |
130 Returns the current collision mask of the given gear. See `SetGearCollisionMask` for an explanation of the mask. |
130 Returns the current collision mask of the given gear. See `SetGearCollisionMask` for an explanation of the mask. |
131 |
131 |
132 === <tt>!GetGearRadius(gearUid)</tt> === |
132 === `GetGearRadius(gearUid)` === |
133 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. |
133 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. |
134 |
134 |
135 To set the `Radius` value, use `SetGearValues`. |
135 To set the `Radius` value, use `SetGearValues`. |
136 |
136 |
137 === <tt>!GetGearVelocity(gearUid)</tt> === |
137 === `GetGearVelocity(gearUid)` === |
138 Returns a tuple of dx,dy values for the specified gear. |
138 Returns a tuple of dx,dy values for the specified gear. |
139 |
139 |
140 === <tt>!GetFlightTime(gearUid)</tt> === |
140 === `GetFlightTime(gearUid)` === |
141 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. |
141 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. |
142 |
142 |
143 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. |
143 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. |
144 |
144 |
145 === <tt>!GetGearElasticity(gearUid) </tt> === |
145 === `GetGearElasticity(gearUid) ` === |
146 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. |
146 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. |
147 |
147 |
148 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. |
148 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. |
149 |
149 |
150 === <tt>!GetGearFriction(gearUid) </tt> === |
150 === `GetGearFriction(gearUid) ` === |
151 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. |
151 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. |
152 |
152 |
153 === <tt>!GetHogClan(gearUid)</tt> === |
153 === `GetHogClan(gearUid)` === |
154 Returns the clan ID of the specified hedgehog gear. |
154 Returns the clan ID of the specified hedgehog gear. |
155 |
155 |
156 === <tt>!GetHogTeamName(gearUid)</tt> === |
156 === `GetHogTeamName(gearUid)` === |
157 Returns the name of the specified gear’s team. `gearUid` can be a hedgehog or a grave. |
157 Returns the name of the specified gear’s team. `gearUid` can be a hedgehog or a grave. |
158 |
158 |
159 === <tt>!GetHogName(gearUid)</tt> === |
159 === `GetHogName(gearUid)` === |
160 Returns the name of the specified hedgehog gear. |
160 Returns the name of the specified hedgehog gear. |
161 |
161 |
162 === <tt>!IsHogHidden(gearUid)</tt> (0.9.25) === |
162 === `IsHogHidden(gearUid)` (0.9.25) === |
163 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. |
163 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. |
164 |
164 |
165 === <tt>!GetEffect(gearUid, effect)</tt> === |
165 === `GetEffect(gearUid, effect)` === |
166 Returns the state of given effect for the given hedgehog gear. |
166 Returns the state of given effect for the given hedgehog gear. |
167 |
167 |
168 See `SetEffect` for further details. |
168 See `SetEffect` for further details. |
169 |
169 |
170 === <tt>!GetHogHat(gearUid)</tt> === |
170 === `GetHogHat(gearUid)` === |
171 Returns the hat of the specified hedgehog gear. |
171 Returns the hat of the specified hedgehog gear. |
172 |
172 |
173 === <tt>!GetHogFlag(gearUid)</tt> === |
173 === `GetHogFlag(gearUid)` === |
174 Returns the name of the flag of the team of the specified hedgehog gear. |
174 Returns the name of the flag of the team of the specified hedgehog gear. |
175 |
175 |
176 === <tt>!GetHogFort(gearUid)</tt> (0.9.23) === |
176 === `GetHogFort(gearUid)` (0.9.23) === |
177 Returns the name of the fort of the team of the specified hedgehog gear. |
177 Returns the name of the fort of the team of the specified hedgehog gear. |
178 |
178 |
179 === <tt>!GetHogGrave(gearUid)</tt> === |
179 === `GetHogGrave(gearUid)` === |
180 Returns the name of the grave of the team of the specified hedgehog gear. |
180 Returns the name of the grave of the team of the specified hedgehog gear. |
181 |
181 |
182 === <tt>!GetHogVoicepack(gearUid)</tt> === |
182 === `GetHogVoicepack(gearUid)` === |
183 Returns the name of the voicepack of the team of the specified hedgehog gear. |
183 Returns the name of the voicepack of the team of the specified hedgehog gear. |
184 |
184 |
185 === <tt>!GetAmmoCount(gearUid, ammoType)</tt> === |
185 === `GetAmmoCount(gearUid, ammoType)` === |
186 Returns the ammo count of the specified ammo type for the specified hedgehog gear. If infinite, returns `AMMO_INFINITE`. |
186 Returns the ammo count of the specified ammo type for the specified hedgehog gear. If infinite, returns `AMMO_INFINITE`. |
187 |
187 |
188 === <tt>!GetAmmoTimer(gearUid, ammoType)</tt> (0.9.25) === |
188 === `GetAmmoTimer(gearUid, ammoType)` (0.9.25) === |
189 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. |
189 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. |
190 |
190 |
191 Example: |
191 Example: |
192 <code lang="lua">GetAmmoTimer(CurrentHedgehog, amGrenade) |
192 <code lang="lua">GetAmmoTimer(CurrentHedgehog, amGrenade) |
193 -- May return 1000, 2000, 3000, 4000 or 5000</code> |
193 -- May return 1000, 2000, 3000, 4000 or 5000</code> |
194 |
194 |
195 === <tt>!IsHogLocal(gearUid)</tt> (0.9.23) === |
195 === `IsHogLocal(gearUid)` (0.9.23) === |
196 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. |
196 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. |
197 |
197 |
198 This is perfect to hide certain captions like weapon messages from enemy eyes. |
198 This is perfect to hide certain captions like weapon messages from enemy eyes. |
199 |
199 |
200 === <tt>!GetGearTarget(gearUid, x, y) </tt> === |
200 === `GetGearTarget(gearUid, x, y) ` === |
201 Returns the x and y coordinate of target-based weapons/utilities. |
201 Returns the x and y coordinate of target-based weapons/utilities. |
202 <b>Note:</b>: This can’t be used in `onGearAdd()` but must be called after gear creation. |
202 <b>Note:</b>: This can’t be used in `onGearAdd()` but must be called after gear creation. |
203 |
203 |
204 === <tt>GetX(gearUid)</tt> === |
204 === `GetX(gearUid)` === |
205 Returns x coordinate of the gear. |
205 Returns x coordinate of the gear. |
206 |
206 |
207 === <tt>GetY(gearUid)</tt> === |
207 === `GetY(gearUid)` === |
208 Returns y coordinate of the gear. |
208 Returns y coordinate of the gear. |
209 |
209 |
210 === <tt>!GetState(gearUid)</tt> === |
210 === `GetState(gearUid)` === |
211 Returns the state of the gear. The gear state is a bitmask which is built out of the variables as shown in [States]. |
211 Returns the state of the gear. The gear state is a bitmask which is built out of the variables as shown in [States]. |
212 |
212 |
213 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. |
213 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. |
214 |
214 |
215 Examples: |
215 Examples: |
254 -- Now colorTag stores the tag of ball (in this case a number denoting its color) |
254 -- Now colorTag stores the tag of ball (in this case a number denoting its color) |
255 </code> |
255 </code> |
256 |
256 |
257 The meaning of tags are described in [GearTypes]. |
257 The meaning of tags are described in [GearTypes]. |
258 |
258 |
259 === <tt>!GetFollowGear()</tt> === |
259 === `GetFollowGear()` === |
260 Returns the uid of the gear that is currently being followed. |
260 Returns the uid of the gear that is currently being followed. |
261 |
261 |
262 === <tt>!GetTimer(gearUid)</tt> === |
262 === `GetTimer(gearUid)` === |
263 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. |
263 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. |
264 |
264 |
265 === <tt>!GetHealth(gearUid)</tt> === |
265 === `GetHealth(gearUid)` === |
266 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. |
266 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. |
267 |
267 |
268 === <tt>!GetHogLevel(gearUid)</tt> === |
268 === `GetHogLevel(gearUid)` === |
269 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. |
269 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. |
270 |
270 |
271 === <tt>!GetGearPos(gearUid)</tt> === |
271 === `GetGearPos(gearUid)` === |
272 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. |
272 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. |
273 |
273 |
274 *Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that. |
274 *Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that. |
275 |
275 |
276 === <tt>!GetGearValues(gearUid)</tt> === |
276 === `GetGearValues(gearUid)` === |
277 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. |
277 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. |
278 |
278 |
279 This is returned (all variables are integers): |
279 This is returned (all variables are integers): |
280 |
280 |
281 `Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom` |
281 `Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom` |
309 <code language="lua">-- Return visual gear values |
309 <code language="lua">-- Return visual gear values |
310 local X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale = GetVisualGearValues(vgUid) |
310 local X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale = GetVisualGearValues(vgUid) |
311 </code> |
311 </code> |
312 |
312 |
313 == Functions to change position and velocity == |
313 == Functions to change position and velocity == |
314 === <tt>!SetGearPosition(gearUid, x, y)</tt> === |
314 === `SetGearPosition(gearUid, x, y)` === |
315 Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`. |
315 Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`. |
316 |
316 |
317 === <tt>!SetGearVelocity(gearUid, dx, dy)</tt> === |
317 === `SetGearVelocity(gearUid, dx, dy)` === |
318 Gives the specified gear the velocity of `dx`, `dy`. |
318 Gives the specified gear the velocity of `dx`, `dy`. |
319 |
319 |
320 === <tt>CopyPV(gearUid, gearUid)</tt> === |
320 === `CopyPV(gearUid, gearUid)` === |
321 This sets the position and velocity of the second gear to the first one. |
321 This sets the position and velocity of the second gear to the first one. |
322 |
322 |
323 === <tt>!FindPlace(gearUid, fall, left, right[, tryHarder])</tt> === |
323 === `FindPlace(gearUid, fall, left, right[, tryHarder])` === |
324 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. |
324 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. |
325 |
325 |
326 Example: |
326 Example: |
327 |
327 |
328 <code language="lua"> gear = AddGear(...) |
328 <code language="lua"> gear = AddGear(...) |
329 FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code> |
329 FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code> |
330 |
330 |
331 == Functions to modify gears == |
331 == Functions to modify gears == |
332 === <tt>!SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)</tt> === |
332 === `SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)` === |
333 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. |
333 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. |
334 |
334 |
335 Set `nil` for each value you do not want to change. |
335 Set `nil` for each value you do not want to change. |
336 |
336 |
337 Example: |
337 Example: |