spawn = {}
spawn.storage = minetest.get_mod_storage()

dofile(minetest.get_modpath('spawn')..'/news.lua')
dofile(minetest.get_modpath('spawn')..'/rules.lua')
dofile(minetest.get_modpath('spawn')..'/commands.lua')
dofile(minetest.get_modpath('spawn')..'/temp_info.lua')

minetest.register_node('spawn:quartz_pillar', {
   description = 'Quartz Pillar',
   tiles = {'spawn_quartz_top.png', 'spawn_quartz_top.png','spawn_quartz_side.png'},
   paramtype2 = 'facedir',
   on_place = minetest.rotate_node,
   sounds = default.node_sound_stone_defaults(),
   groups = {not_in_creative_inventory=1}
})

minetest.register_node('spawn:quartz_pillar_slab', {
   description = 'Quartz Pillar Slab',
   drawtype = 'nodebox',
   tiles = {'spawn_quartz_top.png', 'spawn_quartz_top.png','spawn_quartz_side.png'},
   paramtype2 = 'facedir',
   node_box = {
         type = 'fixed',
         fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
      },
   on_place = minetest.rotate_node,
   sounds = default.node_sound_stone_defaults(),
   groups = {not_in_creative_inventory=1}
})

minetest.register_node('spawn:quartz1_pillar_slab', {
   description = 'Quartz Pillar Slab',
   drawtype = 'nodebox',
   tiles = {{name='spawn_quartz1.png', align_style='world', scale=4}},
   paramtype2 = 'facedir',
   node_box = {
         type = 'fixed',
         fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
      },
   on_place = minetest.rotate_node,
   sounds = default.node_sound_stone_defaults(),
   groups = {not_in_creative_inventory=1}
})

local nodes = { --name, desc,
   {'stone', 'Tiled Stone'},
   {'basalt', 'Basalt'},
   {'quartz1', 'Quartz1'},
   {'quartz2', 'Quartz2'},
   {'brick', 'Brick'},
   {'bridge', 'Bridge'},
   {'path', 'Path'},
   {'brown_concrete', 'Brown Concrete'},
   {'black_concrete', 'Black Concrete'},
}

for i in ipairs (nodes) do
   local name = nodes[i][1]
   local desc = nodes[i][2]

   minetest.register_node('spawn:'..name, {
      description = desc,
      tiles = {{name='spawn_'..name..'.png', align_style='world', scale=4}},
      inventory_image = '[inventorycube{spawn_'..name..'.png&[sheet:4x4:1,1{spawn_'..name..'.png&[sheet:4x4:1,1{spawn_'..name..'.png&[sheet:4x4:1,1',
      sounds = default.node_sound_stone_defaults(),
      groups = {not_in_creative_inventory=1}
   })
end

minetest.register_node('spawn:path', {
   description = 'Path',
   tiles = {{name='spawn_path.png', align_style='world', scale=4}},
   inventory_image = '[inventorycube{spawn_path.png&[sheet:4x4:1,1{spawn_path.png&[sheet:4x4:1,1{spawn_path.png&[sheet:4x4:1,1',
   sounds = default.node_sound_stone_defaults(),
   groups = {crumbly = 2},
})

minetest.register_craft({
   output = 'spawn:path 2',
   recipe = {
      {'epic:scorched_dirt', 'epic:scorched_dirt'}
   }
})

minetest.register_node('spawn:andesite', {
   description = 'Andesite',
   tiles = {'spawn_andesite.png',},
   sounds = default.node_sound_stone_defaults(),
   groups = {not_in_creative_inventory=1}
})

---Mesh Nodes
minetest.register_node('spawn:sign', {
   description = 'Exit Sign',
   drawtype = 'mesh',
   mesh = 'spawn_sign.obj',
   tiles = {'spawn_sign.png'},
   paramtype = 'light',
   paramtype2 = 'facedir',
   selection_box = {
      type = 'fixed',
      fixed = {-.44, -.1, -.1, .44, .5, .1},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.44, -.1, -.1, .44, .5, .1},
      },
   groups = {oddly_breakable_by_hand = 1, not_in_creative_inventory=1},
})

minetest.register_node('spawn:poster1', {
   description = 'Rules Poster',
   drawtype = 'mesh',
   mesh = 'spawn_poster.obj',
   tiles = {'spawn_poster_rules.png'},
   paramtype = 'light',
   paramtype2 = 'facedir',
   groups = {not_in_creative_inventory=1},
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, .4, .5, .5, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, .4, .5, .5, .5},
      },
   on_rightclick = function(pos)
      local meta = minetest.get_meta(pos)
      meta:set_string('infotext', 'Rules')
      meta:set_string('formspec', spawn_rules_formspec)
   end,
})

minetest.register_node('spawn:poster2', {
   description = 'News Poster',
   drawtype = 'mesh',
   mesh = 'spawn_poster.obj',
   tiles = {'spawn_poster_news.png'},
   paramtype = 'light',
   paramtype2 = 'facedir',
   groups = {not_in_creative_inventory=1},
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, .4, .5, .5, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, .4, .5, .5, .5},
      },
   on_rightclick = function(pos)
      local meta = minetest.get_meta(pos)
      meta:set_string('infotext', 'News')
      meta:set_string('formspec', spawn_news_formspec)
   end,
})
