diff --git a/README.txt b/README.txt old mode 100644 new mode 100755 index 3e9f77d..4424cde --- a/README.txt +++ b/README.txt @@ -35,7 +35,6 @@ Dependencies: License of textures: -------------------- hbarmor_icon.png - Stu (CC BY-SA 3.0), modified by BlockMen -hbarmor_bgicon.png - Stu (CC BY-SA 3.0), modified by BlockMen hbarmor_bar.png - Wuzzy (WTFPL) diff --git a/armor.lua b/armor.lua old mode 100644 new mode 100755 index 511640d..7214b2b --- a/armor.lua +++ b/armor.lua @@ -21,7 +21,7 @@ end function hbarmor.set_armor(player_name, ges_state, items) local max_items = 4 - if items == 5 then + if items == 5 then max_items = items end local max = max_items * 65535 diff --git a/changelog.txt b/changelog.txt old mode 100644 new mode 100755 diff --git a/depends.txt b/depends.txt old mode 100644 new mode 100755 diff --git a/hbarmor.conf.example b/hbarmor.conf.example old mode 100644 new mode 100755 diff --git a/init.lua b/init.lua old mode 100644 new mode 100755 index 4aba3bd..47bf66e --- a/init.lua +++ b/init.lua @@ -16,7 +16,7 @@ hbarmor.autohide = true --load custom settings local set = io.open(minetest.get_modpath("hbarmor").."/hbarmor.conf", "r") -if set then +if set then dofile(minetest.get_modpath("hbarmor").."/hbarmor.conf") set:close() end @@ -50,7 +50,7 @@ local function custom_hud(player) end --register and define armor HUD bar -hb.register_hudbar("armor", 0xFFFFFF, "Armor", { icon = "hbarmor_icon.png", bgicon = "hbarmor_bgicon.png", bar = "hbarmor_bar.png" }, 0, 100, hbarmor.autohide, "%s: %d%%") +hb.register_hudbar("armor", 0xFFFFFF, "Armor", { icon = "hbarmor_icon.png", bar = "hbarmor_bar.png" }, 0, 100, hbarmor.autohide, "%s: %d%%") dofile(minetest.get_modpath("hbarmor").."/armor.lua") @@ -88,26 +88,21 @@ minetest.register_on_leaveplayer(function(player) hbarmor.player_active[name] = false end) -local main_timer = 0 -local timer = 0 -minetest.register_globalstep(function(dtime) - main_timer = main_timer + dtime - timer = timer + dtime - if main_timer > hbarmor.tick or timer > 4 then - if minetest.setting_getbool("enable_damage") then - if main_timer > hbarmor.tick then main_timer = 0 end - for _,player in ipairs(minetest.get_connected_players()) do - local name = player:get_player_name() - if hbarmor.player_active[name] == true then - local ret = hbarmor.get_armor(player) - if ret == false then - minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in globalstep returned with false!") - end - -- update all hud elements - update_hud(player) +local function hbarmor_step() + if minetest.setting_getbool("enable_damage") then + for _,player in ipairs(minetest.get_connected_players()) do + local name = player:get_player_name() + if hbarmor.player_active[name] == true then + local ret = hbarmor.get_armor(player) + if ret == false then + minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in step returned with false!") end + -- update all hud elements + update_hud(player) end end end - if timer > 4 then timer = 0 end -end) + + minetest.after(hbarmor.tick, hbarmor_step) +end +minetest.after(0, hbarmor_step) diff --git a/textures/hbarmor_bar.png b/textures/hbarmor_bar.png old mode 100644 new mode 100755 index 9623c4e..0e4495c Binary files a/textures/hbarmor_bar.png and b/textures/hbarmor_bar.png differ diff --git a/textures/hbarmor_bgicon.png b/textures/hbarmor_bgicon.png deleted file mode 100644 index 3240100..0000000 Binary files a/textures/hbarmor_bgicon.png and /dev/null differ diff --git a/textures/hbarmor_icon.png b/textures/hbarmor_icon.png old mode 100644 new mode 100755 index 374f1a9..5e033c7 Binary files a/textures/hbarmor_icon.png and b/textures/hbarmor_icon.png differ