mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-22 20:43:43 +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 S = minetest.get_translator(minetest.get_current_modname())
|
||||||
local F = minetest.formspec_escape
|
local F = minetest.formspec_escape
|
||||||
local has_technic = minetest.get_modpath("technic") ~= nil
|
local has_technic = minetest.get_modpath("technic") ~= nil
|
||||||
|
local ui = unified_inventory
|
||||||
|
|
||||||
if not minetest.global_exists("unified_inventory") then
|
if not minetest.global_exists("unified_inventory") then
|
||||||
minetest.log("warning", S("3d_armor_ui: Mod loaded but unused."))
|
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", {
|
unified_inventory.register_page("armor", {
|
||||||
get_formspec = function(player, perplayer_formspec)
|
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()
|
local name = player:get_player_name()
|
||||||
if armor.def[name].init_time == 0 then
|
if armor.def[name].init_time == 0 then
|
||||||
return {formspec="label[0,0;"..F(S("Armor not initialized!")).."]"}
|
return {formspec="label[0,0;"..F(S("Armor not initialized!")).."]"}
|
||||||
end
|
end
|
||||||
local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"..
|
local formspec = perplayer_formspec.standard_inv_bg..
|
||||||
"label[0,0;"..F(S("Armor")).."]"..
|
perplayer_formspec.standard_inv..
|
||||||
"list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"..
|
ui.make_inv_img_grid(gridx, gridy, 2, 3)..
|
||||||
"image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"..
|
string.format("label[%f,%f;%s]",
|
||||||
"label[5.0,"..(fy + 0.0)..";"..F(S("Level"))..": "..armor.def[name].level.."]"..
|
perplayer_formspec.form_header_x, perplayer_formspec.form_header_y, F(S("Armor")))..
|
||||||
"label[5.0,"..(fy + 0.5)..";"..F(S("Heal"))..": "..armor.def[name].heal.."]"..
|
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[current_player;main]"..
|
||||||
"listring[detached:"..name.."_armor;armor]"
|
"listring[detached:"..name.."_armor;armor]"
|
||||||
if armor.config.fire_protect then
|
if armor.config.fire_protect then
|
||||||
@ -45,7 +53,7 @@ unified_inventory.register_page("armor", {
|
|||||||
F(S("Fire"))..": "..armor.def[name].fire.."]"
|
F(S("Fire"))..": "..armor.def[name].fire.."]"
|
||||||
end
|
end
|
||||||
if has_technic then
|
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"].."]"
|
F(S("Radiation"))..": "..armor.def[name].groups["radiation"].."]"
|
||||||
end
|
end
|
||||||
return {formspec=formspec}
|
return {formspec=formspec}
|
||||||
|
@ -2,3 +2,4 @@ name = 3d_armor_ui
|
|||||||
depends = 3d_armor
|
depends = 3d_armor
|
||||||
optional_depends = unified_inventory
|
optional_depends = unified_inventory
|
||||||
description = Adds 3d_armor page to the 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