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 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 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. 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. see armor.conf.example for all available options.
Note: worldpath config settings override any settings made in the mod's directory. 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) inventory_plus.get_formspec = function(player, page)
end end
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" inv_mod = "unified_inventory"
unified_inventory.register_button("armor", { unified_inventory.register_button("armor", {
type = "image", type = "image",
@ -120,6 +120,17 @@ elseif minetest.get_modpath("inventory_enhanced") then
inv_mod = "inventory_enhanced" inv_mod = "inventory_enhanced"
elseif minetest.get_modpath("smart_inventory") then elseif minetest.get_modpath("smart_inventory") then
inv_mod = "smart_inventory" 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 end
if minetest.get_modpath("skins") then if minetest.get_modpath("skins") then
@ -248,7 +259,7 @@ end
armor.update_armor = function(self, player) armor.update_armor = function(self, player)
-- Legacy support: Called when armor levels are changed -- Legacy support: Called when armor levels are changed
-- Other mods can hook on to this function, see hud mod for example -- Other mods can hook on to this function, see hud mod for example
end end
armor.get_player_skin = function(self, name) armor.get_player_skin = function(self, name)
@ -297,9 +308,16 @@ armor.update_inventory = function(self, player)
if state then if state then
state:get("update_hook"):submit() state:get("update_hook"):submit()
end end
return elseif inv_mod == "sfinv" then
end if sfinv.set_page then
if inv_mod == "unified_inventory" 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 if unified_inventory.current_page[name] == "armor" then
unified_inventory.set_inventory_formspec(player, "armor") unified_inventory.set_inventory_formspec(player, "armor")
end end
@ -428,7 +446,7 @@ minetest.register_on_joinplayer(function(player)
for i=1, 6 do for i=1, 6 do
local stack = player_inv:get_stack("armor", i) local stack = player_inv:get_stack("armor", i)
armor_inv:set_stack("armor", i, stack) armor_inv:set_stack("armor", i, stack)
end end
armor.def[name] = { armor.def[name] = {
state = 0, state = 0,
count = 0, count = 0,

View File

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