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

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

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

by Linuxdirk » Sat Feb 17, 2018 01:33

Abstract


Hunger NG is a mod for Minetest adding a very customizable and easy to extend hunger system.

The mod adds a hunger bar at the position of the breath bar and hides the bar if the breath bar becomes visible so the most important bar is shown without cluttering the UI too much.

Image

Hunger NG works in singleplayer mode as well as on a multiplayer server. It automatically disables itself when damage is disabled and adapts to the used texture pack.

Rationale


“Why yet another hunger mod? Is it a fork?” – No, Hunger NG was written from scratch in code and concept, is not a fork, and is completely self-contained.

The main difference from most (if not all) hunger mods is that hunger points get subtracted directly from the hunger value instead of being calculated to some sort of exhaustion value that’s being used to reduce the hunger. This gives more detailed control over how many hunger a specific action will cause.

Additionally all of the hunger-related information is stored as custom player attributes or custom item attributes. There are no global tables polluting the mod namespace or held in the mod’s local chunk. It’s all nice and clean stored in players and items.

Hunger NG allows detailed configuration of all aspects of the hunger manipulation. An exhaustive section on that is available in the mod’s README.md file (see GitLab link). There is a chat command that allows setting the hunger for any named player when having the server privilege.

Mod compatibility


By default the hunger bar is in the same position as the breath bar (the bubbles that appear when a player is awash) and disappears if the breath bar becomes visible. Any mod changing the position of the breath bar needs to change the position of the hunger bar as well (the ID is stored as custom player attribute, too).

Mods that alter or replace food with own versions ignoring custom item attributes will render them unusable for Hunger NG resulting in not being processed by Hunger NG but handled regularly.

Hunger NG is compatible with Wuzzy’s hudbars mod.
hbSprint by texmex has support for Hunger NG.


Obtaining the mod


GitLab: Browse the source, Download latest version, Content DB
Documentation click here for the online documentation
License: GPL Version 3 for source, various for sounds
Dependencies: default, farming, hudbars?, flowers?, mobs_animal?
Last edited by Linuxdirk on Sat Oct 20, 2018 03:35, edited 7 times in total.
 

Joseph13
Member
 
Posts: 190
Joined: Tue Dec 06, 2016 05:35
In-game: Joseph

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

by Joseph13 » Wed Feb 21, 2018 20:04

wow finally a new hunger mod!
I love Hobby Drones! They are awesome! Also I love FPV rc cars!!!
 

User avatar
Linuxdirk
Member
 
Posts: 1629
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 » Thu Feb 22, 2018 06:24

Joseph13 wrote:wow finally a new hunger mod!

And it also has a different concept than all of the other hunger mods :)

Plus: I'm currently redesigning the chat command and will do some balancing tests during the weekend.
 

User avatar
Stix
Member
 
Posts: 1249
Joined: Fri Aug 04, 2017 14:19
Location: USA
IRC: Stix + Stix_
In-game: Stix

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

by Stix » Thu Feb 22, 2018 16:23

i love how this doesn't take up more space over your hot-bar.
Playing at Elkien3 Factions.
Need to know something? "Google it" --GreenDimond
Next release of your favorite game? "Bugfixes" --Wuzzy
[OLD]The new Minetest-offtopic can be found here: https://minetestoftopic.createaforum.com/index.php
 

User avatar
rubenwardy
Moderator
 
Posts: 5503
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Thu Feb 22, 2018 17:16

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)
 

User avatar
Linuxdirk
Member
 
Posts: 1629
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 » Thu Feb 22, 2018 17:53

rubenwardy wrote:Nice! It's good to see a maintained hunger mod which uses player attributes and not a table or inventory stack hacks

Thanks :) That was the reason I created it.

rubenwardy wrote:BTW: you can use register_on_item_eat to support any food.

I already use this register like so. The only thing that is not done using a “generic” satiation value but specific ones (that will be tweaked over time) mod authors could add to their own foods either by depending on hunger_ng and using the global function after they registered their food or by manually adding the custom item attribute table as described for the function.
 

User avatar
rubenwardy
Moderator
 
Posts: 5503
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Thu Feb 22, 2018 18:02

Is there any reason why you didn't decide to guess the correct satiation value for unknown foods? It's better to have an inaccurate value than not support it at all, imo
 

Chem871
Member
 
Posts: 842
Joined: Sat Aug 19, 2017 21:49
Location: SCP-2935
GitHub: Chemguy99
In-game: Nyx Serris

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

by Chem871 » Thu Feb 22, 2018 19:26

I didn't know that some foods were sanitary, good to know.
What is SCP-055 again? I forgot.
 

User avatar
Linuxdirk
Member
 
Posts: 1629
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 23, 2018 06:12

rubenwardy wrote:Is there any reason why you didn't decide to guess the correct satiation value for unknown foods?

Due to concept. Foods need a custom attribute being a table containing the satiation/heal values. So I either need to weaken the concept or opt-depend on everything and iterate over all items trying to detect if they are food and add the custom attribute to them.

rubenwardy wrote:It's better to have an inaccurate value than not support it at all, imo

Unsupported foods work like the mod authors want them to work. So foods that are not supported by (Or do not support - both is possible, the later even without opt-depending!) Hunger NG are not affected at all.

If you think anything is missing (most recent version when posting this message) feel free to suggest adding it or contact the mod's author to add the necessary attribute (this is preferred, the interoperability section should be seen as temporary only).

Chem871 wrote:I didn't know that some foods were sanitary, good to know.

Some very substantial foods give you some health points, yes. Foods that should not be eaten raw (or are otherwise not the best you can eat) will damage you a little like raw chicken or the red mushroom.
Last edited by Linuxdirk on Tue Jun 05, 2018 17:54, edited 1 time in total.
 

User avatar
Linuxdirk
Member
 
Posts: 1629
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 24, 2018 14:18

Did some balancing.

  • Players can walk for a whole accumulated ingame day before their hunger is at 0
  • Placing nodes costs 1 hunger point for 100 nodes (0.01 per node)
  • Digging nodes costs 1 hunger point for 200 nodes (0.005 per node)
  • The basal metabolism takes roughly 10 ingame days to use up the maximum hunger value
  • Starvation results in 1 health point removed every 20 seconds
  • Healing adds 1 health point every 5 seconds
All the values are configurable of course.
 

User avatar
texmex
Member
 
Posts: 1013
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 » Sun Feb 25, 2018 21:40

Support for this mod added in hbSprint; it now drains satiation 1 unit ("half a bread") per second of sprinting by default.
 

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

User avatar
rubenwardy
Moderator
 
Posts: 5503
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Sun Feb 25, 2018 22:35

Linuxdirk wrote:opt-depend on everything and iterate over all items trying to detect if they are food and add the custom attribute to them.


You can use minetest.register_on_item_eat, as said. It's better to have a wrongly weighted food item than one that doesn't work consistently as a food
 

User avatar
Lone_Wolf
Member
 
Posts: 1943
Joined: Sun Apr 09, 2017 05:50
Location: Hopefully very far from yours, snoop :P
GitHub: LoneWolfHT
IRC: Lone_Wolf
In-game: Lone_Wolf
 

User avatar
texmex
Member
 
Posts: 1013
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 » Mon Feb 26, 2018 11:25

Linuxdirk wrote:hbSprint optionally support Hunger NG by setting the raw hunger value on sprinting.

I couldn't get hunger_ng.alter_hunger to work so I just went with your initial recommendation. :)
 

User avatar
Linuxdirk
Member
 
Posts: 1629
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 Feb 26, 2018 17:47

texmex wrote:I couldn't get hunger_ng.alter_hunger to work so I just went with your initial recommendation. :)

Why?

You basically just pass the player name (a string that is the name, not the object) and a number value (the hunger change either positive or negative float or int) to the function.

Are there error messages?
 

User avatar
texmex
Member
 
Posts: 1013
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 » Mon Feb 26, 2018 20:34

Linuxdirk wrote:Why?

You basically just pass the player name (a string that is the name, not the object) and a number value (the hunger change either positive or negative float or int) to the function.

Are there error messages?

I must admit I didn't look into it that deep, circumventing the problem was faster. >:)
 

User avatar
Linuxdirk
Member
 
Posts: 1629
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 Apr 04, 2018 17:21

texmex wrote:I must admit I didn't look into it that deep, circumventing the problem was faster. >:)

Actually I just made a copy&paste error and the bug is now fixed. The function now works as documented. (Adn there is a function to get the hunger now, too. In case you still need the value itself – same commit)


And completely unrelated: Item returns basing on additional definition are now fully supported.

https://gitlab.com/4w/hunger_ng/blob/ma ... unger-data
 

User avatar
Linuxdirk
Member
 
Posts: 1629
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 Oct 24, 2018 21:05

Hunger NG now has properly working chat commands.

When having the custom manage_hunger privilege set (or, of course, having the server privilege, as usual) players can view and change all hunger values including their own. This is useful if you want admins having this power for their administrative work but do not want to give them the server privilege.

Code: Select all
/hunger set Foobar 10
/hunger set 7.5
/hunger change -10
/hunger change Foobar 15
/hunger get
/hunger get Foobar

The first example sets the hunger value of player “Foobar” to 10 (5 breads). The second example sets the own hunger value to 7.5 (ceiled 8, so this looks like 4 breads). The third example reduces the own hunger value by 10, the fourth example raises Foobar’s hunger value by 15.

The second command is /myhunger without any parameters. This parameter simply returns the current hunger value to the player invoking this command. The interact privilege is needed for that. Since this is THE basic privilege, players actually playing on the server have it.

The execution of both commands is properly logged. Examples:

Code: Select all
2018-10-24 22:59:05: ACTION[Server]: [hunger_ng] Foobar sets own hunger to 20
2018-10-24 22:58:57: ACTION[Server]: [hunger_ng] Foobar gets own hunger value
2018-10-24 23:01:45: ACTION[Server]: [hunger_ng] Foobar changes hunger for Blergh by -5

1: /hunger set 20
2: /myhunger
3: /hunger set Blergh -5

Just get the latest version from GitLab and restart your server.
 

User avatar
LMD
Member
 
Posts: 676
Joined: Sat Apr 08, 2017 08:16
Location: Somewhere over the Rainbow : Bonn, Germany
GitHub: appgurueu
In-game: LMD + PRO_LMD + Limo

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

by LMD » Thu Nov 01, 2018 18:10

Actually, a great idea to always switch between breath and hunger.
I was inspired by this design concept so I made this :
Image

It works similar to yours but with a regen bar(which actually got nothing to do with eating).
Also, it uses (a modified version of) hudbars.
Attachments
hiding_regen.gif
(15.14 KiB) Not downloaded yet
Magic-CTF(soon)MTPCFractal-SuiteModel Creator Schematic CreatorColorfulXmas BallsWebsite • Never judge me by my age
 


Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 9 guests