summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.txt61
-rw-r--r--armor.lua34
-rw-r--r--changelog.txt89
-rw-r--r--depends.txt3
-rw-r--r--hud.conf.example33
-rw-r--r--hunger.lua46
-rw-r--r--init.lua328
-rw-r--r--textures/crosshair.pngbin216 -> 0 bytes
-rw-r--r--textures/hbhunger_bar.pngbin0 -> 80 bytes
-rw-r--r--textures/hbhunger_icon.png (renamed from textures/hud_hunger_fg.png)bin522 -> 522 bytes
-rw-r--r--textures/hud_air_fg.pngbin579 -> 0 bytes
-rw-r--r--textures/hud_armor_bg.pngbin424 -> 0 bytes
-rw-r--r--textures/hud_armor_fg.pngbin3167 -> 0 bytes
-rw-r--r--textures/hud_heart_bg.pngbin302 -> 0 bytes
-rw-r--r--textures/hud_heart_fg.pngbin369 -> 0 bytes
-rw-r--r--textures/hud_hotbar.pngbin1142 -> 0 bytes
-rw-r--r--textures/hud_hotbar_selected.pngbin9049 -> 0 bytes
-rw-r--r--textures/hud_hunger_bg.pngbin417 -> 0 bytes
-rw-r--r--textures/wieldhand.pngbin153 -> 0 bytes
19 files changed, 118 insertions, 476 deletions
diff --git a/README.txt b/README.txt
index d2899c5..3f5ac6d 100644
--- a/README.txt
+++ b/README.txt
@@ -1,37 +1,32 @@
-Minetest mod "Better HUD"
-=========================
-Version: 1.4.1
+Minetest mod: Hunger [hbhunger]
+===============================
+Version: 0.1.0
License of source code: WTFPL
-----------------------------
-(c) Copyright BlockMen (2013-2015)
+by Wuzzy (2015)
+Forked from the “Better HUD (and hunger)” mod by BlockMen (2013-2014).
Using the mod:
--------------
-This mod changes the HUD of Minetest.
-It improves the apperance of the health and breath bar and adds a more fancy hotbar. Furthermore it adds a
-custom crosshair, an armor bar (only for 3darmor mod) and a hunger bar. It includes also a mechanic for hunger.
-
-You can create a "hud.conf" file to customize the positions of health, hunger, armor and breath bar. Take a look at "hud.conf.example" to get more infos.
-
-
-!!IMPORTANT !!:
-Keep in mind if running a server with this mod, that the custom position should be displayed correct on every screen size!!
+This mod adds a mechanic for hunger.
+This mod depends on the HUD bars mod [hudbars], major version 1.
+You can create a "hunger.conf" file to customize the properties of hunger for your needs.
-=Hunger=
-========
-This mod adds a hunger mechanic to the game. Player actions like digging, placing and walking causes exhausion,
-that lowers players saturation. Also every 800 seconds you lose 1 saturation point without doing anything.
-If you are hungry (empty hunger bar) you will get damage and die in case you don't eat something.
-
-
-Notice:
--------
-You can disable this by setting "HUD_HUNGER_ENABLE = false" in "hud.conf", or "hud_hunger_enable = false" in minetest.conf.
-In case of conflict hud.conf configuration is dominant.
+About hunger
+============
+This mod adds a hunger mechanic to the game.
+A new player starts with 20 saturation points out of 30.
+Player actions like digging, placing and walking cause exhausion, which lower the player's
+saturation. Also every 800 seconds you lose 1 saturation point without doing anything.
+If you are hungry (0 saturation) you will suffer damage and die in case you don't eat something.
+If your saturation is greater than 15, you will slowly regenerate health points.
+Eating food will increase your saturation.
+Important: Eating food will not directly increase your health anymore, as long as the food item
+is supported by this mod (see below).
Currently supported food:
@@ -60,23 +55,15 @@ Currently supported food:
- Seaplants (sea)
- Simple mobs
-Example: 1 apple fills up the hunger bar by 1 bread, 1 bread (from farming) 2 breads in bar.
-
-Although it show 20 hunger points (10 breads) in hunger bar,
-you can fill it up to 30 points.(5 breads not shown then)
-
+Examples:
+Eating an apple (from the default Minetest game) increases your saturation by 2,
+eating a bread (from the default Minetest game) increases your saturation by 4.
License of textures:
--------------------
-hud_heart_fg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
-hud_heart_bg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
-hud_hunger_fg.png - PilzAdam (WTFPL), modified by BlockMen
-hud_hunger_bg.png - PilzAdam (WTFPL), modified by BlockMen
-wieldhand.png (from character.png) - Jordach (CC BY-SA 3.0), modified by BlockMen
-hud_air_fg.png - kaeza (WTFPL), modified by BlockMen
-hud_armor_fg.png - Stu (CC BY-SA 3.0), modified by BlockMen
-hud_armor_bg.png - Stu (CC BY-SA 3.0), modified by BlockMen
+hunger_icon.png - PilzAdam (WTFPL), modified by BlockMen
+hunger_bar.png - Wuzzy (WTFPL)
everything else is WTFPL:
(c) Copyright BlockMen (2013-2015)
diff --git a/armor.lua b/armor.lua
deleted file mode 100644
index 7f0d0cf..0000000
--- a/armor.lua
+++ /dev/null
@@ -1,34 +0,0 @@
-minetest.after(0, function()
- if not armor.def then
- minetest.after(2,minetest.chat_send_all,"#Better HUD: Please update your version of 3darmor")
- HUD_SHOW_ARMOR = false
- end
-end)
-
-function hud.get_armor(player)
- if not player or not armor.def then
- return
- end
- local name = player:get_player_name()
- local def = armor.def[name] or nil
- if def and def.state and def.count then
- hud.set_armor(name, def.state, def.count)
- end
-end
-
-function hud.set_armor(player_name, ges_state, items)
- local max_items = 4
- if items == 5 then
- max_items = items
- end
- local max = max_items * 65535
- local lvl = max - ges_state
- lvl = lvl/max
- if ges_state == 0 and items == 0 then
- lvl = 0
- end
-
- hud.armor[player_name] = lvl* (items * (20 / max_items))
-
-
-end \ No newline at end of file
diff --git a/changelog.txt b/changelog.txt
index 4eac6c5..e812a43 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,88 +1,3 @@
-0.2 Beta
---------
-- added support of custom config files
-- you can eat max. 50% more than before (although it isnt shown in hunger bar)
-- you get healed with 8 breads and more (in hunger bar) now
-- a bread (from farming) == 2 breads in hunger bar
-
-0.2.1 Beta
-----------
-- tweaked override of food
-- added support for food of dwares, moretrees and simple mobs
-
-0.2.2 Beta
-----------
-- added support for food of animalmaterials (mobf modpack),fishing
-
-0.2.3 Beta
-----------
-- added support for food of glooptest and bushes (commit by CheeseKeg)
-
-0.3 Beta
-----------
-- added fancy borders of hud inventory bar (only for screenheight <= 800)
-
-0.4 Beta
-----------
-- enabled drowning
-
-0.5 Beta
-----------
-- removed the fancy borders of hud inventory bar and moved to new native support
-- moved crosshair to native support too
-
-1.0
----
-- hunger is reset after death
-- health and hunger bar is shown correct on all screen resolutions now
-- switched to changed native hotbar image support
-- fixed revival of player when drown
-- hunger bar is not shown anymore if hunger is disabled
-- hunger can be disabled by minetest.conf ("hud_hunger_enable = false")
-
-1.1
----
-- added support for stu's 3darmor mod
-- restructured and cleaned up code
-- added support for poisen food (damages player, but does not kill)
-
-1.2
----
-- Send statbar values only to client when changed
-- Hide armor bar if not wearing armor
-- More reliable food overrides (by CiaranG)
-- Support for bushes_classic foods (plantlife modpack) (by CiaranG)
-- Add support for mushroom mod food/poison (by CiaranG)
-- Add support for mods: fruit and mush45
-- New images for hotbar, smaller armor icons
-
-1.3
----
-- New way hunger is saved (all old files in world dirctory can get deleted [e.g. hud_BlockMen_hunger])
-- Fixed healing (not while drowning, fix after death)
-- Add support for mods: seaplants[sea] and mobfcooking (by Xanthin)
-- Tweaked hand image
-- Player can die caus of starving now
-
-1.3.1
+0.1.0
-----
-- Add compatibility for statbar scaling
-- Fix typo in depends.txt
-- Lower maintimer tick
-
-1.3.2
------
-- Fix dependecies (by Chris Beelby)
-- Add support for creatures mod
-- Add optional healing for food (by TenPlus1)
-
-1.3.3
------
-- Prevent crash with armor mod and missing player
-- Add support for ethereal mod (by TenPlus1)
-
-1.4
----
-- New hunger mechanics/added experimental player-action based hunger
-- Better crosshair texture, switched to "new" default hand
-- Added support for farming redo mod, kpgmobs and jkmod
+Initial release
diff --git a/depends.txt b/depends.txt
index 2f91ba6..d46748a 100644
--- a/depends.txt
+++ b/depends.txt
@@ -1,4 +1,5 @@
-default
+hudbars
+default?
animalmaterials?
bucket?
bushes?
diff --git a/hud.conf.example b/hud.conf.example
deleted file mode 100644
index ffa4cd7..0000000
--- a/hud.conf.example
+++ /dev/null
@@ -1,33 +0,0 @@
---##Better HUD example config file##
-------------------------------------
--- This example moves the health bar in the top left corner and the hunger bar in the top right corner
-
-
---
--- general settings
---
-HUD_ENABLE_HUNGER = true --enables/disables hunger
-HUD_HUNGER_TICK = 300 --sets time for loosing 1/2 bread (of 10) (in seconds)
-
-
---!NOTICE!--
--- >>if damage is disabled neither health bar nor hunger bar or breath bar is shown
-
---
--- health bar
---
-HUD_HEALTH_POS = {x=0,y=0} --min 0, max 1
-HUD_HEALTH_OFFSET = {x=5,y=30} --offset in pixel
-
---
--- hunger bar
---
-HUD_HUNGER_POS = {x=1,y=0} --min 0, max 1
-HUD_HUNGER_OFFSET = {x=-175,y=30} --offset in pixel
-
---
--- breath bar
---
-HUD_AIR_POS = {x=0.5,y=1} --min 0, max 1
-HUD_AIR_OFFSET = {x=15,y=-75} --offset in pixel
-
diff --git a/hunger.lua b/hunger.lua
index c9a53ae..5a6be5f 100644
--- a/hunger.lua
+++ b/hunger.lua
@@ -1,9 +1,9 @@
-- Keep these for backwards compatibility
-function hud.save_hunger(player)
- hud.set_hunger(player)
+function hunger.save_hunger(player)
+ hunger.set_hunger(player)
end
-function hud.load_hunger(player)
- hud.get_hunger(player)
+function hunger.load_hunger(player)
+ hunger.get_hunger(player)
end
-- Poison player
@@ -20,19 +20,19 @@ local function poisenp(tick, time, time_left, player)
end
-function hud.item_eat(hunger_change, replace_with_item, poisen, heal)
+function hunger.item_eat(hunger_change, replace_with_item, poisen, heal)
return function(itemstack, user, pointed_thing)
if itemstack:take_item() ~= nil and user ~= nil then
local name = user:get_player_name()
- local h = tonumber(hud.hunger[name])
+ local h = tonumber(hunger.hunger[name])
local hp = user:get_hp()
-- Saturation
if h < 30 and hunger_change then
h = h + hunger_change
if h > 30 then h = 30 end
- hud.hunger[name] = h
- hud.set_hunger(user)
+ hunger.hunger[name] = h
+ hunger.set_hunger(user)
end
-- Healing
if hp < 20 and heal then
@@ -56,11 +56,13 @@ end
local function overwrite(name, hunger_change, replace_with_item, poisen, heal)
local tab = minetest.registered_items[name]
if tab == nil then return end
- tab.on_use = hud.item_eat(hunger_change, replace_with_item, poisen, heal)
+ tab.on_use = hunger.item_eat(hunger_change, replace_with_item, poisen, heal)
minetest.registered_items[name] = tab
end
-overwrite("default:apple", 2)
+if minetest.get_modpath("default") ~= nil then
+ overwrite("default:apple", 2)
+end
if minetest.get_modpath("farming") ~= nil then
overwrite("farming:bread", 4)
end
@@ -361,32 +363,32 @@ if minetest.get_modpath("ferns") ~= nil then
end
-- player-action based hunger changes
-function hud.handle_node_actions(pos, oldnode, player, ext)
+function hunger.handle_node_actions(pos, oldnode, player, ext)
if not player or not player:is_player() then
return
end
local name = player:get_player_name()
- local exhaus = hud.exhaustion[name]
- local new = HUD_HUNGER_EXHAUST_PLACE
+ local exhaus = hunger.exhaustion[name]
+ local new = HUNGER_EXHAUST_PLACE
-- placenode event
if not ext then
- new = HUD_HUNGER_EXHAUST_DIG
+ new = HUNGER_EXHAUST_DIG
end
-- assume its send by main timer when movement detected
if not pos and not oldnode then
- new = HUD_HUNGER_EXHAUST_MOVE
+ new = HUNGER_EXHAUST_MOVE
end
exhaus = exhaus + new
- if exhaus > HUD_HUNGER_EXHAUST_LVL then
+ if exhaus > HUNGER_EXHAUST_LVL then
exhaus = 0
- local h = tonumber(hud.hunger[name])
+ local h = tonumber(hunger.hunger[name])
h = h - 1
if h < 0 then h = 0 end
- hud.hunger[name] = h
- hud.set_hunger(player)
+ hunger.hunger[name] = h
+ hunger.set_hunger(player)
end
- hud.exhaustion[name] = exhaus
+ hunger.exhaustion[name] = exhaus
end
-minetest.register_on_placenode(hud.handle_node_actions)
-minetest.register_on_dignode(hud.handle_node_actions)
+minetest.register_on_placenode(hunger.handle_node_actions)
+minetest.register_on_dignode(hunger.handle_node_actions)
diff --git a/init.lua b/init.lua
index 1dc9809..386c022 100644
--- a/init.lua
+++ b/init.lua
@@ -1,229 +1,55 @@
-hud = {}
+if minetest.setting_getbool("enable_damage") then
+
+hunger = {}
-- HUD statbar values
-hud.health = {}
-hud.hunger = {}
-hud.air = {}
-hud.armor = {}
-hud.hunger_out = {}
-hud.armor_out = {}
+hunger.hunger = {}
+hunger.hunger_out = {}
-- HUD item ids
-local health_hud = {}
local hunger_hud = {}
-local air_hud = {}
-local armor_hud = {}
-local armor_hud_bg = {}
-
--- default settings
-
-HUD_SCALEABLE = false
-HUD_SIZE = ""
- -- statbar positions
-HUD_HEALTH_POS = {x=0.5,y=0.9}
-HUD_HEALTH_OFFSET = {x=-175, y=2}
-HUD_HUNGER_POS = {x=0.5,y=0.9}
-HUD_HUNGER_OFFSET = {x=15, y=2}
-HUD_AIR_POS = {x=0.5,y=0.9}
-HUD_AIR_OFFSET = {x=15,y=-15}
-HUD_ARMOR_POS = {x=0.5,y=0.9}
-HUD_ARMOR_OFFSET = {x=-175, y=-15}
-
--- dirty way to check for new statbars
-if dump(minetest.hud_replace_builtin) ~= "nil" then
- HUD_SCALEABLE = true
- HUD_SIZE = {x=24, y=24}
- HUD_HEALTH_POS = {x=0.5,y=1}
- HUD_HEALTH_OFFSET = {x=-262, y=-87}
- HUD_HUNGER_POS = {x=0.5,y=1}
- HUD_HUNGER_OFFSET = {x=15, y=-87}
- HUD_AIR_POS = {x=0.5,y=1}
- HUD_AIR_OFFSET = {x=15,y=-110}
- HUD_ARMOR_POS = {x=0.5,y=1}
- HUD_ARMOR_OFFSET = {x=-262, y=-110}
-end
-
-HUD_TICK = 0.1
+HUNGER_HUD_TICK = 0.1
--Some hunger settings
-hud.exhaustion = {} -- Exhaustion is experimental!
-
-HUD_HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
-HUD_HUNGER_EXHAUST_DIG = 3 -- exhaustion increased this value after digged node
-HUD_HUNGER_EXHAUST_PLACE = 1 -- exhaustion increased this value after placed
-HUD_HUNGER_EXHAUST_MOVE = 0.3 -- exhaustion increased this value if player movement detected
-HUD_HUNGER_EXHAUST_LVL = 160 -- at what exhaustion player saturation gets lowerd
-
-
+hunger.exhaustion = {} -- Exhaustion is experimental!
-HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
-if HUD_ENABLE_HUNGER == nil then
- HUD_ENABLE_HUNGER = minetest.setting_getbool("enable_damage")
-end
+HUNGER_HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
+HUNGER_EXHAUST_DIG = 3 -- exhaustion increased this value after digged node
+HUNGER_EXHAUST_PLACE = 1 -- exhaustion increased this value after placed
+HUNGER_EXHAUST_MOVE = 0.3 -- exhaustion increased this value if player movement detected
+HUNGER_EXHAUST_LVL = 160 -- at what exhaustion player saturation gets lowerd
-HUD_SHOW_ARMOR = false
-if minetest.get_modpath("3d_armor") ~= nil then
- HUD_SHOW_ARMOR = true
-end
--load custom settings
-local set = io.open(minetest.get_modpath("hud").."/hud.conf", "r")
+local set = io.open(minetest.get_modpath("hbhunger").."/hbhunger.conf", "r")
if set then
- dofile(minetest.get_modpath("hud").."/hud.conf")
+ dofile(minetest.get_modpath("hbhunger").."/hbhunger.conf")
set:close()
-else
- if not HUD_ENABLE_HUNGER then
- HUD_AIR_OFFSET = HUD_HUNGER_OFFSET
- end
-end
-
-local function hide_builtin(player)
- player:hud_set_flags({crosshair = true, hotbar = true, healthbar = false, wielditem = true, breathbar = false})
end
-
local function custom_hud(player)
- local name = player:get_player_name()
-
--- fancy hotbar (only when no crafting mod present)
- if minetest.get_modpath("crafting") == nil then
- player:hud_set_hotbar_image("hud_hotbar.png")
- player:hud_set_hotbar_selected_image("hud_hotbar_selected.png")
- end
-
- if minetest.setting_getbool("enable_damage") then
- --hunger
- if HUD_ENABLE_HUNGER then
- player:hud_add({
- hud_elem_type = "statbar",
- position = HUD_HUNGER_POS,
- size = HUD_SIZE,
- text = "hud_hunger_bg.png",
- number = 20,
- alignment = {x=-1,y=-1},
- offset = HUD_HUNGER_OFFSET,
- })
- local h = hud.hunger[name]
- if h == nil or h > 20 then h = 20 end
- hunger_hud[name] = player:hud_add({
- hud_elem_type = "statbar",
- position = HUD_HUNGER_POS,
- size = HUD_SIZE,
- text = "hud_hunger_fg.png",
- number = h,
- alignment = {x=-1,y=-1},
- offset = HUD_HUNGER_OFFSET,
- })
- end
- --health
- player:hud_add({
- hud_elem_type = "statbar",
- position = HUD_HEALTH_POS,
- size = HUD_SIZE,
- text = "hud_heart_bg.png",
- number = 20,
- alignment = {x=-1,y=-1},
- offset = HUD_HEALTH_OFFSET,
- })
- health_hud[name] = player:hud_add({
- hud_elem_type = "statbar",
- position = HUD_HEALTH_POS,
- size = HUD_SIZE,
- text = "hud_heart_fg.png",
- number = player:get_hp(),
- alignment = {x=-1,y=-1},
- offset = HUD_HEALTH_OFFSET,
- })
-
- --air
- air_hud[name] = player:hud_add({
- hud_elem_type = "statbar",
- position = HUD_AIR_POS,
- size = HUD_SIZE,
- text = "hud_air_fg.png",
- number = 0,
- alignment = {x=-1,y=-1},
- offset = HUD_AIR_OFFSET,
- })
-
- --armor
- if HUD_SHOW_ARMOR then
- armor_hud_bg[name] = player:hud_add({
- hud_elem_type = "statbar",
- position = HUD_ARMOR_POS,
- size = HUD_SIZE,
- text = "hud_armor_bg.png",
- number = 0,
- alignment = {x=-1,y=-1},
- offset = HUD_ARMOR_OFFSET,
- })
- armor_hud[name] = player:hud_add({
- hud_elem_type = "statbar",
- position = HUD_ARMOR_POS,
- size = HUD_SIZE,
- text = "hud_armor_fg.png",
- number = 0,
- alignment = {x=-1,y=-1},
- offset = HUD_ARMOR_OFFSET,
- })
- end
- end
-end
-
---needs to be defined for older version of 3darmor
-function hud.set_armor()
+ hb.init_hudbar(player, "saturation", hunger.get_hunger(player))
end
+dofile(minetest.get_modpath("hbhunger").."/hunger.lua")
-if HUD_ENABLE_HUNGER then dofile(minetest.get_modpath("hud").."/hunger.lua") end
-if HUD_SHOW_ARMOR then dofile(minetest.get_modpath("hud").."/armor.lua") end
+-- register saturation hudbar
+hb.register_hudbar("saturation", 0xFFFFFF, "Saturation", { icon = "hbhunger_icon.png", bar = "hbhunger_bar.png" }, 20, 30, false)
-- update hud elemtens if value has changed
local function update_hud(player)
local name = player:get_player_name()
- --air
- local air = tonumber(hud.air[name])
- if player:get_breath() ~= air then
- air = player:get_breath()
- hud.air[name] = air
- if air > 10 then air = 0 end
- player:hud_change(air_hud[name], "number", air*2)
- end
- --health
- local hp = tonumber(hud.health[name])
- if player:get_hp() ~= hp then
- hp = player:get_hp()
- hud.health[name] = hp
- player:hud_change(health_hud[name], "number", hp)
- end
- --armor
- local arm_out = tonumber(hud.armor_out[name])
- if not arm_out then arm_out = 0 end
- local arm = tonumber(hud.armor[name])
- if not arm then arm = 0 end
- if arm_out ~= arm then
- hud.armor_out[name] = arm
- player:hud_change(armor_hud[name], "number", arm)
- -- hide armor bar completely when there is none
- if (not armor.def[name].count or armor.def[name].count == 0) and arm == 0 then
- player:hud_change(armor_hud_bg[name], "number", 0)
- else
- player:hud_change(armor_hud_bg[name], "number", 20)
- end
- end
--hunger
- local h_out = tonumber(hud.hunger_out[name])
- local h = tonumber(hud.hunger[name])
+ local h_out = tonumber(hunger.hunger_out[name])
+ local h = tonumber(hunger.hunger[name])
if h_out ~= h then
- hud.hunger_out[name] = h
- -- bar should not have more than 10 icons
- if h>20 then h=20 end
- player:hud_change(hunger_hud[name], "number", h)
+ hunger.hunger_out[name] = h
+ hb.change_hudbar(player, "saturation", h)
end
end
-hud.get_hunger = function(player)
+hunger.get_hunger = function(player)
local inv = player:get_inventory()
if not inv then return nil end
local hgp = inv:get_stack("hunger", 1):get_count()
@@ -236,10 +62,10 @@ hud.get_hunger = function(player)
return hgp-1
end
-hud.set_hunger = function(player)
+hunger.set_hunger = function(player)
local inv = player:get_inventory()
local name = player:get_player_name()
- local value = hud.hunger[name]
+ local value = hunger.hunger[name]
if not inv or not value then return nil end
if value > 30 then value = 30 end
if value < 0 then value = 0 end
@@ -253,87 +79,65 @@ minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
local inv = player:get_inventory()
inv:set_size("hunger",1)
- hud.health[name] = player:get_hp()
- if HUD_ENABLE_HUNGER then
- hud.hunger[name] = hud.get_hunger(player)
- hud.hunger_out[name] = hud.hunger[name]
- hud.exhaustion[name] = 0
- end
- hud.armor[name] = 0
- hud.armor_out[name] = 0
- local air = player:get_breath()
- hud.air[name] = air
- minetest.after(0.5, function()
- hide_builtin(player)
- custom_hud(player)
- if HUD_ENABLE_HUNGER then hud.set_hunger(player) end
- end)
+ hunger.hunger[name] = hunger.get_hunger(player)
+ hunger.hunger_out[name] = hunger.hunger[name]
+ hunger.exhaustion[name] = 0
+ custom_hud(player)
+ hunger.set_hunger(player)
end)
minetest.register_on_respawnplayer(function(player)
- -- reset player breath since the engine doesnt
- player:set_breath(11)
-- reset hunger (and save)
local name = player:get_player_name()
- hud.hunger[name] = 20
- if HUD_ENABLE_HUNGER then
- minetest.after(0.5, hud.set_hunger, player)
- hud.exhaustion[name] = 0
- end
+ hunger.hunger[name] = 20
+ hunger.set_hunger(player)
+ hunger.exhaustion[name] = 0
end)
local main_timer = 0
local timer = 0
local timer2 = 0
-minetest.after(2.5, function()
- minetest.register_globalstep(function(dtime)
- main_timer = main_timer + dtime
- timer = timer + dtime
- timer2 = timer2 + dtime
- if main_timer > HUD_TICK or timer > 4 or timer2 > HUD_HUNGER_TICK then
- if main_timer > HUD_TICK then main_timer = 0 end
- for _,player in ipairs(minetest.get_connected_players()) do
- local name = player:get_player_name()
-
- -- only proceed if damage is enabled
- if minetest.setting_getbool("enable_damage") then
- local h = tonumber(hud.hunger[name])
- local hp = player:get_hp()
- if HUD_ENABLE_HUNGER and timer > 4 then
- -- heal player by 1 hp if not dead and saturation is > 15 (of 30)
- if h > 15 and hp > 0 and hud.air[name] > 0 then
- player:set_hp(hp+1)
+minetest.register_globalstep(function(dtime)
+ main_timer = main_timer + dtime
+ timer = timer + dtime
+ timer2 = timer2 + dtime
+ if main_timer > HUNGER_HUD_TICK or timer > 4 or timer2 > HUNGER_HUNGER_TICK then
+ if main_timer > HUNGER_HUD_TICK then main_timer = 0 end
+ for _,player in ipairs(minetest.get_connected_players()) do
+ local name = player:get_player_name()
+
+ local h = tonumber(hunger.hunger[name])
+ local hp = player:get_hp()
+ if timer > 4 then
+ -- heal player by 1 hp if not dead and saturation is > 15 (of 30)
+ if h > 15 and hp > 0 and player:get_breath() > 0 then
+ player:set_hp(hp+1)
-- or damage player by 1 hp if saturation is < 2 (of 30)
- elseif h <= 1 and minetest.setting_getbool("enable_damage") then
+ elseif h <= 1 then
if hp-1 >= 0 then player:set_hp(hp-1) end
end
- end
- -- lower saturation by 1 point after xx seconds
- if HUD_ENABLE_HUNGER and timer2 > HUD_HUNGER_TICK then
+ end
+ -- lower saturation by 1 point after xx seconds
+ if timer2 > HUNGER_HUNGER_TICK then
if h > 0 then
h = h-1
- hud.hunger[name] = h
- hud.set_hunger(player)
+ hunger.hunger[name] = h
+ hunger.set_hunger(player)
end
- end
- -- update current armor level
- if HUD_SHOW_ARMOR then hud.get_armor(player) end
+ end
- -- update all hud elements
- update_hud(player)
+ -- update all hud elements
+ update_hud(player)
- if HUD_ENABLE_HUNGER then
- local controls = player:get_player_control()
- -- Determine if the player is walking
- if controls.up or controls.down or controls.left or controls.right then
- hud.handle_node_actions(nil, nil, player)
- end
- end
+ local controls = player:get_player_control()
+ -- Determine if the player is walking
+ if controls.up or controls.down or controls.left or controls.right then
+ hunger.handle_node_actions(nil, nil, player)
end
- end
-
end
- if timer > 4 then timer = 0 end
- if timer2 > HUD_HUNGER_TICK then timer2 = 0 end
- end)
+ end
+ if timer > 4 then timer = 0 end
+ if timer2 > HUNGER_HUNGER_TICK then timer2 = 0 end
end)
+
+end
diff --git a/textures/crosshair.png b/textures/crosshair.png
deleted file mode 100644
index a832298..0000000
--- a/textures/crosshair.png
+++ /dev/null
Binary files differ
diff --git a/textures/hbhunger_bar.png b/textures/hbhunger_bar.png
new file mode 100644
index 0000000..c94bf52
--- /dev/null
+++ b/textures/hbhunger_bar.png
Binary files differ
diff --git a/textures/hud_hunger_fg.png b/textures/hbhunger_icon.png
index a5cc2a1..a5cc2a1 100644
--- a/textures/hud_hunger_fg.png
+++ b/textures/hbhunger_icon.png
Binary files differ
diff --git a/textures/hud_air_fg.png b/textures/hud_air_fg.png
deleted file mode 100644
index b62c9b0..0000000
--- a/textures/hud_air_fg.png
+++ /dev/null
Binary files differ
diff --git a/textures/hud_armor_bg.png b/textures/hud_armor_bg.png
deleted file mode 100644
index 3240100..0000000
--- a/textures/hud_armor_bg.png
+++ /dev/null
Binary files differ
diff --git a/textures/hud_armor_fg.png b/textures/hud_armor_fg.png
deleted file mode 100644
index 374f1a9..0000000
--- a/textures/hud_armor_fg.png
+++ /dev/null
Binary files differ
diff --git a/textures/hud_heart_bg.png b/textures/hud_heart_bg.png
deleted file mode 100644
index e2be276..0000000
--- a/textures/hud_heart_bg.png
+++ /dev/null
Binary files differ
diff --git a/textures/hud_heart_fg.png b/textures/hud_heart_fg.png
deleted file mode 100644
index dc213d8..0000000
--- a/textures/hud_heart_fg.png
+++ /dev/null
Binary files differ
diff --git a/textures/hud_hotbar.png b/textures/hud_hotbar.png
deleted file mode 100644
index 8c3df7c..0000000
--- a/textures/hud_hotbar.png
+++ /dev/null
Binary files differ
diff --git a/textures/hud_hotbar_selected.png b/textures/hud_hotbar_selected.png
deleted file mode 100644
index 5334d6b..0000000
--- a/textures/hud_hotbar_selected.png
+++ /dev/null
Binary files differ
diff --git a/textures/hud_hunger_bg.png b/textures/hud_hunger_bg.png
deleted file mode 100644
index 07e21e7..0000000
--- a/textures/hud_hunger_bg.png
+++ /dev/null
Binary files differ
diff --git a/textures/wieldhand.png b/textures/wieldhand.png
deleted file mode 100644
index 2307ba4..0000000
--- a/textures/wieldhand.png
+++ /dev/null
Binary files differ