LuaAPI.wiki
changeset 56 bdfa650e1af1
parent 55 ef26ff619aea
child 57 4c941eb04e57
equal deleted inserted replaced
55:ef26ff619aea 56:bdfa650e1af1
    68 </blockquote>
    68 </blockquote>
    69 === <tt>OnGearDamage(gearUid, damage)</tt> ===
    69 === <tt>OnGearDamage(gearUid, damage)</tt> ===
    70 
    70 
    71 <blockquote>This function is called when a gear is damaged.
    71 <blockquote>This function is called when a gear is damaged.
    72 </blockquote>
    72 </blockquote>
    73 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.
    73 Notice: Lua is case-sensitive. The 'O' in 'OnGearDamage' needs to be capitalised, or Hedgewars won't pick up this function call. This unusual capitalisation will probably be fixed in 0.9.15.
    74 
    74 
    75 Example:
    75 Example:
    76 
    76 
    77 <code lang="lua">    function onGearDamage(gear, damage)
    77 <code lang="lua">    function OnGearDamage(gear, damage)
    78         if (!GetGearType(gear) == gtHedgehog) then
    78         if (!GetGearType(gear) == gtHedgehog) then
    79             -- adds a message saying, e.g. "Hoggy H took 25 points of damage"
    79             -- adds a message saying, e.g. "Hoggy H took 25 points of damage"
    80             !AddCaption(!GetHogName(gear) .. ' took ' .. damage .. ' points of damage')
    80             !AddCaption(!GetHogName(gear) .. ' took ' .. damage .. ' points of damage')
    81         end
    81         end
    82     end</code>
    82     end</code>