Fix hunger bug, add colorize to player damage, improved text positioning

This commit is contained in:
MoNTE48 2019-06-20 00:11:24 +02:00
parent c3e14d78d7
commit 9a288fa3f8
3 changed files with 21 additions and 20 deletions

View File

@ -1,6 +1,20 @@
-- (c) Copyright BlockMen (2013-2016), LGPLv3.0+
if minetest.settings:get_bool("enable_damage") then
hud.register("armor", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
alignment = {x = -1, y = -1},
offset = {x = -247, y = -134},
size = {x = 24, y = 24},
text = "3d_armor_statbar_fg.png",
background = "3d_armor_statbar_bg.png",
number = 0,
max = 20,
autohide_bg = true,
})
local armor_org_func = armor.set_player_armor
local function get_armor_lvl(def)
-- items/protection based display
@ -23,17 +37,4 @@ if minetest.settings:get_bool("enable_damage") then
end
hud.change_item(player, "armor", {number = armor_lvl})
end
hud.register("armor", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
alignment = {x = -1, y = -1},
offset = {x = -247, y = -134},
size = {x = 24, y = 24},
text = "3d_armor_statbar_fg.png",
background = "3d_armor_statbar_bg.png",
number = 0,
max = 20,
autohide_bg = true,
})
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -21,6 +21,10 @@ HUNGER_MAX = 30 -- maximum level of saturation
-- Callbacks
if minetest.settings:get_bool("enable_damage") then
local modpath = minetest.get_modpath("hunger")
dofile(modpath .. "/functions.lua")
dofile(modpath .. "/food.lua")
hud.register("hunger", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
@ -29,15 +33,11 @@ if minetest.settings:get_bool("enable_damage") then
size = {x = 24, y = 24},
text = "hunger_statbar_fg.png",
background = "hunger_statbar_bg.png",
number = 20,
number = 20
})
local modpath = minetest.get_modpath("hunger")
dofile(modpath .. "/functions.lua")
dofile(modpath .. "/food.lua")
minetest.register_on_joinplayer(function(player)
minetest.after(0.1, function()
minetest.after(0.5, function()
local inv = player:get_inventory()
if inv then
inv:set_size("hunger", 1)
@ -51,7 +51,7 @@ if minetest.settings:get_bool("enable_damage") then
lvl = 20
end
hud.change_item(player, "hunger", {number = lvl, max = 20})
hud.change_item(player, "hunger", {number = lvl})
end
end)
end)