Fix hunger bug, add colorize to player damage, improved text positioning
This commit is contained in:
parent
c3e14d78d7
commit
9a288fa3f8
@ -1,6 +1,20 @@
|
|||||||
-- (c) Copyright BlockMen (2013-2016), LGPLv3.0+
|
-- (c) Copyright BlockMen (2013-2016), LGPLv3.0+
|
||||||
|
|
||||||
if minetest.settings:get_bool("enable_damage") then
|
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 armor_org_func = armor.set_player_armor
|
||||||
local function get_armor_lvl(def)
|
local function get_armor_lvl(def)
|
||||||
-- items/protection based display
|
-- items/protection based display
|
||||||
@ -23,17 +37,4 @@ if minetest.settings:get_bool("enable_damage") then
|
|||||||
end
|
end
|
||||||
hud.change_item(player, "armor", {number = armor_lvl})
|
hud.change_item(player, "armor", {number = armor_lvl})
|
||||||
end
|
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
|
end
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 1.1 KiB |
@ -21,6 +21,10 @@ HUNGER_MAX = 30 -- maximum level of saturation
|
|||||||
-- Callbacks
|
-- Callbacks
|
||||||
if minetest.settings:get_bool("enable_damage") then
|
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.register("hunger", {
|
||||||
hud_elem_type = "statbar",
|
hud_elem_type = "statbar",
|
||||||
position = {x = 0.5, y = 1},
|
position = {x = 0.5, y = 1},
|
||||||
@ -29,15 +33,11 @@ if minetest.settings:get_bool("enable_damage") then
|
|||||||
size = {x = 24, y = 24},
|
size = {x = 24, y = 24},
|
||||||
text = "hunger_statbar_fg.png",
|
text = "hunger_statbar_fg.png",
|
||||||
background = "hunger_statbar_bg.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.register_on_joinplayer(function(player)
|
||||||
minetest.after(0.1, function()
|
minetest.after(0.5, function()
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
if inv then
|
if inv then
|
||||||
inv:set_size("hunger", 1)
|
inv:set_size("hunger", 1)
|
||||||
@ -51,7 +51,7 @@ if minetest.settings:get_bool("enable_damage") then
|
|||||||
lvl = 20
|
lvl = 20
|
||||||
end
|
end
|
||||||
|
|
||||||
hud.change_item(player, "hunger", {number = lvl, max = 20})
|
hud.change_item(player, "hunger", {number = lvl})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user