Update hud mod (version 2.1.5)
parent
d1f9d097b1
commit
78e2e811d6
|
@ -1,8 +1,8 @@
|
||||||
Modpack "Better HUD and hunger"
|
Modpack "Better HUD and hunger"
|
||||||
===============================
|
===============================
|
||||||
ModPack-Version: 2.x.0
|
ModPack-Version: 2.x.1
|
||||||
|
|
||||||
Copyright (c) 2013-2015 BlockMen <blockmen2015@gmail.com>
|
Copyright (c) 2013-2016 BlockMen <blockmen2015@gmail.com>
|
||||||
|
|
||||||
|
|
||||||
About this mod:
|
About this mod:
|
||||||
|
@ -36,7 +36,7 @@ For more information how to register more food see API.txt
|
||||||
|
|
||||||
License:
|
License:
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
(c) Copyright BlockMen (2013-2015)
|
(c) Copyright BlockMen (2013-2016)
|
||||||
|
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
Minetest mod "Better HUD"
|
Minetest mod "Better HUD"
|
||||||
=========================
|
=========================
|
||||||
Version: 2.1.4
|
Version: 2.1.5
|
||||||
|
|
||||||
(c) Copyright BlockMen (2013-2015)
|
(c) Copyright BlockMen (2013-2016)
|
||||||
|
|
||||||
|
|
||||||
About this mod:
|
About this mod:
|
||||||
|
@ -26,7 +26,7 @@ This mod supports the 3d_armor mod by stu (https://github.com/stujones11/minetes
|
||||||
|
|
||||||
License:
|
License:
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
(c) Copyright BlockMen (2013-2015)
|
(c) Copyright BlockMen (2013-2016)
|
||||||
|
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2.1.5
|
||||||
|
-----
|
||||||
|
- Fixed armor not being updated correct due armor mod changes
|
||||||
|
|
||||||
2.1.4
|
2.1.4
|
||||||
-----
|
-----
|
||||||
- Fixed unhandled exception in hud.swap_statbar()
|
- Fixed unhandled exception in hud.swap_statbar()
|
||||||
|
|
|
@ -3,59 +3,60 @@ function hud.set_armor()
|
||||||
end
|
end
|
||||||
|
|
||||||
if hud.show_armor then
|
if hud.show_armor then
|
||||||
local shields = minetest.get_modpath("shields") ~= nil
|
local shields = minetest.get_modpath("shields") ~= nil
|
||||||
local armor_org_func = armor.update_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
|
||||||
local lvl = def.level or 0
|
local lvl = def.level or 0
|
||||||
local max = 63 -- full diamond armor
|
local max = 63 -- full diamond armor
|
||||||
if shields then
|
if shields then
|
||||||
max = 84.14 -- full diamond armor + diamond shield
|
max = 84.14 -- full diamond armor + diamond shield
|
||||||
end
|
end
|
||||||
-- TODO: is there a sane way to read out max values?
|
-- TODO: is there a sane way to read out max values?
|
||||||
local ret = lvl/max
|
local ret = lvl/max
|
||||||
if ret > 1 then
|
if ret > 1 then
|
||||||
ret = 1
|
ret = 1
|
||||||
end
|
|
||||||
|
|
||||||
return tonumber(20 * ret)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function armor.update_armor(self, player)
|
return tonumber(20 * ret)
|
||||||
armor_org_func(self, player)
|
end
|
||||||
local name = player:get_player_name()
|
|
||||||
local def = self.def
|
function armor.set_player_armor(self, player)
|
||||||
local armor_lvl = 0
|
armor_org_func(self, player)
|
||||||
if def[name] and def[name].level then
|
local name = player:get_player_name()
|
||||||
armor_lvl = get_armor_lvl(def[name])
|
local def = self.def
|
||||||
end
|
local armor_lvl = 0
|
||||||
hud.change_item(player, "armor", {number = armor_lvl})
|
if def[name] and def[name].level then
|
||||||
|
armor_lvl = get_armor_lvl(def[name])
|
||||||
end
|
end
|
||||||
|
hud.change_item(player, "armor", {number = armor_lvl})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hunger related functions
|
-- Hunger related functions
|
||||||
if not hud.show_hunger then
|
if not hud.show_hunger then
|
||||||
function hud.set_hunger()
|
function hud.set_hunger()
|
||||||
hud.notify_hunger(1, true)
|
hud.notify_hunger(1, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function hud.get_hunger()
|
function hud.get_hunger()
|
||||||
hud.notify_hunger(1, true)
|
hud.notify_hunger(1, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function hud.item_eat(hp_change, replace_with_item)
|
function hud.item_eat(hp_change, replace_with_item)
|
||||||
return function(itemstack, user, pointed_thing)
|
return function(itemstack, user, pointed_thing)
|
||||||
hud.notify_hunger(1, true)
|
hud.notify_hunger(1, true)
|
||||||
local func = minetest.item_eat(hp_change, replace_with_item)
|
local func = minetest.item_eat(hp_change, replace_with_item)
|
||||||
return func(itemstack, user, pointed_thing)
|
return func(itemstack, user, pointed_thing)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function hud.save_hunger()
|
function hud.save_hunger()
|
||||||
hud.notify_hunger(1, true)
|
hud.notify_hunger(1, true)
|
||||||
end
|
end
|
||||||
function hud.load_hunger(player)
|
|
||||||
hud.notify_hunger(1, true)
|
function hud.load_hunger(player)
|
||||||
end
|
hud.notify_hunger(1, true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue