Add support for sfinv

This commit is contained in:
rubenwardy 2017-02-16 00:10:19 +00:00 committed by stujones11
parent 3df7802439
commit 8b8a554ff7
3 changed files with 26 additions and 8 deletions

View File

@ -3,7 +3,7 @@
Depends: default
Recommends: inventory_plus or unified_inventory (use only one)
Recommends: sfinv, inventory_plus or unified_inventory (use only one to avoid conflicts)
Adds craftable armor that is visible to other players. Each armor item worn contributes to
a player's armor group level making them less vulnerable to weapons.
@ -21,4 +21,3 @@ Armor can be configured by adding a file called armor.conf in 3d_armor mod and/o
see armor.conf.example for all available options.
Note: worldpath config settings override any settings made in the mod's directory.

View File

@ -93,7 +93,7 @@ if minetest.get_modpath("inventory_plus") then
inventory_plus.get_formspec = function(player, page)
end
end
elseif minetest.get_modpath("unified_inventory") then
elseif minetest.get_modpath("unified_inventory") and not unified_inventory.sfinv_compat_layer then
inv_mod = "unified_inventory"
unified_inventory.register_button("armor", {
type = "image",
@ -120,6 +120,17 @@ elseif minetest.get_modpath("inventory_enhanced") then
inv_mod = "inventory_enhanced"
elseif minetest.get_modpath("smart_inventory") then
inv_mod = "smart_inventory"
elseif minetest.get_modpath("sfinv") then
inv_mod = "sfinv"
armor.formspec = "image[2,0.5;2,4;armor_preview]"
sfinv.register_page("3d_armor:armor", {
title = "Armor",
get = function(self, player, context)
return sfinv.make_formspec(player, context,
armor:get_armor_formspec(player:get_player_name()), true)
end
})
end
if minetest.get_modpath("skins") then
@ -297,9 +308,16 @@ armor.update_inventory = function(self, player)
if state then
state:get("update_hook"):submit()
end
return
end
if inv_mod == "unified_inventory" then
elseif inv_mod == "sfinv" then
if sfinv.set_page then
sfinv.set_page(player, "3d_armor:armor")
else
-- Backwards compat
sfinv.set_player_inventory_formspec(player, {
page = "3d_armor:armor"
})
end
elseif inv_mod == "unified_inventory" then
if unified_inventory.current_page[name] == "armor" then
unified_inventory.set_inventory_formspec(player, "armor")
end

View File

@ -1,6 +1,7 @@
default
inventory_plus?
unified_inventory?
sfinv?
fire?
ethereal?
bakedclay?