From 6cf900f31d0360c23889509262a9168ae4dc9ba6 Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Thu, 27 Aug 2020 16:59:14 +0200 Subject: [PATCH] modernize mods with some small adjustments --- creative_maxstack/depends.txt | 1 - creative_maxstack/mod.conf | 4 ++++ sfinv_buttons/API.md | 14 ++++++++++++ sfinv_buttons/depends.txt | 2 -- sfinv_buttons/init.lua | 6 ++--- sfinv_buttons/mod.conf | 3 +++ smart_sfinv_api/API.md | 24 ++++++++++++++++++++ smart_sfinv_api/depends.txt | 1 - smart_sfinv_api/init.lua | 29 ++++++------------------ smart_sfinv_api/mod.conf | 3 +++ smart_sfinv_creative_bymod/depends.txt | 1 - smart_sfinv_creative_bymod/mapping.lua | 4 +++- smart_sfinv_creative_bymod/mod.conf | 3 +++ smart_sfinv_creative_sitebar/depends.txt | 1 - smart_sfinv_creative_sitebar/mod.conf | 3 +++ smart_sfinv_tweaks/depends.txt | 2 -- smart_sfinv_tweaks/mod.conf | 3 +++ 17 files changed, 70 insertions(+), 34 deletions(-) delete mode 100644 creative_maxstack/depends.txt create mode 100644 creative_maxstack/mod.conf create mode 100644 sfinv_buttons/API.md delete mode 100644 sfinv_buttons/depends.txt create mode 100644 sfinv_buttons/mod.conf create mode 100644 smart_sfinv_api/API.md delete mode 100644 smart_sfinv_api/depends.txt create mode 100644 smart_sfinv_api/mod.conf delete mode 100644 smart_sfinv_creative_bymod/depends.txt create mode 100644 smart_sfinv_creative_bymod/mod.conf delete mode 100644 smart_sfinv_creative_sitebar/depends.txt create mode 100644 smart_sfinv_creative_sitebar/mod.conf delete mode 100644 smart_sfinv_tweaks/depends.txt create mode 100644 smart_sfinv_tweaks/mod.conf diff --git a/creative_maxstack/depends.txt b/creative_maxstack/depends.txt deleted file mode 100644 index c327490..0000000 --- a/creative_maxstack/depends.txt +++ /dev/null @@ -1 +0,0 @@ -creative diff --git a/creative_maxstack/mod.conf b/creative_maxstack/mod.conf new file mode 100644 index 0000000..a4e1f46 --- /dev/null +++ b/creative_maxstack/mod.conf @@ -0,0 +1,4 @@ +name = creative_maxstack +description = Set all items to max stack size in creative inventory +depends = creative + diff --git a/sfinv_buttons/API.md b/sfinv_buttons/API.md new file mode 100644 index 0000000..7d86d85 --- /dev/null +++ b/sfinv_buttons/API.md @@ -0,0 +1,14 @@ +New buttons can be registered using the next API call +``` +sfinv_buttons.register_button(button_name, { + -- mandatory + image = Texture file shown on button + action = function(player, context, content, show_inv). Called if button is pressed + + -- optional + title = Text shown in Tooltip (part 1) + tooltip = Text shown in Tooltip (Part 2) + position = Number. If given the mod try to place the button to this position + show = function(player, context, content, show_inv). Allow show or hide button dynamically +}) +``` diff --git a/sfinv_buttons/depends.txt b/sfinv_buttons/depends.txt deleted file mode 100644 index 1b60254..0000000 --- a/sfinv_buttons/depends.txt +++ /dev/null @@ -1,2 +0,0 @@ -smart_sfinv_api -intllib? diff --git a/sfinv_buttons/init.lua b/sfinv_buttons/init.lua index 142fc13..4628575 100644 --- a/sfinv_buttons/init.lua +++ b/sfinv_buttons/init.lua @@ -47,7 +47,7 @@ smart_sfinv_api.register_enhancement({ local retval = "" for idx = 1, last_button do - def = sfinv_buttons.registered_buttons[idx] + local def = sfinv_buttons.registered_buttons[idx] local x = 8.1 + math.floor(idx / sfinv_buttons.MAX_ROWS) local y = (idx - 1) % sfinv_buttons.MAX_ROWS @@ -85,9 +85,9 @@ smart_sfinv_api.register_enhancement({ local player_name = player:get_player_name() local button_prefix_len = button_prefix:len() for idx = 1, last_button do - def = sfinv_buttons.registered_buttons[idx] + local def = sfinv_buttons.registered_buttons[idx] if def and fields[def.button_name] and def.action then - def.action(player) + def.action(player, context, content, show_inv) break end end diff --git a/sfinv_buttons/mod.conf b/sfinv_buttons/mod.conf new file mode 100644 index 0000000..abb4d4b --- /dev/null +++ b/sfinv_buttons/mod.conf @@ -0,0 +1,3 @@ +name = sfinv_buttons +description = Allow additional buttons in sfinv inventory on the right site +depends = smart_sfinv_api diff --git a/smart_sfinv_api/API.md b/smart_sfinv_api/API.md new file mode 100644 index 0000000..550a03b --- /dev/null +++ b/smart_sfinv_api/API.md @@ -0,0 +1,24 @@ +Smart inventory can be enhanced using the API call + +``` +smart_sfinv_api.register_enhancement(enhancement_def) +``` +enhancement_def is a lua table that contains the next values: + +Methods: + - make_formspec(enhancement_def, player, context, content, show_inv) - Allow to modify page formspec in context + - get_nav_fs(enhancement_def, player, context, nav, current_idx) - Allow to modify shown tabs (in nav table) before sfinv creates tab header + - receive_fields(handler, player, context, fields) - Receive fields processing for new elements in enhancement + +Method does set Attributes: + - enh.formspec_size - Overrides the default size (size[8,9.1]) + - enh.formspec_size_add_w - Overssides the defaults size - additional with + - enh.formspec_size_add_h - Overssides the defaults size - additional height + - enh.theme_main - Theme - Additional formspec appended at begin of sfinv formspec + + - enh.formspec_before_navfs - Additional formspec string appended before get_nav_fs tab header + - enh.custom_nav_fs - Custom formspec replaces the get_nav_fs tab header + - enh.formspec_after_navfs - Additional formspec string appended after get_nav_fs tab header and before content + - enh.formspec_after_content - Additional formspec string appended after content + - enh.theme_inv - Additional formspec string appended before player inventory is shown +}) diff --git a/smart_sfinv_api/depends.txt b/smart_sfinv_api/depends.txt deleted file mode 100644 index e354eb3..0000000 --- a/smart_sfinv_api/depends.txt +++ /dev/null @@ -1 +0,0 @@ -sfinv diff --git a/smart_sfinv_api/init.lua b/smart_sfinv_api/init.lua index 8711025..4969d74 100644 --- a/smart_sfinv_api/init.lua +++ b/smart_sfinv_api/init.lua @@ -20,8 +20,8 @@ Method does set Attributes: - enh.formspec_before_navfs - enh.formspec_after_navfs - enh.formspec_after_content - - theme_main - Theme - - theme_inv - Player inventory fields + - enh.theme_main - Theme + - enh.theme_inv - Player inventory fields - enh.custom_nav_fs - if set, default is skipped ]] @@ -110,7 +110,7 @@ function sfinv.make_formspec(player, context, content, show_inv, size) end - local tmp = enh_handler_class.patch_2275 and { + local tmp = { new_size or handler.formspec_size, handler.theme_main, handler.formspec_before_navfs, @@ -119,17 +119,7 @@ function sfinv.make_formspec(player, context, content, show_inv, size) show_inv and handler.theme_inv or "", content, handler.formspec_after_content - } or { -- can be removed if patch_2275 merged to upstream - new_size or handler.formspec_size, - handler.theme_main, - handler.formspec_before_navfs, - nav_fs, - handler.formspec_after_navfs, - content, - show_inv and handler.theme_inv or "", - handler.formspec_after_content } - return table.concat(tmp, "") end @@ -154,13 +144,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) ----------------------------------------------- --- Initialization: hacky access to some default variables ----------------------------------------------- +----------------------------------------------- +--- 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.,]+%]*)([^|]*)|([^|]*)") -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 +enh_handler_class.formspec_size, enh_handler_class.theme_inv, enh_handler_class.theme_main = _dummy_page:match("(size%[[%d.,]+%]*)([^|]*)|([^|]*)") diff --git a/smart_sfinv_api/mod.conf b/smart_sfinv_api/mod.conf new file mode 100644 index 0000000..9db349a --- /dev/null +++ b/smart_sfinv_api/mod.conf @@ -0,0 +1,3 @@ +name = smart_sfinv_api +description = Smart Enhancements API for sfinv inventory +depends = sfinv diff --git a/smart_sfinv_creative_bymod/depends.txt b/smart_sfinv_creative_bymod/depends.txt deleted file mode 100644 index c327490..0000000 --- a/smart_sfinv_creative_bymod/depends.txt +++ /dev/null @@ -1 +0,0 @@ -creative diff --git a/smart_sfinv_creative_bymod/mapping.lua b/smart_sfinv_creative_bymod/mapping.lua index 6ea2a71..0f9757b 100644 --- a/smart_sfinv_creative_bymod/mapping.lua +++ b/smart_sfinv_creative_bymod/mapping.lua @@ -47,7 +47,9 @@ return { maidroid_core = 'maidroid', maidroid_tool = 'maidroid', - shields = '3d_armor', + ["3d_armor"] = 'armor', + shields = 'armor', + armor_addon = 'armor', }, by_group = { -- Order all stairs and slabs to the stairs group diff --git a/smart_sfinv_creative_bymod/mod.conf b/smart_sfinv_creative_bymod/mod.conf new file mode 100644 index 0000000..0bc6b0d --- /dev/null +++ b/smart_sfinv_creative_bymod/mod.conf @@ -0,0 +1,3 @@ +name = smart_sfinv_creative_bymod +description = Split creative page to multiple pages by mod instead of "nodes","items","tools" +depends = creative diff --git a/smart_sfinv_creative_sitebar/depends.txt b/smart_sfinv_creative_sitebar/depends.txt deleted file mode 100644 index 8619dff..0000000 --- a/smart_sfinv_creative_sitebar/depends.txt +++ /dev/null @@ -1 +0,0 @@ -smart_sfinv_api diff --git a/smart_sfinv_creative_sitebar/mod.conf b/smart_sfinv_creative_sitebar/mod.conf new file mode 100644 index 0000000..23d2674 --- /dev/null +++ b/smart_sfinv_creative_sitebar/mod.conf @@ -0,0 +1,3 @@ +name = smart_sfinv_creative_sitebar +description = Unify creative pages to one, add grouping to site bar on the left site +depends = smart_sfinv_api diff --git a/smart_sfinv_tweaks/depends.txt b/smart_sfinv_tweaks/depends.txt deleted file mode 100644 index 711d60c..0000000 --- a/smart_sfinv_tweaks/depends.txt +++ /dev/null @@ -1,2 +0,0 @@ -smart_sfinv_api -sfinv_buttons diff --git a/smart_sfinv_tweaks/mod.conf b/smart_sfinv_tweaks/mod.conf new file mode 100644 index 0000000..5716451 --- /dev/null +++ b/smart_sfinv_tweaks/mod.conf @@ -0,0 +1,3 @@ +name = smart_sfinv_tweaks +description = Adds additional inventory related buttons +depends = smart_sfinv_api, sfinv_buttons