# HG changeset patch # User RedGrinner # Date 1291651185 0 # Node ID ef26ff619aea3ff7f802c18979c9e5bbeeded596 # Parent 2017dc6bc149c5d3f20f29b6dea75c1d9100da2a Edited wiki page LuaAPI through web user interface. diff -r 2017dc6bc149 -r ef26ff619aea LuaAPI.wiki --- 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.