equal
deleted
inserted
replaced
73 </blockquote> |
73 </blockquote> |
74 === <tt>onGearDamage(gearUid, damage)</tt> === |
74 === <tt>onGearDamage(gearUid, damage)</tt> === |
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 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. |
78 |
79 |
79 Example: |
80 Example: |
80 |
81 |
81 <code lang="lua"> function !onGearDamage(gear, damage) |
82 <code lang="lua"> function !OnGearDamage(gear, damage) |
|
83 if (!GetGearType(gear) == gtHedgehog) then |
82 if (!GetGearType(gear) == gtHedgehog) then |
84 -- 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" |
85 !AddCaption(!GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
84 !AddCaption(!GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
86 end |
85 end |
87 end</code> |
86 end</code> |