local food_prep_table_functions = simplecrafting_lib.generate_table_functions('food_prep', {
   show_guides = true,
   alphabetize_items = true,}
)

local food_prep_table_def = {
   description = 'Food Prep',
   drawtype = 'mesh',
   mesh = 'stations_food_prep.obj',
   tiles = {'stations_food_prep.png'},
   use_texture_alpha = 'opaque',
   sounds = default.node_sound_wood_defaults(),
   paramtype2 = 'facedir',
   paramtype = 'light',
   selection_box = {
      type = 'fixed',
      fixed = {-.4, -.5, -.4, 1.4, -.2, .4},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.4, -.5, -.4, 1.4, -.2, .4},
      },
   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', 'Food Prep')
   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(food_prep_table_functions) do
   food_prep_table_def[k] = v
end

minetest.register_node('stations:food_prep', food_prep_table_def)


local food_prep_locked_functions = simplecrafting_lib.generate_table_functions('food_prep', {
   show_guides = true,
   alphabetize_items = true,
   protect_inventory = true,}
)

local food_prep_locked_def = {
   description = 'Food Prep (locked)',
   drawtype = 'mesh',
   mesh = 'stations_food_prep.obj',
   tiles = {'stations_food_prep.png'},
   use_texture_alpha = 'opaque',
   sounds = default.node_sound_wood_defaults(),
   paramtype2 = 'facedir',
   paramtype = 'light',
   selection_box = {
      type = 'fixed',
      fixed = {-.4, -.5, -.4, 1.4, -.2, .4},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.4, -.5, -.4, 1.4, -.2, .4},
      },
   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', 'Food Prep (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(food_prep_locked_functions) do
   food_prep_locked_def[k] = v
end

minetest.register_node('stations:food_prep_locked', food_prep_locked_def)

local is_uninv = minetest.global_exists("unified_inventory") or false
if is_uninv then
   unified_inventory.register_craft_type("food_prep", {
      description = "Food Prep",
      icon = 'stations_food_prep_icon.png',
      width = 4,
      height = 2,
      uses_crafting_grid = false
   })
end
