1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-05 01:50:25 +01:00
server-nalc/mods/hbarmor/armor.lua

38 lines
805 B
Lua
Raw Normal View History

2015-04-13 21:37:48 +02:00
minetest.after(0, function()
if not armor.def then
minetest.after(2,minetest.chat_send_all,"#Better HUD: Please update your version of 3darmor")
HUD_SHOW_ARMOR = false
end
end)
function hbarmor.get_armor(player)
2015-04-13 21:37:48 +02:00
if not player or not armor.def then
return false
2015-04-13 21:37:48 +02:00
end
local name = player:get_player_name()
local def = armor.def[name] or nil
if def and def.state and def.count then
hbarmor.set_armor(name, def.state, def.count)
else
return false
2015-04-13 21:37:48 +02:00
end
return true
2015-04-13 21:37:48 +02:00
end
function hbarmor.set_armor(player_name, ges_state, items)
2015-04-13 21:37:48 +02:00
local max_items = 4
2015-06-10 17:14:58 +02:00
if items == 5 then
2015-04-13 21:37:48 +02:00
max_items = items
end
local max = max_items * 65535
local lvl = max - ges_state
lvl = lvl/max
if ges_state == 0 and items == 0 then
lvl = 0
end
hbarmor.armor[player_name] = lvl* (items * (100 / max_items))
2015-04-13 21:37:48 +02:00
end