forked from mtcontrib/minetest_hbarmor
Remove needless variables
This commit is contained in:
parent
e6b9bc6836
commit
0e18630d41
20
init.lua
20
init.lua
@ -2,11 +2,9 @@ hud = {}
|
|||||||
|
|
||||||
-- HUD statbar values
|
-- HUD statbar values
|
||||||
hud.armor = {}
|
hud.armor = {}
|
||||||
hud.armor_out = {}
|
|
||||||
|
|
||||||
-- HUD item ids
|
-- HUD item ids
|
||||||
local armor_hud = {}
|
local armor_hud = {}
|
||||||
local armor_hud_bg = {}
|
|
||||||
|
|
||||||
HUD_TICK = 0.1
|
HUD_TICK = 0.1
|
||||||
|
|
||||||
@ -50,26 +48,20 @@ dofile(minetest.get_modpath("hbarmor").."/armor.lua")
|
|||||||
local function update_hud(player)
|
local function update_hud(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
--armor
|
--armor
|
||||||
local arm_out = tonumber(hud.armor_out[name])
|
|
||||||
if not arm_out then arm_out = 0 end
|
|
||||||
local arm = tonumber(hud.armor[name])
|
local arm = tonumber(hud.armor[name])
|
||||||
if not arm then arm = 0 end
|
if not arm then arm = 0 end
|
||||||
if arm_out ~= arm then
|
-- hide armor bar completely when there is none
|
||||||
hud.armor_out[name] = arm
|
if must_hide(name, arm) then
|
||||||
-- hide armor bar completely when there is none
|
hb.hide_hudbar(player, "armor")
|
||||||
if must_hide(name, arm) then
|
else
|
||||||
hb.hide_hudbar(player, "armor")
|
hb.unhide_hudbar(player, "armor")
|
||||||
else
|
|
||||||
hb.unhide_hudbar(player, "armor")
|
|
||||||
end
|
|
||||||
hb.change_hudbar(player, "armor", arm_printable(arm))
|
|
||||||
end
|
end
|
||||||
|
hb.change_hudbar(player, "armor", arm_printable(arm))
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
hud.armor[name] = 0
|
hud.armor[name] = 0
|
||||||
hud.armor_out[name] = 0
|
|
||||||
custom_hud(player)
|
custom_hud(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user