Page 2 of 4

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Fri Feb 08, 2019 07:23
by Linuxdirk
Please make sure to use the latest available Git versions of Minetest, Minetest Game, Hunger NG, and Hudbars. Make sure that Hudbars runs without any issues, make sure Hunger NG runs without any issues. Then enable both Hudbars and Hunger NG and provide the error message you get. Preferably over at GitLab. Thanks!

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Fri Feb 08, 2019 14:49
by runs
I use hbhunger with hudbar, and all OK. When I replace to hunger_ng, I get this error:

Code: Select all

2019-02-08 15:47:55: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'hunger_ng' in callback on_joinplayer(): .../games/bogart/mods/hunger_ng/system/hunger_functions.lua:26: bad argument #1 to 'get_player_by_name' (string expected, got nil)
2019-02-08 15:47:55: ERROR[Main]: stack traceback:
2019-02-08 15:47:55: ERROR[Main]: 	[C]: in function 'get_player_by_name'
2019-02-08 15:47:55: ERROR[Main]: 	.../games/bogart/mods/hunger_ng/system/hunger_functions.lua:26: in function 'get_data'
2019-02-08 15:47:55: ERROR[Main]: 	...games/bogart/mods/hunger_ng/interoperability/hudbars.lua:32: in function <...games/bogart/mods/hunger_ng/interoperability/hudbars.lua:30>
2019-02-08 15:47:55: ERROR[Main]: 	/opt/minetest/bin/../builtin/game/register.lua:419: in function </opt/minetest/bin/../builtin/game/register.lua:399>

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Fri Feb 08, 2019 14:59
by Linuxdirk
Thanks, I'll check this evening.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Fri Feb 08, 2019 15:47
by texmex
Have you ever thought of tracking basic nutrients individually? :)

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Fri Feb 08, 2019 21:58
by Linuxdirk
runs wrote:I use hbhunger with hudbar, and all OK. When I replace to hunger_ng, I get this error:
Found the issue (embarrassing typo) and fixed it. I also fixed the default hunger bar not being removed when enabling the hudbars mod. Just fetch the latest Git versions of everything.
texmex wrote:Have you ever thought of tracking basic nutrients individually? :)
Processing nutrients changes their nutritive value so I need to check that, too. Also I need to get all recipes to check what’s in them and need to check if the ingredients are made from basic nutrients, and so on … So for the sake of simplicity I rather not do this :)

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Sat Feb 09, 2019 00:44
by Linuxdirk
Attention modders!

The API changed a little. When getting the hunger information using hunger_ng.get_hunger_information you’ll get a slightly altered table back.

Also: all hunger data is now player meta data and no longer custom attributes because with Minetest 5.0.0 custom attributes are to be seen as deprecated!

In addition to that: Some of the (previous) custom attributes (now meta data) were renamed for better handling within the mod. You should not use them anyways :)

Just get the latest Git version and the Minetest 5.0.0 release candidate. An update via CDB will be available soon.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Sat Feb 09, 2019 20:24
by Lone_Wolf
This doesn't seem to be working with mobs_animal anymore. I got this mod and mobs_animal from the CDB. I use Minetest 5.0

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Sat Feb 09, 2019 20:58
by Linuxdirk
Sigh … those Lua patterns driving me insane one day … please get the last version and try. I’ll push a new release to the CDB soon.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Sat May 04, 2019 10:36
by sfan5
Right back where we were:
The 30 hud updates per second is too much, you should only call hud_change when the value actually changes.
(Here's how another mod solves this)

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Mon May 06, 2019 05:42
by Linuxdirk
sfan5 wrote:The 30 hud updates per second is too much, you should only call hud_change when the value actually changes.
The problem is that the value could change all the time with every update. So I either check for changes and always change the HUD depending on the breath status or I add another player value that I need to load and check (and set) all the time.

Just created an issue but how much of a difference does this really make? Is it actually noticeable under real-word circumstances?

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Mon May 06, 2019 13:33
by sfan5
The "old hud value" would not be stored in a player attribute since it's not persistent.
Comparing an entry in a table every globalstep shouldn't be a problem.

Regarding performance impact, when I tested this in singleplayer it caused 30 hud updates per second (standing still and hunger didn't change).
If you consider a server with 20 players, this would be 600 packets sent per second. Now, any (decent) server network won't have a problem with this (won't be noticeable), but it's still lots of network traffic wasted for nothing.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Fri Oct 18, 2019 13:23
by Linuxdirk
A quick test shows that the mod works properly and without any lag under 5.1.0 (and 5.0.1 of course). A properly flagged version in CDB will be released soon. No further changes were made so far. Reducing the sent network packages is on the long-term roadmap.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Tue Jan 07, 2020 19:16
by TDT2
rubenwardy wrote:Nice! It's good to see a maintained hunger mod which uses player attributes and not a table or inventory stack hacks

BTW: you can use register_on_item_eat to support any food. That's the reason that callback was added. Return true to cancel the default behaviour. You could also override minetest.do_item_eat if you don't want any conflict with callbacks (but you'd need to call callbacks yourself, if you wish)
uh.. hi. am kinda new to minetest forums, what prompted me to make an account was an issue, a question I need answered. can You tell me just WHERE do I put that "register_on_item_eat" thing? yea... am kinda of a noob with understanding registry stuff(especially the numbers, lol), anyways. . I've been trying to register some new eatable fish stuff for my fishing mod and I just have NO idea where to put that heading in.. if You can answer me that would be appreciated. thanks.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Tue Jan 07, 2020 20:00
by Linuxdirk
For using the mod you don’t need to put any code anywhere. Just install the through the content database in the client and enable the mod for the world(s) you want to use it in.

If you want to create your own mod that does something when a player eats something then the simplest thing is having this in you mod’s init.lua file.

The function is documented here.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Tue Jan 07, 2020 23:10
by TDT2
Linuxdirk wrote:For using the mod you don’t need to put any code anywhere. Just install the through the content database in the client and enable the mod for the world(s) you want to use it in.

If you want to create your own mod that does something when a player eats something then the simplest thing is having this in you mod’s init.lua file.

The function is documented here.
am amazed by how fast it took for someone to reply.... thanks for answering, and sorry I didn't answer back sooner, had things to do. but I still don't fully understand.. I don't even know where this content database is... and am not actually building any mods, I just simply make small edits/tweaks to already existing downloaded mods. I sort of learned how recipes work, and have done things with it, as well as making texture file edits, am No where near Your level of expertise,.I tried to copy and past the highlighted text that You provided in the link, and I tried to paste it somewhere at the end of the mods init file.... the darn thing wouldn't load after that and I had to go and delete everything.

do You think that maybe You could try being a bit more specific to where everything is located? like a folder for folder, file for file walkthrough? sorry if am asking for so much.... I know that a lot of mods are very different from each other, and maybe precise instructions might be impractical, but am gonna post a link to the mod that am trying to program with this so that maybe You could take a look at it?

ok... here goes https://github.com/MinetestForFun/fishing
that's what am working with. I hope that manages to help.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Wed Jan 08, 2020 07:26
by Linuxdirk
TDT2 wrote:I tried to copy and past the highlighted text that You provided in the link, and I tried to paste it somewhere at the end of the mods init file.... the darn thing wouldn't load after that and I had to go and delete everything.
That's not how it works. Also: You need to provide as a function what you actually want to do when someone eats something. This is all basic modding stuff and has nothing to do with Hunger NG. Please refer to the modding sub forum to ask your questions.

viewforum.php?f=47

Also have a look at the excellent modding book by rubenwardy.

https://rubenwardy.com/minetest_modding ... index.html

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Wed Jan 08, 2020 18:32
by TDT2
Linuxdirk wrote:
TDT2 wrote:I tried to copy and past the highlighted text that You provided in the link, and I tried to paste it somewhere at the end of the mods init file.... the darn thing wouldn't load after that and I had to go and delete everything.
That's not how it works. Also: You need to provide as a function what you actually want to do when someone eats something. This is all basic modding stuff and has nothing to do with Hunger NG. Please refer to the modding sub forum to ask your questions.

viewforum.php?f=47

Also have a look at the excellent modding book by rubenwardy.
https://rubenwardy.com/minetest_modding ... index.html
well thanks for referring me to that other forum post, and thanks for Your time in answering me. I just posted my question there. the book You suggested to me also didn't help.... it was uh.. complicated. but thanks for that also... it was worth at least investigating, I just wanted to know how to add the satiation thing to the fish, Not a bunch of hard to understand coding stuff on how to make a mod. lol, You are probably thinking just how that didn't clear anything up with what I wanted... but dunno. . . I guess that's the kind of Noob I really am.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Tue Feb 04, 2020 07:21
by RobertBuilder
Minor graphical bug with hudbars enabled: hunger_ng "overwrites" HUD element of other mods.
To reproduce:
Minetest 5.1.0 + hunger_ng, hudbars, areas, biome_lib, farming, intlib, mobs, mobs_animal, moretrees, plantlife

In the lower right hand corner the areas HUD will be overwritten with "farming_bread.png"

Suggested fix:
  • interoperability/hudbars.lua, line 53 replace

    Code: Select all

    minetest.after(delay, function () player:hud_remove(hud_id) end)
    
    with

    Code: Select all

    minetest.after(delay, function() 
    	f.set_data(player_name, a.hunger_bar_id, "")
    	player:hud_remove(hud_id)
    end)
    
  • system/hunger_functions.lua, line 29 replace

    Code: Select all

    if as_string then
        return tostring(player_meta:get(field) or 'invalid')
    else
        return tonumber(player_meta:get(field) or nil)
    end
    
    with

    Code: Select all

    if as_string then
        return (player_meta:get(field) and tostring(player_meta:get(field))) or 'invalid'
    else
        return (player_meta:get(field) and tonumber(player_meta:get(field))) or nil
    end
    
  • system/timers.lua line 111 replace

    Code: Select all

    if player:get_breath() < breath_max or is_yes(disabled) then
         player:hud_change(bar_id, 'text', '')
    else
         player:hud_change(bar_id, 'text', hunger_bar_image)
    end
    
    with

    Code: Select all

    if bar_id then
        if player:get_breath() < breath_max or is_yes(disabled) then
            player:hud_change(bar_id, 'text', '')
        else
            player:hud_change(bar_id, 'text', hunger_bar_image)
         end
    end
    

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Fri Feb 07, 2020 21:50
by Linuxdirk
RobertBuilder wrote:In the lower right hand corner the areas HUD will be overwritten with "farming_bread.png"
Please do a minimal test with hunger_ng and areas only. I was not able to reproduce it using the latest versions of hunger_ng and the areas mod on Minetest 5.1.1.

In other news: Hunger NG can now be configured on a per-world basis. All settings in minetest.conf are applied as usual, but when having settings in ./worlds/worldname/_hunger_ng/hunger_ng_settings.conf those settings take precedence over the globally set options. Also some minor bug fixes regarding cost and timer settings were made.

The configuration documentation was updated accordingly and the new version was published to the CDB and is available on GitLab as usual.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Tue Mar 03, 2020 19:46
by Clyde
Hello,

at my server, there happened something strange:

Code: Select all

2020-03-03 01:38:15: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod 'hunger_ng' in callback environment_Step(): ...inetest/games/Smalltech/mods/hunger_ng/system/timers.lua:68: attempt to compare nil with number
2020-03-03 01:38:15: ERROR[Main]: stack traceback:
2020-03-03 01:38:15: ERROR[Main]: 	...inetest/games/Smalltech/mods/hunger_ng/system/timers.lua:68: in function <...inetest/games/Smalltech/mods/hunger_ng/system/timers.lua:36>
2020-03-03 01:38:15: ERROR[Main]: 	/usr/local/share/minetest/builtin/game/register.lua:429: in function </usr/local/share/minetest/builtin/game/register.lua:413>
2020-03-03 01:38:15: ERROR[Main]: stack traceback:

This happens, when i logged out, after this the server crashes ...

Greetings, Clyde.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Wed Mar 04, 2020 05:10
by Linuxdirk
Strange, I cannot reproduce this issue but checking player for being a player seems better than checking player for not being nil. Just get the latest Git version where I merged your request to.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Wed Mar 04, 2020 16:06
by Clyde
This happened with the latest git-Version.

I have seen a similar behavior at the mod wielded_light and at the global step too.
Interesting to see is, it runs for a while, nothing happens, but when, then always and always only at the logout.

For me, the only explanation was, that the current player isn't valid anymore at this time. A change to the check, if the player is valid, has fixed the crash.

Strange because you iterate through the players, where i would think like you, i get only valid players, but it seems, the engine is here faster with the logout than the loop.

Greetings, Clyde.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Wed Mar 04, 2020 16:23
by Linuxdirk
Clyde wrote:Strange because you iterate through the players, where i would think like you, i get only valid players, but it seems, the engine is here faster with the logout than the loop.
Mmmh, maybe … but it all happens at the same tick I guess. And if the player logged out before then the player object is nil and if the player logged out afterwards then it does not matter because everything ran before.

I was not able top reproduce it and never noticed that before, but as said: get the latest Git version where I merged the request. Maybe this is more robust.

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Wed Mar 04, 2020 16:26
by sorcerykid
Clyde wrote:This happened with the latest git-Version.
The bug with get_connected_players() was introduced recently, but sfan5 pushed an emergency patch yesterday:

http://irc.minetest.net/minetest-dev/20 ... #i_5647380

Re: [Mod] Hunger NG: A next generation hunger mod (hunger_ng

Posted: Thu Mar 05, 2020 03:27
by Clyde
Thank you, this explains a lot.