From 8b807e4cf88b9fcf46613067f600735996007f25 Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Wed, 19 Aug 2020 08:53:20 +0200 Subject: [PATCH] override sfinv function only if sfinv was found --- pages/creative.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pages/creative.lua b/pages/creative.lua index 74ae294..506f360 100644 --- a/pages/creative.lua +++ b/pages/creative.lua @@ -291,17 +291,19 @@ smart_inventory.register_page({ }) -- Redefinition for sfinv method maybe called from other mods -function sfinv.set_player_inventory_formspec(player, context) - local playername = player:get_player_name() +if minetest.global_exists("sfinv") then + function sfinv.set_player_inventory_formspec(player, context) + local playername = player:get_player_name() - local page_state = smart_inventory.get_page_state("creative", playername) - if page_state then - local state = page_state.location.parentState - local has_creative = player_has_creative(state) - state:get("creative_button"):setVisible(has_creative) - if not has_creative then - state:get("crafting_button"):submit(nil, playername) + local page_state = smart_inventory.get_page_state("creative", playername) + if page_state then + local state = page_state.location.parentState + local has_creative = player_has_creative(state) + state:get("creative_button"):setVisible(has_creative) + if not has_creative then + state:get("crafting_button"):submit(nil, playername) + end + state:show() end - state:show() end end