From a9f74339656ad0f2c3c63c0b17baa16f9ff8d8bd Mon Sep 17 00:00:00 2001 From: kilbith Date: Thu, 14 Jan 2016 23:29:31 +0100 Subject: [PATCH] Craft guide : remember tab id on clearing filter --- enchanting.lua | 4 +--- worktable.lua | 15 ++++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/enchanting.lua b/enchanting.lua index df7961d..4822c1a 100644 --- a/enchanting.lua +++ b/enchanting.lua @@ -75,9 +75,7 @@ end local function allowed(tool) for item in pairs(minetest.registered_tools) do - if item:match("enchanted_"..tool) then - return true - end + if item:match("enchanted_"..tool) then return true end end return false end diff --git a/worktable.lua b/worktable.lua index 8b3643c..4a44b59 100644 --- a/worktable.lua +++ b/worktable.lua @@ -227,8 +227,8 @@ function worktable.fields(pos, _, fields) elseif fields.storage then worktable.formspecs.storage(meta) elseif fields.craftguide or fields.clearfilter then - worktable.craftguide_main_list(meta, nil, 1) - worktable.craftguide_formspec(meta, 1, nil, 1, "", 1) + worktable.craftguide_main_list(meta, nil, tab_id) + worktable.craftguide_formspec(meta, 1, nil, 1, "", tab_id) elseif fields.alternate then local item = formspec:match("item_image%[.*;([%w_:]+)%]") or "" local recipe_num = tonumber(formspec:match("Recipe%s(%d+)")) or 1 @@ -262,13 +262,10 @@ function worktable.dig(pos) inv:is_empty("tool") and inv:is_empty("storage") end -function worktable.allowed(table, element) - if table then - for _, value in pairs(table) do - if value == element then - return true - end - end +function worktable.allowed(mod, node) + if not mod then return end + for _, it in pairs(mod) do + if it == node then return true end end return false end