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

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

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

by Linuxdirk » Fri Feb 08, 2019 07:23

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: 1140
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

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

by runs » Fri Feb 08, 2019 14:49

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>
 

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

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

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

by texmex » Fri Feb 08, 2019 15:47

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

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

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

by Linuxdirk » Fri Feb 08, 2019 21:58

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: 2348
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

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

by Linuxdirk » Sat Feb 09, 2019 00:44

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: 2276
Joined: Sun Apr 09, 2017 05:50
Location: Not there, THERE!
GitHub: LoneWolfHT
IRC: Lone_Wolf or LoneWolfHT
In-game: Lone_Wolf

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

by Lone_Wolf » Sat Feb 09, 2019 20:24

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
Content DB -|- Working on Voxel Knights
 

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

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

by Linuxdirk » Sat Feb 09, 2019 20:58

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: 3829
Joined: Wed Aug 24, 2011 09:44
Location: Germany
GitHub: sfan5
IRC: sfan5

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

by sfan5 » Sat May 04, 2019 10:36

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: 2348
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

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

by Linuxdirk » Mon May 06, 2019 05:42

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: 3829
Joined: Wed Aug 24, 2011 09:44
Location: Germany
GitHub: sfan5
IRC: sfan5

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

by sfan5 » Mon May 06, 2019 13:33

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: 2348
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

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

by Linuxdirk » Fri Oct 18, 2019 13:23

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 » Tue Jan 07, 2020 19:16

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: 2348
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

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

by Linuxdirk » Tue Jan 07, 2020 20:00

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 » Tue Jan 07, 2020 23:10

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: 2348
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

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

by Linuxdirk » Wed Jan 08, 2020 07:26

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.

https://forum.minetest.net/viewforum.php?f=47

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

https://rubenwardy.com/minetest_modding_book/en/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 » Wed Jan 08, 2020 18:32

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.

https://forum.minetest.net/viewforum.php?f=47

Also have a look at the excellent modding book by rubenwardy.
https://rubenwardy.com/minetest_modding_book/en/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 » Tue Feb 04, 2020 07:21

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: 2348
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

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

by Linuxdirk » Fri Feb 07, 2020 21:50

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.
 

Previous

Return to Mod Releases



Who is online

Users browsing this forum: davidthecreator and 15 guests