-xdecor.register("workbench", {
- description = "Work Bench", infotext = "Work Bench",
- sounds = default.node_sound_wood_defaults(), groups = {snappy=3},
- tiles = {"xdecor_workbench_top.png", "xdecor_workbench_top.png",
- "xdecor_workbench_sides.png", "xdecor_workbench_sides.png",
- "xdecor_workbench_front.png", "xdecor_workbench_front.png"},
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string("formspec", "size[8,7;]"..fancy_gui..
- "label[0,0;Cut your wood into...]"..
- "label[0,1.5;Input]"..
- "list[current_name;input;0,2;1,1;]"..
- "image[1,2;1,1;xdecor_saw.png]"..
- "label[2,1.5;Output]"..
- "list[current_name;output;2,2;1,1;]"..
- "label[5.5,0;Damaged tool]"..
- "list[current_name;src;6,0.5;1,1;]"..
- "image[4.35,1.1;1.5,1.5;xdecor_hammer.png]"..
- "label[5.8,1.5;Hammer]]"..
- "list[current_name;fuel;6,2;1,1;]"..
- "item_image_button[0,0.5;1,1;xdecor:microslab_wood;microslab; ]"..
- "item_image_button[1,0.5;1,1;xdecor:microslab_half_wood;microslabhalf; ]"..
- "item_image_button[2,0.5;1,1;xdecor:microcube_wood;microcube; ]"..
- "item_image_button[3,0.5;1,1;xdecor:panel_wood;panel; ]"..
- "list[current_player;main;0,3.25;8,4;]")
- meta:set_string("infotext", "Work Bench")
- local inv = meta:get_inventory()
- inv:set_size("output", 1)
- inv:set_size("input", 1)
- inv:set_size("src", 1)
- inv:set_size("fuel", 1)
- end,
- on_receive_fields = function(pos, formname, fields, sender)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- local shape = {}
- local anz = 0
-
- if fields["microslab"] then
- anz = "8"
- shape = "xdecor:microslab_wood"
- elseif fields["microslabhalf"] then
- anz = "16"
- shape = "xdecor:microslab_half_wood"
- elseif fields["microcube"] then
- anz = "8"
- shape = "xdecor:microcube_wood"
- elseif fields["panel"] then
- anz = "4"
- shape = "xdecor:panel_wood"
- else return end
-
- local inputstack = inv:get_stack("input", 1)
- if (inputstack:get_name() == "default:wood") then
- local give = {}
- for i = 0, anz-1 do
- give[i+1] = inv:add_item("output", shape)
- end
- inputstack:take_item()
- inv:set_stack("input", 1, inputstack)
- else return end
- end,
- can_dig = function(pos, player)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- if not inv:is_empty("input")
- or not inv:is_empty("output")
- or not inv:is_empty("fuel")
- or not inv:is_empty("src") then
- return false end
- return true
+-- Nodes allowed to be cut.
+-- Only the regular, solid blocks without metas or explosivity can be cut.
+local nodes = {}
+for node, def in pairs(minetest.registered_nodes) do
+ if (def.drawtype == "normal" or def.drawtype:sub(1,5) == "glass") and
+ (def.groups.cracky or def.groups.choppy) and
+ not def.on_construct and
+ not def.after_place_node and
+ not def.on_rightclick and
+ not def.on_blast and
+ not def.allow_metadata_inventory_take and
+ not (def.groups.not_in_creative_inventory == 1) and
+ not def.groups.wool and
+ not def.description:find("Ore") and
+ def.description and
+ def.description ~= "" and
+ def.light_source == 0
+ then
+ nodes[#nodes+1] = node