Edited wiki page LuaAPI through web user interface.
--- a/LuaAPI.wiki Mon Dec 06 15:02:41 2010 +0000
+++ b/LuaAPI.wiki Mon Dec 06 15:59:45 2010 +0000
@@ -66,6 +66,20 @@
<blockquote>This function is called when a new gear is deleted. Useful in
combination with <tt>!GetGearType(gearUid)</tt>.
</blockquote>
+=== <tt>OnGearDamage(gearUid, damage)</tt> ===
+
+<blockquote>This function is called when a gear is damaged.
+</blockquote>
+Notice: Lua is case-sensitive. The 'O' in 'OnGearDamage' needs to be big, or Hedgewars won't pick up this function call. This unusual capitalisation will probably be fixed in 0.9.15.
+
+Example:
+
+<code lang="lua"> function onGearDamage(gear, damage)
+ if (!GetGearType(gear) == gtHedgehog) then
+ -- adds a message saying, e.g. "Hoggy H took 25 points of damage"
+ !AddCaption(!GetHogName(gear) .. ' took ' .. damage .. ' points of damage')
+ end
+ end</code>
=== <tt>onGearResurrect(gearUid)</tt> ===
<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.