Page 1 of 1

Entity ondestroy?

PostPosted: Fri Mar 29, 2013 21:42
by FosJonas
Hello, ive got another Quesition:

if I create an Entity, i can damage them by Punch them and if the life drops under 0 they die, but is there a way to actually react on a dead Entity? like a OnDestroy Function? I didnt found any in the modding ressources.

With OnPunch and a check if the life is below 1 i dont get any results, seems like the damage gets calculated after the OnPunch function?

PostPosted: Fri Mar 29, 2013 21:51
by PilzAdam
FosJonas wrote:With OnPunch and a check if the life is below 1 i dont get any results, seems like the damage gets calculated after the OnPunch function?

This should work. What Minetest version do you run?

PostPosted: Fri Mar 29, 2013 22:35
by FosJonas
Oh, after you said that i tested some more arround and found out that it works with Onpunch, had some weird mistakes in my code.
Thanks for the help.

PostPosted: Sat Mar 30, 2013 00:47
by prestidigitator
We DO need more callbacks like that for entities, though. It's not just punches that can destroy them. Right now the best you can do is hack together some kind of registry and check for entities disappearing (unfindable from minetest.env:get_objects_inside_radius(...) or not reporting using their on_step(...) callback) but still in the registry. And that's really ugly.