levels = {}

function levels.register_basic(name, desc, sound, nodes, vol, group) --Registers node, stairs, slabs. With same texture on all sides.
   vol = vol or 1
   nodes = nodes or 2
   local new_groups
   if not group then
      new_groups = {breakable = 1}
   else
      new_groups = table.copy(group)
      new_groups.breakable = 1
   end


   --local new_groups = table.copy(groups)
   --new_groups.stair = 1

   minetest.register_node('levels:'..name, {
      description = desc,
      tiles = {{name='levels_'..name..'.png', align_style='world', scale=4}},
      inventory_image = '[inventorycube{levels_'..name..'.png&[sheet:4x4:1,1{levels_'..name..'.png&[sheet:4x4:1,1{levels_'..name..'.png&[sheet:4x4:1,1',
      groups = new_groups,
      sounds = {footstep = {name = sound, gain = vol}}
   })

   if nodes == 2 then
      stairs.register_stair_and_slab(name,
         {breakable=1},
         {{name='levels_'..name..'.png', align_style='world', scale=4}},
         {footstep = {name = sound, gain = vol}},
         true)
   elseif nodes == 1 then
      stairs.register_slab(name,
         {breakable=1},
         {{name='levels_'..name..'.png', align_style='world', scale=4}},
         {footstep = {name = sound, gain = vol}},
         true)
   end
end

function levels.register_tube(name, desc, sound, nodes, vol) --Registers node, stairs, slabs. With one texture on top and bottom, and one on all sides.
   vol = vol or 1
   nodes = nodes or 2
   minetest.register_node('levels:'..name, {
      description = desc,
      tiles = {'levels_'..name..'_top.png', 'levels_'..name..'_top.png', 'levels_'..name..'_side.png'},
      groups = {breakable=1},
      sounds = {footstep = {name = sound, gain = vol}},
      paramtype2 = 'facedir',
      on_place = minetest.rotate_and_place,
   })

   if nodes == 2 then
      stairs.register_stair_and_slab(name,
         {breakable=1},
         {'levels_'..name..'_top.png', 'levels_'..name..'_top.png', 'levels_'..name..'_side.png'},
         {footstep = {name = sound, gain = vol}},
         true)
   elseif nodes == 1 then
      stairs.register_slab(name,
         {breakable=1},
         {'levels_'..name..'_top.png', 'levels_'..name..'_top.png', 'levels_'..name..'_side.png'},
         {footstep = {name = sound, gain = vol}},
         true)
   end
end

function levels.register_alpha(name, desc, sound, vol)
   vol = vol or 1
   minetest.register_node('levels:'..name, {
      description = desc,
      drawtype = 'allfaces',
      paramtype = 'light',
      tiles = {{name='levels_'..name..'.png', align_style='world', scale=4}},
      inventory_image = '[inventorycube{levels_'..name..'.png&[sheet:4x4:1,1{levels_'..name..'.png&[sheet:4x4:1,1{levels_'..name..'.png&[sheet:4x4:1,1',
      groups = {breakable=1},
      sounds = {footstep = {name = sound, gain = vol}},
   })

end

dofile(minetest.get_modpath('levels')..'/animated.lua')
dofile(minetest.get_modpath('levels')..'/borders.lua')
dofile(minetest.get_modpath('levels')..'/ducts.lua')
dofile(minetest.get_modpath('levels')..'/glass.lua')
dofile(minetest.get_modpath('levels')..'/ground.lua')
dofile(minetest.get_modpath('levels')..'/metal.lua')
dofile(minetest.get_modpath('levels')..'/misc.lua')
dofile(minetest.get_modpath('levels')..'/scifi.lua')
dofile(minetest.get_modpath('levels')..'/specials.lua')
dofile(minetest.get_modpath('levels')..'/stone.lua')
dofile(minetest.get_modpath('levels')..'/tiles.lua')
dofile(minetest.get_modpath('levels')..'/wood.lua')
