55 === <tt>onGameTick()</tt> === |
55 === <tt>onGameTick()</tt> === |
56 |
56 |
57 <blockquote>This function is called on every game tick, i.e. 1000 times a second. |
57 <blockquote>This function is called on every game tick, i.e. 1000 times a second. |
58 </blockquote> |
58 </blockquote> |
59 |
59 |
60 === <tt>onNewTurn()</tt> === |
60 === <tt>onNewTurn()</tt> (dev) === |
61 |
61 |
62 <blockquote>This function calls at the start of every turn. |
62 <blockquote>This function calls at the start of every turn. |
63 </blockquote> |
63 </blockquote> |
64 === <tt>onGearAdd(gearUid)</tt> === |
64 === <tt>onGearAdd(gearUid)</tt> === |
65 |
65 |
69 === <tt>onGearDelete(gearUid)</tt> === |
69 === <tt>onGearDelete(gearUid)</tt> === |
70 |
70 |
71 <blockquote>This function is called when a new gear is deleted. Useful in |
71 <blockquote>This function is called when a new gear is deleted. Useful in |
72 combination with <tt>!GetGearType(gearUid)</tt>. |
72 combination with <tt>!GetGearType(gearUid)</tt>. |
73 </blockquote> |
73 </blockquote> |
74 === <tt>onGearDamage(gearUid, damage)</tt> === |
74 === <tt>onGearDamage(gearUid, damage)</tt> (dev) === |
75 |
75 |
76 <blockquote>This function is called when a gear is damaged. |
76 <blockquote>This function is called when a gear is damaged. |
77 </blockquote> |
77 </blockquote> |
78 |
78 |
79 Example: |
79 Example: |
82 if (!GetGearType(gear) == gtHedgehog) then |
82 if (!GetGearType(gear) == gtHedgehog) then |
83 -- adds a message saying, e.g. "Hoggy H took 25 points of damage" |
83 -- adds a message saying, e.g. "Hoggy H took 25 points of damage" |
84 !AddCaption(!GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
84 !AddCaption(!GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
85 end |
85 end |
86 end</code> |
86 end</code> |
87 === <tt>onGearResurrect(gearUid)</tt> === |
87 === <tt>onGearResurrect(gearUid) (dev)</tt> === |
88 |
88 |
89 <blockquote>This function is called when a gear is resurrected. CPU Hogs will resurrect if gfAISurvival is included in !GameFlags. Alternatively, specific gears can have heResurrectable set to true via !SetEffect. |
89 <blockquote>This function is called when a gear is resurrected. CPU Hogs will resurrect if gfAISurvival is included in !GameFlags. Alternatively, specific gears can have heResurrectable set to true via !SetEffect. |
90 </blockquote> |
90 </blockquote> |
91 === <tt>onAmmoStoreInit()</tt> === |
91 === <tt>onAmmoStoreInit()</tt> === |
92 |
92 |
201 === <tt>!GetBotLevel(gearUid)</tt> (0.9.14) === |
201 === <tt>!GetBotLevel(gearUid)</tt> (0.9.14) === |
202 |
202 |
203 <blockquote>returns the bot level from 0 to 5. 0 means human player. |
203 <blockquote>returns the bot level from 0 to 5. 0 means human player. |
204 </blockquote> |
204 </blockquote> |
205 |
205 |
206 === <tt>!GetVisualGearValues(vgUid)</tt> === |
206 === <tt>!GetVisualGearValues(vgUid)</tt> (dev) === |
207 |
207 |
208 <blockquote>This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values: |
208 <blockquote>This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values: |
209 X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint |
209 X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint |
210 X, Y typically position, dX, dY typically speed, Angle is usually the rotation angle, Frame is typically the animation frame, FrameTicks is usually an animation counter. State can have a variety of values, but is typically bit packed, Timer is usually the gear lifetime and Tint is the colour. |
210 X, Y typically position, dX, dY typically speed, Angle is usually the rotation angle, Frame is typically the animation frame, FrameTicks is usually an animation counter. State can have a variety of values, but is typically bit packed, Timer is usually the gear lifetime and Tint is the colour. |
211 Most visual gears require little to no modification of parameters. |
211 Most visual gears require little to no modification of parameters. |
223 Example: |
223 Example: |
224 |
224 |
225 <code lang="lua"> gear = !AddGear(…) |
225 <code lang="lua"> gear = !AddGear(…) |
226 !DeleteGear(gear) -- Delete the newly created gear.</code> |
226 !DeleteGear(gear) -- Delete the newly created gear.</code> |
227 |
227 |
228 === <tt>!DeleteVisualGear(vgUid)</tt> === |
228 === <tt>!DeleteVisualGear(vgUid)</tt> (dev) === |
229 |
229 |
230 <blockquote>Deletes a Visual Gear. Note, most visual gears delete themselves.</blockquote> |
230 <blockquote>Deletes a Visual Gear. Note, most visual gears delete themselves.</blockquote> |
231 Example: |
231 Example: |
232 |
232 |
233 <code lang="lua"> vgear = !AddVisualGear(…) |
233 <code lang="lua"> vgear = !AddVisualGear(…) |
234 !DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code> |
234 !DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code> |
235 |
235 |
236 |
236 |
237 === <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)</tt> === |
237 === <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)</tt> (dev) === |
238 |
238 |
239 <blockquote>This allows manipulation of many of the visual gear values. Calling GetVisualGearValues first is recommended on most visual gears unless you are controlling all the key values. In the case of vgtCircle, the visual gear values are mapped as follows. X, Y: position. State: radius. Timer: Thickness. FrameTicks: pulsation speed (0 to disable). dX, dY: min/max pulsation opacity (0-255). Tint: colour, RGBA. |
239 <blockquote>This allows manipulation of many of the visual gear values. Calling GetVisualGearValues first is recommended on most visual gears unless you are controlling all the key values. In the case of vgtCircle, the visual gear values are mapped as follows. X, Y: position. State: radius. Timer: Thickness. FrameTicks: pulsation speed (0 to disable). dX, dY: min/max pulsation opacity (0-255). Tint: colour, RGBA. |
240 Most visual gears require little to no modification of parameters. |
240 Most visual gears require little to no modification of parameters. |
241 </blockquote> |
241 </blockquote> |
242 Example: |
242 Example: |
371 === <tt>!GetRandom(number)</tt> (0.9.14) === |
371 === <tt>!GetRandom(number)</tt> (0.9.14) === |
372 |
372 |
373 <blockquote>Returns a randomly generated number in the range of 0 to number - 1. This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games. Use GetRandom for anything that could impact the engine state. For example, a visual gear can use the Lua random, but adding a regular gear should use GetRandom. |
373 <blockquote>Returns a randomly generated number in the range of 0 to number - 1. This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games. Use GetRandom for anything that could impact the engine state. For example, a visual gear can use the Lua random, but adding a regular gear should use GetRandom. |
374 </blockquote> |
374 </blockquote> |
375 |
375 |
376 === <tt>!SetWind(windSpeed)</tt> (development) === |
376 === <tt>!SetWind(windSpeed)</tt> (dev) === |
377 |
377 |
378 <blockquote>Sets the current wind in the range of -100 to 100. Use together with gfDisableWind for full control. |
378 <blockquote>Sets the current wind in the range of -100 to 100. Use together with gfDisableWind for full control. |
379 </blockquote> |
379 </blockquote> |
380 |
380 |
|
381 === <tt>!GetDataPath()</tt> (dev) === |
|
382 |
|
383 <blockquote>Returns the path to the data directory, used when adding libraries. |
|
384 </blockquote> |
|
385 |
381 == Debugging Functions == |
386 == Debugging Functions == |
382 |
387 |
383 === <tt>!WriteLnToConsole(string)</tt> (0.9.14) === |
388 === <tt>!WriteLnToConsole(string)</tt> (0.9.14) === |
384 |
389 |
385 <blockquote>Guess :D |
390 <blockquote>Guess :D |