Update dependencies
[minetest_hbarmor.git] / armor.lua
blob7f0d0cffae3742bb95e2259d4f273ad56616d49b
1 minetest.after(0, function()
2 if not armor.def then
3 minetest.after(2,minetest.chat_send_all,"#Better HUD: Please update your version of 3darmor")
4 HUD_SHOW_ARMOR = false
5 end
6 end)
8 function hud.get_armor(player)
9 if not player or not armor.def then
10 return
11 end
12 local name = player:get_player_name()
13 local def = armor.def[name] or nil
14 if def and def.state and def.count then
15 hud.set_armor(name, def.state, def.count)
16 end
17 end
19 function hud.set_armor(player_name, ges_state, items)
20 local max_items = 4
21 if items == 5 then
22 max_items = items
23 end
24 local max = max_items * 65535
25 local lvl = max - ges_state
26 lvl = lvl/max
27 if ges_state == 0 and items == 0 then
28 lvl = 0
29 end
31 hud.armor[player_name] = lvl* (items * (20 / max_items))
34 end