Compatibility update (scaling statbars)

This commit is contained in:
BlockMen 2014-05-13 18:59:08 +02:00
parent 45eebf79c9
commit 28754289b7
4 changed files with 35 additions and 11 deletions

@ -1,6 +1,6 @@
Minetest mod "Better HUD" Minetest mod "Better HUD"
========================= =========================
Version: 1.3 Version: 1.3.1
License of source code: WTFPL License of source code: WTFPL
----------------------------- -----------------------------

@ -63,3 +63,9 @@
- Add support for mods: seaplants[sea] and mobfcooking (by Xanthin) - Add support for mods: seaplants[sea] and mobfcooking (by Xanthin)
- Tweaked hand image - Tweaked hand image
- Player can die caus of starving now - Player can die caus of starving now
1.3.1
-----
- Add compatibility for statbar scaling
- Fix typo in depends.txt
- Lower maintimer tick

@ -7,7 +7,7 @@ fishing?
glooptest? glooptest?
bushes? bushes?
docfarming? docfarming?
farmingplus? farming_plus?
mtfoods? mtfoods?
bushes_classic? bushes_classic?
mushroom? mushroom?

@ -16,6 +16,10 @@ local armor_hud = {}
local armor_hud_bg = {} local armor_hud_bg = {}
-- default settings -- default settings
HUD_SCALEABLE = false
HUD_SIZE = ""
-- statbar positions -- statbar positions
HUD_HEALTH_POS = {x=0.5,y=0.9} HUD_HEALTH_POS = {x=0.5,y=0.9}
HUD_HEALTH_OFFSET = {x=-175, y=2} HUD_HEALTH_OFFSET = {x=-175, y=2}
@ -26,7 +30,21 @@ HUD_AIR_OFFSET = {x=15,y=-15}
HUD_ARMOR_POS = {x=0.5,y=0.9} HUD_ARMOR_POS = {x=0.5,y=0.9}
HUD_ARMOR_OFFSET = {x=-175, y=-15} HUD_ARMOR_OFFSET = {x=-175, y=-15}
HUD_TICK = 0.2 -- 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
HUD_HUNGER_TICK = 300 HUD_HUNGER_TICK = 300
HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable") HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
@ -46,7 +64,7 @@ if set then
set:close() set:close()
else else
if not HUD_ENABLE_HUNGER then if not HUD_ENABLE_HUNGER then
HUD_AIR_OFFSET = {x=15,y=0} HUD_AIR_OFFSET = HUD_HUNGER_OFFSET
end end
end end
@ -70,7 +88,7 @@ local function custom_hud(player)
player:hud_add({ player:hud_add({
hud_elem_type = "statbar", hud_elem_type = "statbar",
position = HUD_HUNGER_POS, position = HUD_HUNGER_POS,
scale = {x=1, y=1}, size = HUD_SIZE,
text = "hud_hunger_bg.png", text = "hud_hunger_bg.png",
number = 20, number = 20,
alignment = {x=-1,y=-1}, alignment = {x=-1,y=-1},
@ -81,7 +99,7 @@ local function custom_hud(player)
hunger_hud[name] = player:hud_add({ hunger_hud[name] = player:hud_add({
hud_elem_type = "statbar", hud_elem_type = "statbar",
position = HUD_HUNGER_POS, position = HUD_HUNGER_POS,
scale = {x=1, y=1}, size = HUD_SIZE,
text = "hud_hunger_fg.png", text = "hud_hunger_fg.png",
number = h, number = h,
alignment = {x=-1,y=-1}, alignment = {x=-1,y=-1},
@ -92,7 +110,7 @@ local function custom_hud(player)
player:hud_add({ player:hud_add({
hud_elem_type = "statbar", hud_elem_type = "statbar",
position = HUD_HEALTH_POS, position = HUD_HEALTH_POS,
scale = {x=1, y=1}, size = HUD_SIZE,
text = "hud_heart_bg.png", text = "hud_heart_bg.png",
number = 20, number = 20,
alignment = {x=-1,y=-1}, alignment = {x=-1,y=-1},
@ -101,7 +119,7 @@ local function custom_hud(player)
health_hud[name] = player:hud_add({ health_hud[name] = player:hud_add({
hud_elem_type = "statbar", hud_elem_type = "statbar",
position = HUD_HEALTH_POS, position = HUD_HEALTH_POS,
scale = {x=1, y=1}, size = HUD_SIZE,
text = "hud_heart_fg.png", text = "hud_heart_fg.png",
number = player:get_hp(), number = player:get_hp(),
alignment = {x=-1,y=-1}, alignment = {x=-1,y=-1},
@ -112,7 +130,7 @@ local function custom_hud(player)
air_hud[name] = player:hud_add({ air_hud[name] = player:hud_add({
hud_elem_type = "statbar", hud_elem_type = "statbar",
position = HUD_AIR_POS, position = HUD_AIR_POS,
scale = {x=1, y=1}, size = HUD_SIZE,
text = "hud_air_fg.png", text = "hud_air_fg.png",
number = 0, number = 0,
alignment = {x=-1,y=-1}, alignment = {x=-1,y=-1},
@ -124,7 +142,7 @@ local function custom_hud(player)
armor_hud_bg[name] = player:hud_add({ armor_hud_bg[name] = player:hud_add({
hud_elem_type = "statbar", hud_elem_type = "statbar",
position = HUD_ARMOR_POS, position = HUD_ARMOR_POS,
scale = {x=1, y=1}, size = HUD_SIZE,
text = "hud_armor_bg.png", text = "hud_armor_bg.png",
number = 0, number = 0,
alignment = {x=-1,y=-1}, alignment = {x=-1,y=-1},
@ -133,7 +151,7 @@ local function custom_hud(player)
armor_hud[name] = player:hud_add({ armor_hud[name] = player:hud_add({
hud_elem_type = "statbar", hud_elem_type = "statbar",
position = HUD_ARMOR_POS, position = HUD_ARMOR_POS,
scale = {x=1, y=1}, size = HUD_SIZE,
text = "hud_armor_fg.png", text = "hud_armor_fg.png",
number = 0, number = 0,
alignment = {x=-1,y=-1}, alignment = {x=-1,y=-1},