Page 1 of 1

[SOLVED] get_hp 4.16

Posted: Wed Oct 16, 2019 04:03
by bikerchick
Hey,

I upgraded to 4.16 from 4.14 and am having problems with object:get_hp() in an on_punch event tied to an entity.

If I comment out the second line everything works. So I'm not sure what happened, I don't imagine too much has changed in 4.16?

Thanks for any help,
Madi

Code: Select all

on_punch = function(self, hitter)
                        if self.object:get_hp() <= 0 then
                        ..............

Re: get_hp 4.16

Posted: Wed Oct 16, 2019 06:29
by rubenwardy
0.4.16 is over 2 years out of date. The latest version is 5.1.0, released a few days ago. I say this because we don't support outdated versions (ie: if this is an engine bug only in 0.4.16, we won't fix it)

Also, when asking for help you should say what it is that isn't working. For example, does it crash or not behave how you expect?

Re: get_hp 4.16

Posted: Wed Oct 16, 2019 15:56
by Krock
In future reports (using the most recent stable version), please also include the relevant debug.txt lines to help us tracking down the issue.
https://wiki.minetest.net/Reporting_bugs

Re: get_hp 4.16

Posted: Wed Oct 16, 2019 16:13
by bikerchick
Maybe this is in the wrong board? I'll try again... but I can repost in a different board if necessary.

The mod is a pilzadam framework mod, where a punched mob is supposed to drop an item if hp<=0. However, it seems that hp is not returned. IE. it just skips over till end. There is no output in debug.txt regarding the problem, so therefor there's nothing to debug.

Has no one else had a problem with object:get_hp() in 4.16 or higher?

EDIT---

I'm starting to wonder if the entity is being removed before the on_punch event triggers.... that would explain a few things...

Re: get_hp 4.16

Posted: Wed Oct 16, 2019 18:11
by bikerchick
Alright, upon further debugging, I have come to find that the entity is indeed removed before the on_punch event.

Log:

Code: Select all

2019-10-16 13:07:48: ACTION[Server]: madi punches object 19: LuaEntitySAO at (4.56142,3.5,-149.451)
on_punch hp= 1
2019-10-16 13:07:48: ACTION[Server]: LuaEntitySAO at (4.56142,3.5,-149.451) punched by player madi, damage 1 hp, health now 0 hp

Re: get_hp 4.16

Posted: Wed Oct 16, 2019 19:59
by bikerchick
Solved by reverting back to 0.4.14.

Re: get_hp 4.16

Posted: Wed Oct 16, 2019 20:02
by rubenwardy
bikerchick wrote:Solved by reverting back to 0.4.14.
Using software 6 versions and 3 years out of date isn't a solution

Also, I can't find a mod called "framework" by PilzAdam.
If you're referring to either Simple Mobs by PilzAdam or Animal Framework by sapier, then you should use Mobs Redo instead - it's actually maintained

Re: [SOLVED] get_hp 4.16

Posted: Wed Oct 16, 2019 22:37
by bikerchick
Yeah thanks for not helping, at all. Next time, if you don't have a clue, just ignore my threads, and leave the replies to someone who might have an idea.

Thanks!

Re: [SOLVED] get_hp 4.16

Posted: Wed Oct 16, 2019 22:43
by rubenwardy
You barely gave any relevant information to actually let us help you, and then went with the lazy solution. My first question was about the full nature of the problem, then the second question was after I was trying to find the full code to be able to reproduce it if a simple example didn't.

I work a full time job and invest many hours developing Minetest, writing the modding book, and working on related third-party projects. After spending all that time, receiving that response doesn't really motivate me to look into to the cause of this and see if this still happens on a supported version of Minetest

Re: [SOLVED] get_hp 4.16

Posted: Wed Oct 16, 2019 23:14
by Lone_Wolf
@bikerchick Why are you still using 0.4.14? The latest Minetest (5.1) is a lot better. Not many mods are going to be backwards-compatible with 0.4.x anyway

Re: [SOLVED] get_hp 4.16

Posted: Wed Oct 16, 2019 23:59
by Sokomine
bikerchick wrote: Yeah thanks for not helping, at all. Next time, if you don't have a clue, just ignore my threads, and leave the replies to someone who might have an idea.
But the information that simple_mobs by PilzAdam is no longer maintained and that it might be a good idea to use its successor - mobs_redo - instead is good advice. A lot changed in the meantime; mobs_redo runs fine on servers and supports more features. What prevents you from updating?

Re: [SOLVED] get_hp 4.16

Posted: Wed Apr 15, 2020 03:39
by wulfsdad
bikerchick wrote:
having problems with object:get_hp() in an on_punch event tied to an entity.
...

Code: Select all

on_punch = function(self, hitter)
                        if self.object:get_hp() <= 0 then
                        ..............
Use on_death instead.