diff --git a/src/workbench.lua b/src/workbench.lua index 908818b..c734f72 100644 --- a/src/workbench.lua +++ b/src/workbench.lua @@ -1,5 +1,6 @@ local workbench = {} local registered_cuttable_nodes = {} +local special_cuts = {} screwdriver = screwdriver or {} local min, ceil = math.min, math.ceil @@ -76,13 +77,23 @@ function workbench:get_output(inv, input, name) local extended = workbench:cuttable_extended(input:get_name()) for i = 1, #self.defs do local nbox = self.defs[i] + local cuttype = nbox[1] + local count = min(nbox[2] * input:get_count(), input:get_stack_max()) + local was_cut = false if extended or nbox[3] == nil then - local count = min(nbox[2] * input:get_count(), input:get_stack_max()) - local item = name .. "_" .. nbox[1] + local item = name .. "_" .. cuttype - item = nbox[3] and item or "stairs:" .. nbox[1] .. "_" .. name:match(":(.*)") + item = nbox[3] and item or "stairs:" .. cuttype .. "_" .. name:match(":(.*)") if minetest.registered_items[item] then output[i] = item .. " " .. count + was_cut = true + end + end + if not was_cut and special_cuts[input:get_name()] ~= nil then + local cut = special_cuts[input:get_name()][cuttype] + if cut then + output[i] = cut .. " " .. count + was_cut = true end end end @@ -90,6 +101,11 @@ function workbench:get_output(inv, input, name) inv:set_list("forms", output) end +function workbench:register_special_cut(nodename, cutlist) + registered_cuttable_nodes[nodename] = true + special_cuts[nodename] = cutlist +end + local main_fs = "label[0.9,1.23;"..FS("Cut").."]" .."label[0.9,2.23;"..FS("Repair").."]" ..[[ box[-0.05,1;2.05,0.9;#555555] @@ -453,3 +469,7 @@ minetest.register_craft({ {"group:wood", "group:wood"} } }) + +-- Special cuts for cushion block and cabinet +workbench:register_special_cut("xdecor:cushion_block", { slab = "xdecor:cushion" }) +workbench:register_special_cut("xdecor:cabinet", { slab = "xdecor:cabinet_half" })