Add SFINV support

This commit is contained in:
Panquesito7 2020-05-04 22:30:26 -05:00
parent dc58cb606d
commit 4a005972df
No known key found for this signature in database
GPG Key ID: 3C482B03FD220E68
3 changed files with 25 additions and 3 deletions

View File

@ -1,3 +1,3 @@
name = quests
optional_depends = intllib, unified_inventory, inventory_plus, central_message
description = Quest framework for Minetest.
optional_depends = intllib, unified_inventory, inventory_plus, central_message, sfinv
description = Quest framework for Minetest.

View File

@ -7,8 +7,11 @@ if minetest.get_modpath("inventory_plus") then
dofile(minetest.get_modpath("quests") .. "/mod_integrations/inventory_plus.lua")
end
if minetest.global_exists("sfinv") then
dofile(minetest.get_modpath("quests") .. "/mod_integrations/sfinv.lua")
end
--mod that displays notifications in the screen's center
-- mod that displays notifications in the screen's center
if minetest.get_modpath("central_message") then
dofile(minetest.get_modpath("quests") .. "/mod_integrations/central_message.lua")

View File

@ -0,0 +1,19 @@
assert(sfinv.enabled, "Please enable sfinv in order to use it.")
local old_func = sfinv.pages["sfinv:crafting"].get
sfinv.override_page("sfinv:crafting", {
get = function(self, player, context)
local fs = old_func(self, player, context)
return fs .. "image_button[0,0;1,1;inventory_plus_quests.png;quests;]"
end
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.quests then
quests.show_formspec(player:get_player_name())
return true
elseif fields.quests_exit then
sfinv.set_page(player, "sfinv:crafting")
return true
end
return false
end)