From dd298406ea33bf4e9df0d82de166d87cab37d469 Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Wed, 19 Dec 2018 18:43:09 +0100 Subject: [PATCH] get mt-0.5 ready --- smart_sfinv_api/init.lua | 19 +++++++++++++++++-- smart_sfinv_creative_sitebar/init.lua | 2 +- smart_sfinv_tweaks/init.lua | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/smart_sfinv_api/init.lua b/smart_sfinv_api/init.lua index cdaa89b..29df883 100644 --- a/smart_sfinv_api/init.lua +++ b/smart_sfinv_api/init.lua @@ -88,7 +88,16 @@ function sfinv.make_formspec(player, context, content, show_inv, size) handler:run_enhancements("make_formspec", player, context, content, show_inv) - local tmp = { + local tmp = enh_handler_class.patch_2275 and { + handler.formspec_size, + handler.theme_main, + handler.formspec_before_navfs, + nav_fs, + handler.formspec_after_navfs, + show_inv and handler.theme_inv or "", + content, + handler.formspec_after_content + } or { -- can be removed if patch_2275 merged to upstream handler.formspec_size, handler.theme_main, handler.formspec_before_navfs, @@ -98,6 +107,7 @@ function sfinv.make_formspec(player, context, content, show_inv, size) show_inv and handler.theme_inv or "", handler.formspec_after_content } + return table.concat(tmp, "") end @@ -126,4 +136,9 @@ end) -- Initialization: hacky access to some default variables ---------------------------------------------- local _dummy_page = orig_make_formspec(nil, {}, "|", true, nil) -enh_handler_class.formspec_size, enh_handler_class.theme_main, enh_handler_class.theme_inv = _dummy_page:match("(size%[[%d.,]+%]+)([^|]+)|([^|]+)") +enh_handler_class.formspec_size, enh_handler_class.theme_main, enh_handler_class.theme_inv = _dummy_page:match("(size%[[%d.,]+%]*)([^|]*)|([^|]*)") +if enh_handler_class.theme_inv == "" then -- Support for https://github.com/minetest/minetest_game/pull/2275 + enh_handler_class.patch_2275 = true + enh_handler_class.theme_inv = enh_handler_class.theme_main + enh_handler_class.theme_main = "" +end diff --git a/smart_sfinv_creative_sitebar/init.lua b/smart_sfinv_creative_sitebar/init.lua index 2b3a8e2..1e96b22 100644 --- a/smart_sfinv_creative_sitebar/init.lua +++ b/smart_sfinv_creative_sitebar/init.lua @@ -38,7 +38,7 @@ smart_sfinv_api.register_enhancement({ if current_idx_above == -1 then current_idx_above = 2 -- Creative handler.formspec_before_navfs = "textlist[0,0;2.8,8.6;smart_sfinv_nav_site;" .. table.concat(nav_titles_site, ",") .. - ";" .. context.current_idx_site .. ";true]container[3.5,0]"..handler.formspec_before_navfs + ";" .. context.current_idx_site .. ";true]container[3,0]"..handler.formspec_before_navfs handler.formspec_after_content = handler.formspec_after_content.."container_end[]" handler.formspec_size = 'size[11,8.6]' elseif current_idx_above >= 2 then diff --git a/smart_sfinv_tweaks/init.lua b/smart_sfinv_tweaks/init.lua index 1f2387c..fab66d1 100644 --- a/smart_sfinv_tweaks/init.lua +++ b/smart_sfinv_tweaks/init.lua @@ -7,7 +7,7 @@ smart_sfinv_api.defaults.theme_inv = smart_sfinv_api.defaults.theme_inv .. 'tooltip[sfinv_tweaks_rotate;Rotate rows]' -local crafting_enhance = 'image_button[0.5,1.6;0.8,0.8;smart_sfinv_tweaks_sweep_button.png;sfinv_tweaks_sweep;]' .. +local crafting_enhance = 'image_button[0.5,1.6;0.8,0.8;smart_sfinv_tweaks_sweep_button.png;sfinv_tweaks_sweep;]' .. 'tooltip[sfinv_tweaks_sweep;Sweep crafting area]' smart_sfinv_api.register_enhancement({