2017-08-06 18:43:41 +02:00
|
|
|
-- support for i18n
|
|
|
|
local S = armor_i18n.gettext
|
|
|
|
local F = armor_i18n.fgettext
|
|
|
|
|
2017-03-19 19:39:58 +01:00
|
|
|
if not minetest.global_exists("unified_inventory") then
|
2017-08-06 18:43:41 +02:00
|
|
|
minetest.log("warning", S("3d_armor_ui: Mod loaded but unused."))
|
2017-03-19 19:39:58 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if unified_inventory.sfinv_compat_layer then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
armor:register_on_update(function(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
if unified_inventory.current_page[name] == "armor" then
|
|
|
|
unified_inventory.set_inventory_formspec(player, "armor")
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
unified_inventory.register_button("armor", {
|
|
|
|
type = "image",
|
|
|
|
image = "inventory_plus_armor.png",
|
2017-08-06 18:37:30 +02:00
|
|
|
tooltip = S("3d Armor")
|
2017-03-19 19:39:58 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
unified_inventory.register_page("armor", {
|
|
|
|
get_formspec = function(player, perplayer_formspec)
|
|
|
|
local fy = perplayer_formspec.formspec_y
|
|
|
|
local name = player:get_player_name()
|
2017-04-13 20:47:43 +02:00
|
|
|
if armor.def[name].init_time == 0 then
|
2017-08-06 18:43:41 +02:00
|
|
|
return {formspec="label[0,0;"..F("Armor not initialized!").."]"}
|
2017-04-13 20:47:43 +02:00
|
|
|
end
|
2017-03-19 19:39:58 +01:00
|
|
|
local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"..
|
2017-08-06 18:43:41 +02:00
|
|
|
"label[0,0;"..F("Armor").."]"..
|
2017-04-13 18:21:16 +02:00
|
|
|
"list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"..
|
2017-03-19 19:39:58 +01:00
|
|
|
"image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"..
|
2017-08-06 18:43:41 +02:00
|
|
|
"label[5.0,"..(fy + 0.0)..";"..F("Level")..": "..armor.def[name].level.."]"..
|
|
|
|
"label[5.0,"..(fy + 0.5)..";"..F("Heal")..": "..armor.def[name].heal.."]"..
|
2017-03-19 19:39:58 +01:00
|
|
|
"listring[current_player;main]"..
|
|
|
|
"listring[detached:"..name.."_armor;armor]"
|
2017-04-13 20:47:43 +02:00
|
|
|
if armor.config.fire_protect then
|
|
|
|
formspec = formspec.."label[5.0,"..(fy + 1.0)..";"..
|
2017-08-06 18:43:41 +02:00
|
|
|
F("Fire")..": "..armor.def[name].fire.."]"
|
2017-04-13 20:47:43 +02:00
|
|
|
end
|
|
|
|
if minetest.global_exists("technic") then
|
|
|
|
formspec = formspec.."label[5.0,"..(fy + 1.5)..";"..
|
2017-08-06 18:43:41 +02:00
|
|
|
F("Radiation")..": "..armor.def[name].groups["radiation"].."]"
|
2017-03-19 19:39:58 +01:00
|
|
|
end
|
|
|
|
return {formspec=formspec}
|
|
|
|
end,
|
|
|
|
})
|