local mortar_table_functions = simplecrafting_lib.generate_table_functions('mortar', {
   show_guides = false,
   alphabetize_items = true,}
)

local mortar_table_def = {
   description = 'Mortar & Pestle',
   drawtype = 'mesh',
   mesh = 'stations_mortar.obj',
   tiles = {'stations_mortar.png', 'stations_pestle.png'},
   sounds = default.node_sound_wood_defaults(),
   paramtype2 = 'facedir',
   paramtype = 'light',
   selection_box = {
      type = 'fixed',
      fixed = {-.4, -.5, -.4, .4, .1, .4},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.4, -.5, -.4, .4, .1, .4},
      },
   groups = {oddly_breakable_by_hand = 1, choppy=3},
   after_place_node = function(pos)
      local meta = minetest.get_meta(pos)
      meta:set_string('infotext', 'Mortar & Pestle')
   end,
}
for k, v in pairs(mortar_table_functions) do
   mortar_table_def[k] = v
end

minetest.register_node('stations:mortar', mortar_table_def)


local mortar_locked_functions = simplecrafting_lib.generate_table_functions('mortar', {
   show_guides = false,
   alphabetize_items = true,}
)

local mortar_locked_def = {
   description = 'Mortar & Pestle (locked)',
   drawtype = 'mesh',
   mesh = 'stations_mortar.obj',
   tiles = {'stations_mortar.png', 'stations_pestle.png'},
   sounds = default.node_sound_wood_defaults(),
   paramtype2 = 'facedir',
   paramtype = 'light',
   selection_box = {
      type = 'fixed',
      fixed = {-.4, -.5, -.4, .4, .1, .4},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.4, -.5, -.4, .4, .1, .4},
      },
   groups = {oddly_breakable_by_hand = 1, choppy=3},
   after_place_node = function(pos)
      local meta = minetest.get_meta(pos)
      meta:set_string('infotext', 'Mortar & Pestle (locked)')
   end,
}
for k, v in pairs(mortar_locked_functions) do
   mortar_locked_def[k] = v
end

minetest.register_node('stations:mortar_locked', mortar_locked_def)

local is_uninv = minetest.global_exists("unified_inventory") or false
if is_uninv then
   unified_inventory.register_craft_type("mortar", {
      description = "Mortar & Pestle",
      icon = 'stations_mortar_icon.png',
      width = 4,
      height = 2,
      uses_crafting_grid = false
   })
end
