local woodworking_table_functions = simplecrafting_lib.generate_table_functions('woodworking', {
   show_guides = true,
   alphabetize_items = true,})

local woodworking_table_def = {
   description = 'Woodworking Station',
   drawtype = 'mesh',
   mesh = 'stations_woodworking.obj',
   tiles = {'stations_woodworking.png'},
   sounds = default.node_sound_wood_defaults(),
   paramtype2 = 'facedir',
   paramtype = 'light',
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, 1.5, .5, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, 1.5, .5, .5},
      },
   groups = {oddly_breakable_by_hand = 1, choppy=3},
   after_place_node = function(pos, placer, itemstack)
      if not epic.space_to_side(pos) then
         minetest.remove_node(pos)
         return itemstack
      end
      local meta = minetest.get_meta(pos)
      meta:set_string('infotext', 'Woodworking Station')
   end,
   after_dig_node = function(pos, oldnode, oldmetadata, digger)
      epic.remove_side_node(pos, oldnode)
   end,
   on_rotate = function(pos, node)
      return false
   end,
}
for k, v in pairs(woodworking_table_functions) do
   woodworking_table_def[k] = v
end

minetest.register_node('stations:woodworking', woodworking_table_def)


local woodworking_locked_functions = simplecrafting_lib.generate_table_functions('woodworking', {
   show_guides = true,
   alphabetize_items = true,
   protect_inventory = true})

local woodworking_locked_def = {
   description = 'Woodworking Station (locked)',
   drawtype = 'mesh',
   mesh = 'stations_woodworking.obj',
   tiles = {'stations_woodworking.png'},
   sounds = default.node_sound_wood_defaults(),
   paramtype2 = 'facedir',
   paramtype = 'light',
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, 1.5, .5, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, 1.5, .5, .5},
      },
   groups = {oddly_breakable_by_hand = 1, choppy=3},
   after_place_node = function(pos, placer, itemstack)
      if not epic.space_to_side(pos) then
         minetest.remove_node(pos)
         return itemstack
      end
      local meta = minetest.get_meta(pos)
      meta:set_string('infotext', 'Woodworking Station (locked)')
   end,
   after_dig_node = function(pos, oldnode, oldmetadata, digger)
      epic.remove_side_node(pos, oldnode)
   end,
   on_rotate = function(pos, node)
      return false
   end,
}
for k, v in pairs(woodworking_locked_functions) do
   woodworking_locked_def[k] = v
end

minetest.register_node('stations:woodworking_locked', woodworking_locked_def)

local is_uninv = minetest.global_exists("unified_inventory") or false
if is_uninv then
   unified_inventory.register_craft_type("woodworking", {
      description = "Woodworking Station",
      icon = 'stations_woodworking_icon.png',
      width = 4,
      height = 2,
      uses_crafting_grid = false
   })
end
