From c7633ffd2029fea899a6156a01176b578ab4029b Mon Sep 17 00:00:00 2001 From: kilbith Date: Mon, 11 Jan 2016 19:51:02 +0100 Subject: [PATCH] Small simplifications --- cooking.lua | 4 ++-- enchanting.lua | 2 +- worktable.lua | 12 +++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cooking.lua b/cooking.lua index 5093abb..c35bcd0 100644 --- a/cooking.lua +++ b/cooking.lua @@ -111,7 +111,7 @@ minetest.register_abm({ minetest.register_abm({ nodenames = {"xdecor:cauldron_boiling_water"}, - interval = 3, chance = 1, + interval = 5, chance = 1, action = function(pos, node) local objs = minetest.get_objects_inside_radius(pos, 0.5) if not objs then return end @@ -124,7 +124,7 @@ minetest.register_abm({ for _, obj in pairs(objs) do if obj and obj:get_luaentity() then - local itemstring = obj:get_luaentity().itemstring:match(":([%w_]+)") + local itemstring = obj:get_luaentity().itemstring:match("[^:]+$") if not next(ingredients) then for _, rep in pairs(ingredients) do if itemstring == rep then return end diff --git a/enchanting.lua b/enchanting.lua index bfa4549..b6c10a5 100644 --- a/enchanting.lua +++ b/enchanting.lua @@ -83,7 +83,7 @@ local function allowed(tool) end function enchanting.put(_, listname, _, stack) - local item = stack:get_name():match(":([%w_]+)") + local item = stack:get_name():match("[^:]+$") if listname == "mese" and item == "mese_crystal" then return stack:get_count() elseif listname == "tool" and allowed(item) then diff --git a/worktable.lua b/worktable.lua index 83740e8..bd59cd7 100644 --- a/worktable.lua +++ b/worktable.lua @@ -34,17 +34,15 @@ local def = { -- Nodebox name, yield, definition. function worktable.get_recipe(item) if item:find("^group:") then if item:find("wool$") or item:find("dye$") then - item = item:match(":([%w_]+)")..":white" - elseif minetest.registered_items["default:"..item:match(":([%w_,]+)")] then + item = item:match("[^,:]+$")..":white" + elseif minetest.registered_items["default:"..item:match("[^,:]+$")] then item = item:gsub("group:", "default:") else for node, definition in pairs(minetest.registered_items) do - for group in pairs(definition.groups) do - if item:match(".*"..group.."$") then + if definition.groups[item:match("[^,:]+$")] then item = node end end - end end end return item @@ -274,9 +272,9 @@ function worktable.put(_, listname, _, stack) local stackname = stack:get_name() local mod, node = stackname:match("([%w_]+):([%w_]+)") - if (listname == "input" and worktable.contains(nodes[mod], node)) or + if (listname == "tool" and stack:get_wear() > 0 and stackname ~= "xdecor:hammer") or + (listname == "input" and worktable.contains(nodes[mod], node)) or (listname == "hammer" and stackname == "xdecor:hammer") or - (listname == "tool" and stack:get_wear() > 0) or listname == "storage" then return stack:get_count() end