Entity ondestroy?

FosJonas
Member
 
Posts: 10
Joined: Thu Aug 23, 2012 12:44

Entity ondestroy?

by FosJonas » Fri Mar 29, 2013 21:42

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?
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Mar 29, 2013 21:51

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?
 

FosJonas
Member
 
Posts: 10
Joined: Thu Aug 23, 2012 12:44

by FosJonas » Fri Mar 29, 2013 22:35

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.
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Sat Mar 30, 2013 00:47

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.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 5 guests

cron