summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--armor.lua34
-rw-r--r--init.lua205
-rw-r--r--textures/crosshair.pngbin216 -> 0 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
12 files changed, 17 insertions, 222 deletions
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/init.lua b/init.lua
index 1dc9809..027f01f 100644
--- a/init.lua
+++ b/init.lua
@@ -1,48 +1,11 @@
hud = {}
-- HUD statbar values
-hud.health = {}
hud.hunger = {}
-hud.air = {}
-hud.armor = {}
hud.hunger_out = {}
-hud.armor_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
@@ -56,45 +19,18 @@ HUD_HUNGER_EXHAUST_MOVE = 0.3 -- exhaustion increased this value if player movem
HUD_HUNGER_EXHAUST_LVL = 160 -- at what exhaustion player saturation gets lowerd
-
-HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
-if HUD_ENABLE_HUNGER == nil then
- HUD_ENABLE_HUNGER = minetest.setting_getbool("enable_damage")
-end
-
-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("hunger").."/hud.conf", "r")
if set then
- dofile(minetest.get_modpath("hud").."/hud.conf")
+ dofile(minetest.get_modpath("hunger").."/hud.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,
@@ -115,103 +51,14 @@ local function custom_hud(player)
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()
-end
-
-
-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
+dofile(minetest.get_modpath("hunger").."/hunger.lua")
-- 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])
@@ -253,33 +100,19 @@ 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)
+ hud.hunger[name] = hud.get_hunger(player)
+ hud.hunger_out[name] = hud.hunger[name]
+ hud.exhaustion[name] = 0
+ custom_hud(player)
+ hud.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
+ hud.set_hunger(player)
+ hud.exhaustion[name] = 0
end)
local main_timer = 0
@@ -301,7 +134,7 @@ minetest.after(2.5, function()
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
+ 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
@@ -309,26 +142,22 @@ minetest.after(2.5, function()
end
end
-- lower saturation by 1 point after xx seconds
- if HUD_ENABLE_HUNGER and timer2 > HUD_HUNGER_TICK then
+ if timer2 > HUD_HUNGER_TICK then
if h > 0 then
h = h-1
hud.hunger[name] = h
hud.set_hunger(player)
end
end
- -- update current armor level
- if HUD_SHOW_ARMOR then hud.get_armor(player) end
-- 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
+ hud.handle_node_actions(nil, nil, player)
+ 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/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