TNT: Allow mods to override entity physics.
authorAuke Kok <sofar@foo-projects.org>
Thu, 28 Apr 2016 03:15:52 +0000 (20:15 -0700)
committerparamat <mat.gregory@virginmedia.com>
Sat, 30 Apr 2016 19:47:21 +0000 (20:47 +0100)
commit098ea0d10a181ea1bcc98d72766969b5c94cd945
tree9fa5aba125ce59e04567693ecb528d0bcfd615d8
parentf14b41115705647a33dbb874c5b0fcab73cd5376
TNT: Allow mods to override entity physics.

Introduces an `on_blast(luaobj, damage)` callback that mods can attach
to an entity def. The function will get called with the damage that
TNT would make.

The function should return three values:

  bool do_damage, bool do_knockback, table drops

do_damage allows the mod to tell the TNT code to perform damage on
the entity for the mod. The mod code should not do anything with
the entity HP. The entity should not be immortal. If false, then
the entity will not be damaged by the TNT mod.

do_knockback allows the mod to tell the TNT mod to perform an
entity knockback effect. If false, no knockback effect is applied
to the entity.

the drops table is a list of items to drop. It may be nil. E.g. {
"wool:red" }.

I've documented both on_blast() API methods in game_api.txt. It is
a better place than lua_api.txt.
game_api.txt
mods/tnt/init.lua