local sewing_table_functions = simplecrafting_lib.generate_table_functions('sewing', {
   show_guides = true,
   alphabetize_items = true,}
)

local sewing_table_def = {
   description = 'Sewing Station',
   drawtype = 'mesh',
   mesh = 'stations_sewing.obj',
   tiles = {'stations_sewing.png'},
   use_texture_alpha = 'opaque',
   sounds = default.node_sound_wood_defaults(),
   paramtype2 = 'facedir',
   paramtype = 'light',
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, 1.5, .3, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, 1.5, .3, .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
      else
         local meta = minetest.get_meta(pos)
         meta:set_string('infotext', 'Sewing Station')
      end
   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(sewing_table_functions) do
   sewing_table_def[k] = v
end

minetest.register_node('stations:sewing', sewing_table_def)


local sewing_locked_functions = simplecrafting_lib.generate_table_functions('sewing', {
   show_guides = true,
   alphabetize_items = true,
   protect_inventory = true,}
)

local sewing_locked_def = {
   description = 'Sewing Station (locked)',
   drawtype = 'mesh',
   mesh = 'stations_sewing.obj',
   tiles = {'stations_sewing.png'},
   use_texture_alpha = 'opaque',
   sounds = default.node_sound_wood_defaults(),
   paramtype2 = 'facedir',
   paramtype = 'light',
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, 1.5, .3, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, 1.5, .3, .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
      else
         local meta = minetest.get_meta(pos)
         meta:set_string('infotext', 'Sewing Station (locked)')
      end
   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(sewing_locked_functions) do
   sewing_locked_def[k] = v
end

minetest.register_node('stations:sewing_locked', sewing_locked_def)

unified_inventory.register_craft_type("sewing", {
   description = "Sewing Station",
   icon = 'stations_sewing_icon.png',
   width = 4,
   height = 2,
   uses_crafting_grid = false
})
