mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-12-22 17:02:23 +01:00
Update to work with Unified Inventory since formspec v4 update (#45)
Requires UI git tag "version-2" or commit a7556c50, and Minetest v5.4.0 or later
This commit is contained in:
parent
44111db4d7
commit
583dfe7b21
Binary file not shown.
Before Width: | Height: | Size: 8.9 KiB |
@ -2,6 +2,7 @@
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
local F = minetest.formspec_escape
|
||||
local has_technic = minetest.get_modpath("technic") ~= nil
|
||||
local ui = unified_inventory
|
||||
|
||||
if not minetest.global_exists("unified_inventory") then
|
||||
minetest.log("warning", S("3d_armor_ui: Mod loaded but unused."))
|
||||
@ -27,17 +28,24 @@ unified_inventory.register_button("armor", {
|
||||
|
||||
unified_inventory.register_page("armor", {
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
local fy = perplayer_formspec.formspec_y
|
||||
local fy = perplayer_formspec.form_header_y + 0.5
|
||||
local gridx = perplayer_formspec.std_inv_x
|
||||
local gridy = 0.6
|
||||
|
||||
local name = player:get_player_name()
|
||||
if armor.def[name].init_time == 0 then
|
||||
return {formspec="label[0,0;"..F(S("Armor not initialized!")).."]"}
|
||||
end
|
||||
local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"..
|
||||
"label[0,0;"..F(S("Armor")).."]"..
|
||||
"list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"..
|
||||
"image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"..
|
||||
"label[5.0,"..(fy + 0.0)..";"..F(S("Level"))..": "..armor.def[name].level.."]"..
|
||||
"label[5.0,"..(fy + 0.5)..";"..F(S("Heal"))..": "..armor.def[name].heal.."]"..
|
||||
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.."]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[detached:"..name.."_armor;armor]"
|
||||
if armor.config.fire_protect then
|
||||
@ -45,7 +53,7 @@ unified_inventory.register_page("armor", {
|
||||
F(S("Fire"))..": "..armor.def[name].fire.."]"
|
||||
end
|
||||
if has_technic then
|
||||
formspec = formspec.."label[5.0,"..(fy + 1.5)..";"..
|
||||
formspec = formspec.."label[6.0,"..(fy + 1.5)..";"..
|
||||
F(S("Radiation"))..": "..armor.def[name].groups["radiation"].."]"
|
||||
end
|
||||
return {formspec=formspec}
|
||||
|
@ -2,3 +2,4 @@ name = 3d_armor_ui
|
||||
depends = 3d_armor
|
||||
optional_depends = unified_inventory
|
||||
description = Adds 3d_armor page to the unified inventory.
|
||||
min_minetest_version = 5.4.0
|
||||
|
Loading…
Reference in New Issue
Block a user