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

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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!

User avatar
runs
Member
Posts: 1744
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

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

by runs » Post

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>
Day 42 of the quarantine

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

Thanks, I'll check this evening.

User avatar
texmex
Member
Posts: 1752
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

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

by texmex » Post

Have you ever thought of tracking basic nutrients individually? :)
Mods | Support Mesehub: bc1qluuests9rxmlnvpjrhsnyjg9ucwy6z3r0y3srw

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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 :)

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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.

User avatar
Lone_Wolf
Member
Posts: 2355
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: Lone_Wolf or LoneWolfHT
In-game: Lone_Wolf
Location: Not there, THERE!

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

by Lone_Wolf » Post

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

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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.

User avatar
sfan5
Moderator
Posts: 3926
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

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

by sfan5 » Post

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)
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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?

User avatar
sfan5
Moderator
Posts: 3926
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

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

by sfan5 » Post

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.
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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.

TDT2
Member
Posts: 11
Joined: Tue Jan 07, 2020 18:57
GitHub: TDT2
IRC: TDT2
In-game: TDT2

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

by TDT2 » Post

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.

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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.

TDT2
Member
Posts: 11
Joined: Tue Jan 07, 2020 18:57
GitHub: TDT2
IRC: TDT2
In-game: TDT2

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

by TDT2 » Post

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.

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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

TDT2
Member
Posts: 11
Joined: Tue Jan 07, 2020 18:57
GitHub: TDT2
IRC: TDT2
In-game: TDT2

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

by TDT2 » Post

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.

RobertBuilder
New member
Posts: 4
Joined: Mon Feb 03, 2020 23:42

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

by RobertBuilder » Post

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
    

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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.

User avatar
Clyde
Member
Posts: 148
Joined: Sat Jul 30, 2016 14:23
GitHub: acmgit
In-game: clyde

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

by Clyde » Post

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.

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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.

User avatar
Clyde
Member
Posts: 148
Joined: Sat Jul 30, 2016 14:23
GitHub: acmgit
In-game: clyde

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

by Clyde » Post

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.

User avatar
Linuxdirk
Member
Posts: 2555
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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.

User avatar
sorcerykid
Member
Posts: 1344
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

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

by sorcerykid » Post

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

User avatar
Clyde
Member
Posts: 148
Joined: Sat Jul 30, 2016 14:23
GitHub: acmgit
In-game: clyde

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

by Clyde » Post

Thank you, this explains a lot.

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests