From 9ab92ba0566a339a34bdecadb0f2ff7dff30d3e9 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Fri, 7 May 2021 03:16:11 +0200 Subject: [PATCH] *Really* disable sfinv --- .luacheckrc | 3 ++- init.lua | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index e767495..5840689 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -6,7 +6,6 @@ ignore = { read_globals = { "minetest", - "default", "armor", "skins", "awards", @@ -19,4 +18,6 @@ read_globals = { globals = { "i3", "core", + "sfinv", + "unified_inventory", } diff --git a/init.lua b/init.lua index 824742d..2a59dae 100644 --- a/init.lua +++ b/init.lua @@ -16,7 +16,8 @@ local progressive_mode = core.settings:get_bool "i3_progressive_mode" local damage_enabled = core.settings:get_bool "enable_damage" local __3darmor, __skinsdb, __awards -local sfinv, unified_inventory, old_unified_inventory_fn +local __sfinv, old_sfinv_fn +local __unified_inventory, old_unified_inventory_fn local http = core.request_http_api() local singleplayer = core.is_singleplayer() @@ -2948,15 +2949,17 @@ end on_mods_loaded(function() get_init_items() - sfinv = rawget(_G, "sfinv") + __sfinv = rawget(_G, "sfinv") - if sfinv then + if __sfinv then + old_sfinv_fn = sfinv.set_player_inventory_formspec + function sfinv.set_player_inventory_formspec() return end sfinv.enabled = false end - unified_inventory = rawget(_G, "unified_inventory") + __unified_inventory = rawget(_G, "unified_inventory") - if unified_inventory then + if __unified_inventory then old_unified_inventory_fn = unified_inventory.set_inventory_formspec function unified_inventory.set_inventory_formspec() return end end @@ -3038,14 +3041,15 @@ on_joinplayer(function(player) local info = get_player_info(name) if get_formspec_version(info) < MIN_FORMSPEC_VERSION then - if sfinv then + if __sfinv then + sfinv.set_player_inventory_formspec = old_sfinv_fn sfinv.enabled = true end - if unified_inventory then + if __unified_inventory then unified_inventory.set_inventory_formspec = old_unified_inventory_fn - if sfinv then + if __sfinv then sfinv.enabled = false end end