Health
Hit points. Scripts call Damage (or a DamageOnTouch does it with no code); after a hit the entity can’t be hurt again for InvincibleTime, flashing and blinking to show it. At zero it dies: its behaviors hear OnDeath, the DeathMessage is sent, and it’s destroyed.
Works with: Bar (a health bar (on another entity))
Needed by: Battler
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
max: a number = 3. Most hit points it can have. Changing it while at full health keeps it at full health. (Field: a number.)current: a number = 3. Hit points now. Normally starts at Max. (Field: a number.)
When Hit
Section titled “When Hit”invincibleTime: a number = 0.5. Seconds after a hit during which further damage is ignored. 0 lets every hit land. (Field: a number.)flashOnHit: true or false = true. Flash the entity’s sprites white when hit. (Field: on or off.)blinkWhileInvincible: true or false = true. Blink the entity’s sprites while it can’t be hurt. (Only used when invincibleTime is set.) (Field: on or off.)
destroyOnDeath: true or false = true. Destroy the entity when it dies. Turn off to play a death animation first, and destroy it from a script. (Field: on or off.)deathMessage: text = null. A message sent with Game.Send when it dies, with the entity as its data, e.g. “PlayerDied” or “EnemyDied”. (Names a message.) (Field: a name.)respawn: true or false = false. Come back after dying instead of being destroyed: hidden for RespawnDelay, then back at full health at the active Checkpoint (or where it started), briefly invincible. For the player in a platformer. (Field: on or off.)respawnDelay: a number = 1. Seconds it stays gone before it comes back (see Respawn). (Only used when respawn is on.) (Field: a number.)
Sounds
Section titled “Sounds”hurtSound: text = null. Plays when damage lands but doesn’t kill, from where it is. Make one with Audio > New Sound (Hit). (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)deathSound: text = null. Plays when it dies, from where it is: an explosion, a last cry. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
Saving
Section titled “Saving”saveAs: text = null. Keeps its hit points (and its Max) in the game’s save data under this name, e.g. “Hearts”, so a health saved as the same name in the next scene starts with them (the player walking into the next level hurt) and so does the next run. Saved at zero (it died) it starts full. Empty keeps nothing. (Names a name in the save data: this entity’s own, which other fields can name.) (Field: a name.)loaded: true or false = false. Set by the game once it has taken its hit points from the save data, so a rewind doesn’t do it again. Leave it be. (Field: on or off.)
Actions
Section titled “Actions”What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).
Damage(done with a number, its amount: a trigger’s with, 1 without one). Takes amount hit points away, as a hit does (not while it can’t be hurt after the last one).Heal(done with a number, its amount: a trigger’s with, 1 without one). Gives back up to amount hit points, never past its Max.Kill. Dies straight away, invincible or not: falling out of the world, a reset button.
Outputs
Section titled “Outputs”What anything can read with no code: a Counter’s, Bar’s or Text’s output, a Contraptions Wire’s output as its signal; Text shows names too, the rest read numbers, true as 1.
Health(a number, out of its max). Hit points now. Normally starts at Max.
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
isDead: true or falseisInvincible: true or false. True for InvincibleTime after a hit.
Scripts use it as Health: its methods, events and values that aren’t saved with the scene.