From f79a9886c997544b583a9f25b19437d1af082f40 Mon Sep 17 00:00:00 2001 From: Oversword Date: Sun, 10 Oct 2021 01:33:14 +0100 Subject: [PATCH] Remove sorting API methods in favour of new access methods only --- api.lua | 35 +---------------------------------- init.lua | 2 -- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/api.lua b/api.lua index 834a634..644bbdb 100644 --- a/api.lua +++ b/api.lua @@ -223,7 +223,7 @@ function ui.register_craft(options) table.insert(ui.crafts_for.recipe[item_name],options) for _, callback in ipairs(ui.craft_registered_callbacks) do - callback(item_name) + callback(item_name, options) end end @@ -317,17 +317,6 @@ function ui.register_button(name, def) table.insert(ui.buttons, def) end -function ui.register_craft_sorter(method, item_name) - if type(method) ~= "function" then - error(("Craft sorter method must be a function, %s given."):format(type(method))) - end - if not (item_name == nil or type(item_name) == "string") then - error(("Craft sorter item name must be a string, %s given."):format(type(item_name))) - end - if item_name == nil then item_name = "_default_" end - ui.craft_sorters[item_name] = method -end - function ui.register_on_initialized(callback) if type(callback) ~= "function" then error(("Initialized callback must be a function, %s given."):format(type(callback))) @@ -354,28 +343,6 @@ function ui.get_registered_outputs() return outputs end -ui.register_on_initialized(function () - local outputs = ui.get_registered_outputs() - for _, item_name in ipairs(outputs) do - local craft_sorter = ui.craft_sorters[item_name] or ui.craft_sorters._default_ - if craft_sorter then - local recipes = ui.get_recipe_list(item_name) - table.sort(recipes, craft_sorter) - end - end - ui.crafts_sorted = true -end) - -ui.register_on_craft_registered(function (item_name) - if not ui.crafts_sorted then return end - - local craft_sorter = ui.craft_sorters[item_name] or ui.craft_sorters._default_ - if craft_sorter then - local recipes = ui.get_recipe_list(item_name) - table.sort(recipes, craft_sorter) - end -end) - function ui.is_creative(playername) return minetest.check_player_privs(playername, {creative=true}) or minetest.settings:get_bool("creative_mode") diff --git a/init.lua b/init.lua index af0f442..98ee2e5 100644 --- a/init.lua +++ b/init.lua @@ -24,8 +24,6 @@ unified_inventory = { filtered_items_list = {}, pages = {}, buttons = {}, - craft_sorters = {}, - crafts_sorted = false, initialized_callbacks = {}, craft_registered_callbacks = {},