mirror of
https://github.com/pandorabox-io/banners.git
synced 2025-01-08 17:10:32 +01:00
avoid error: "unknown global"
This commit is contained in:
parent
c8af7c71e5
commit
aa514d114a
15
smartfs.lua
15
smartfs.lua
@ -4,6 +4,9 @@
|
|||||||
-- by Rubenwardy
|
-- by Rubenwardy
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
local has_inventory_plus = core.get_modpath("inventory_plus") and true or false
|
||||||
|
local has_unified_inventory = core.get_modpath("unified_inventory") and true or false
|
||||||
|
|
||||||
smartfs = {
|
smartfs = {
|
||||||
_fdef = {},
|
_fdef = {},
|
||||||
_edef = {},
|
_edef = {},
|
||||||
@ -59,17 +62,17 @@ function smartfs.element(name,data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function smartfs.inventory_mod()
|
function smartfs.inventory_mod()
|
||||||
if unified_inventory then
|
if has_unified_inventory then
|
||||||
return "unified_inventory"
|
return "unified_inventory"
|
||||||
elseif inventory_plus then
|
elseif has_inventory_plus then
|
||||||
return "inventory_plus"
|
return "inventory_plus"
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if unified_inventory then
|
|
||||||
function smartfs.add_to_inventory(form, icon, title)
|
function smartfs.add_to_inventory(form, icon, title)
|
||||||
|
if has_unified_inventory then
|
||||||
unified_inventory.register_button(form.name, {
|
unified_inventory.register_button(form.name, {
|
||||||
type = "image",
|
type = "image",
|
||||||
image = icon,
|
image = icon,
|
||||||
@ -83,7 +86,7 @@ function smartfs.add_to_inventory(form, icon, title)
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
elseif inventory_plus then
|
elseif has_inventory_plus then
|
||||||
core.register_on_joinplayer(function(player)
|
core.register_on_joinplayer(function(player)
|
||||||
inventory_plus.register_button(player, form.name, title)
|
inventory_plus.register_button(player, form.name, title)
|
||||||
end)
|
end)
|
||||||
@ -128,10 +131,10 @@ function smartfs._makeState_(form, player, params, is_inv)
|
|||||||
end,
|
end,
|
||||||
_show_ = function(self)
|
_show_ = function(self)
|
||||||
if self.is_inv then
|
if self.is_inv then
|
||||||
if unified_inventory then
|
if has_unified_inventory then
|
||||||
elseif inventory_plus then
|
|
||||||
unified_inventory.set_inventory_formspec(
|
unified_inventory.set_inventory_formspec(
|
||||||
core.get_player_by_name(self.player), self.def.name)
|
core.get_player_by_name(self.player), self.def.name)
|
||||||
|
elseif has_inventory_plus then
|
||||||
inventory_plus.set_inventory_formspec(
|
inventory_plus.set_inventory_formspec(
|
||||||
core.get_player_by_name(self.player), self:_getFS_(true))
|
core.get_player_by_name(self.player), self:_getFS_(true))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user