Work-in-progress issue for storing ideas/concepts
Created by: 4w
Rationale
It seems like that all hunger mods pretty much base on the same mod/concept by BlockMen. The problem is that this code is two years old now and as of today it is pretty outdated. Still working, but it has issues and seems not to be updated anymore.
Hunger NG is in no way related to that mod but written from scratch using modern Minetest functionality and will be easily extendable.
Outline
The mod implements hunger to Minetest. Players start with full hunger. All actions they do costs hunger points. If all hunger points are used the player starves. Players can eat food to fill the hunger bar. If the hunger bar is at or above a configurable level players start to heal.
Technical information
Core functionality
-
Register custom eating function that cancels the default action and performs all the hunger-related stuff -
Store hunger as player attribute -
Don't delete on sign-off but check when signing in if hunger should be persistent and either reset or keep the value.
-
-
Add hunger bar at breath bubbles position and hide it when the bubbles are shown -
Implement a function to alter registered food to have the food carry meta information about how many points they add to health and hunger (this avoids a global table). -
Add this to most common foods from mods
-
-
Add a chat command and priv to set hunger directly -
Register globalstep timers -
"Basal metabolism" -
Digging/Placing -
Movement -
Healing player when within the limits -
Show/Hide hunger bar depending on breath -
Starvation when below a certain limit
-
-
Write user documentation -
Create a forum post, see here
Concepts
Additional table in foods
-- If not present just pass the food to the core function
_hunger_ng = {
heals = 5, -- Negative values damage the player
satiates = 4 -- Negative values make the player lose hunger points
}
Chat command
Set hunger if the player has server
permission (i.e. is admin).
/sethunger playername <value>
This does not add or substract, it simply sets and should only be used for debugging purposes (hence limited by permissions).
Hide hunger bar when underwater
get_breath()
gets the breath state (0-10 = losing breath points, 11 = not losing breath points), see here.
if player:get_breath() < 11 then
-- Hide hunger bar
else
-- Show hunger bar
end
Hiding and showing the hunger bar could be done by setting it's size to zero (hunger bar still fully functional but not visible), this avoids checking if the bar is shown or not.