2017-08-06 18:43:41 +02:00
|
|
|
-- support for i18n
|
2020-08-31 05:47:57 +02:00
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
2018-07-26 21:05:50 +02:00
|
|
|
local F = minetest.formspec_escape
|
2018-02-22 20:58:26 +01:00
|
|
|
local has_technic = minetest.get_modpath("technic") ~= nil
|
2017-08-06 18:43:41 +02:00
|
|
|
|
2017-03-19 19:39:58 +01:00
|
|
|
if not minetest.global_exists("unified_inventory") then
|
2021-04-15 19:03:21 +02:00
|
|
|
minetest.log("warning", "3d_armor_ui: Mod loaded but unused.")
|
2017-03-19 19:39:58 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-04-15 19:03:21 +02:00
|
|
|
local ui = unified_inventory
|
|
|
|
if ui.sfinv_compat_layer then
|
2017-03-19 19:39:58 +01:00
|
|
|
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",
|
2022-12-25 18:23:49 +01:00
|
|
|
tooltip = S("3D Armor")
|
2017-03-19 19:39:58 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
unified_inventory.register_page("armor", {
|
|
|
|
get_formspec = function(player, perplayer_formspec)
|
2021-03-10 09:21:26 +01:00
|
|
|
local fy = perplayer_formspec.form_header_y + 0.5
|
|
|
|
local gridx = perplayer_formspec.std_inv_x
|
|
|
|
local gridy = 0.6
|
|
|
|
|
2017-03-19 19:39:58 +01:00
|
|
|
local name = player:get_player_name()
|
2021-03-10 09:21:26 +01:00
|
|
|
local formspec = perplayer_formspec.standard_inv_bg..
|
|
|
|
perplayer_formspec.standard_inv..
|
|
|
|
ui.make_inv_img_grid(gridx, gridy, 2, 3)..
|
|
|
|
string.format("label[%f,%f;%s]",
|
|
|
|
perplayer_formspec.form_header_x, perplayer_formspec.form_header_y, F(S("Armor")))..
|
|
|
|
string.format("list[detached:%s_armor;armor;%f,%f;2,3;]",
|
|
|
|
name, gridx + ui.list_img_offset, gridy + ui.list_img_offset) ..
|
|
|
|
"image[3.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"..
|
|
|
|
"label[6.0,"..(fy + 0.0)..";"..F(S("Level"))..": "..armor.def[name].level.."]"..
|
|
|
|
"label[6.0,"..(fy + 0.5)..";"..F(S("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
|
2021-05-24 09:59:54 +02:00
|
|
|
formspec = formspec.."label[6.0,"..(fy + 1.0)..";"..
|
2018-07-26 21:05:50 +02:00
|
|
|
F(S("Fire"))..": "..armor.def[name].fire.."]"
|
2017-04-13 20:47:43 +02:00
|
|
|
end
|
2018-02-22 20:58:26 +01:00
|
|
|
if has_technic then
|
2021-03-10 09:21:26 +01:00
|
|
|
formspec = formspec.."label[6.0,"..(fy + 1.5)..";"..
|
2018-07-26 21:05:50 +02:00
|
|
|
F(S("Radiation"))..": "..armor.def[name].groups["radiation"].."]"
|
2017-03-19 19:39:58 +01:00
|
|
|
end
|
|
|
|
return {formspec=formspec}
|
|
|
|
end,
|
|
|
|
})
|