Language

onDamage


onDamage(string uid, int newhealth)

Description

onDamage() is a callback function called when a bullet hits something.

Parameters

uid
The unique ID of the entity hitted.
newhealth
The new health of the entity.

Examples

Mini boss

  1. local boss = getEntity("boss")
  2.  
  3. function onReset()
  4.     boss:setHealth(100)
  5. end
  6.  
  7. function onDamage(uid, newhealth)
  8.     if uid == "boss" and newhealth == 0 then
  9.         Game.winLevel()
  10.     end
  11. end