local cbox_full = {
		type = "fixed",
		fixed = {
			{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
		}
	}

local cbox_pinstripe = {
		type = "fixed",
		fixed = {
			{-0.125, -0.5, -0.5, 0.125, -0.49, 0.5},
		}
	}

local cbox_pinstripe_45 = {
		type = "fixed",
		fixed = {
			{-0.125, -0.5, 0.4375, 0.1875, -0.49, 0.5},
			{-0.0625, -0.5, 0.375, 0.25, -0.49, 0.4375},
			{0, -0.5, 0.3125, 0.3125, -0.49, 0.375},
			{0.0625, -0.5, 0.25, 0.375, -0.49, 0.3125},
			{0.125, -0.5, 0.1875, 0.4375, -0.49, 0.25},
			{0.1875, -0.5, 0.125, 0.5, -0.49, 0.1875},
			{0.25, -0.5, 0.0625, 0.5, -0.49, 0.125},
			{0.3125, -0.5, 0, 0.5, -0.49, 0.0625},
			{0.375, -0.5, -0.0625, 0.5, -0.49, 0},
			{0.4375, -0.5, -0.125, 0.5, -0.49, -0.0625},
		}
	}

local wall_col = {{"White",100},{"Black",180},{"Red",150},{"Lime",170}}
for i in ipairs(wall_col) do
	local desc = wall_col[i][1]
	local num = wall_col[i][2]
	local col = string.lower(desc)

minetest.register_node("decor:ship_wall_"..col, {
	description = "Ship Wall "..desc,
	tiles = {"decor_ship.png^decor_ship_overlay.png^[colorize:"..col..":"..num},
	drawtype = "normal",
	paramtype = "light",
	paramtype2 = "facedir",
	pointable = true,
	is_ground_content = false,
	groups = {cracky=3,not_in_creative_inventory=0},
})

stairs.register_stair_and_slab("ship_wall_"..col,
							"decor:ship_wall_"..col,
							{cracky=3,not_in_creative_inventory=0},
							{"decor_ship.png^decor_ship_overlay.png^[colorize:"..col..":"..num},
							desc.." Ship Stairs",
							desc.."Ship Slab",
							default.node_sound_stone_defaults())

minetest.register_node("decor:pinstrip_"..col, {
	description = "Pinstripe",
	tiles = {"decor_ship.png^[colorize:"..col..":220"},
	drawtype = "nodebox",
	paramtype = "light",
	paramtype2 = "facedir",
	sunlight_propagates = true,
	groups = {oddly_breakable_by_hand = 2,not_in_creative_inventory=0},
    node_box = cbox_pinstripe,
    collision_box = cbox_pinstripe,

})
minetest.register_node("decor:pinstrip_45_"..col, {
	description = "Pinstripe 45",
	tiles = {"decor_ship.png^[colorize:"..col..":220"},
	drawtype = "nodebox",
	paramtype = "light",
	paramtype2 = "facedir",
	sunlight_propagates = true,
	pointable = true,
	is_ground_content = false,
	groups = {cracky=3,not_in_creative_inventory=0},
    node_box = cbox_pinstripe_45,
    collision_box = cbox_pinstripe_45,
})
end

local ship_parts = {
	{"Pipes",				"decor_ship.png^[colorize:black:100",	cbox_full			,{oddly_breakable_by_hand = 2}},
	{"Pipes Corner",		"decor_ship.png^[colorize:black:100",	cbox_full			,{oddly_breakable_by_hand = 2}},
	{"Floor Grate",			"decor_ship.png",						cbox_full			,{oddly_breakable_by_hand = 2}},
	{"Grooved Wall",		"decor_ship.png",						cbox_full			,{oddly_breakable_by_hand = 2}},
	{"Ship Ladder",			"decor_ship.png^[colorize:black:180",	cbox_full			,{oddly_breakable_by_hand = 2}},
	}

for i in ipairs (ship_parts) do
	local desc = ship_parts[i][1]
	local img = ship_parts[i][2]
	local col = ship_parts[i][3]
	local gro = ship_parts[i][4]
	local itm = string.lower(string.gsub(desc," ","_"))


minetest.register_node("decor:"..itm, {
	description = desc,
	drawtype = "mesh",
    mesh = "decor_"..itm..'.obj',
	paramtype = "light",
	paramtype2 = "facedir",
    selection_box = col,
    collision_box = col,
	tiles = {img},
	groups = gro,
})

end


local ship_models = { -- description, name, model, texture, colbox, light
{'Walkway Inside Corner', 'eic', 'edge_incorner', 'floor_corner_inside.png', 'something', 2},
{'Walkway Outside Corner', 'eoc', 'edge_outcorner', 'floor_corner_outside.png', 'something', 2},
{'Walkway Edge', 'es', 'edge_straight', 'floor.png', 'something', 2},
{'Floor Angle', 'fa', 'floor_angle', 'floor_angle.png', 'something', 2},
{'Floor Square', 'fs', 'floor_square', 'floor_double.png', 'something', 2},
{'Rail Angled', 'ra', 'rail_angle', 'rail.png', 'soemthing', 4},
{'Rail Single', 'rs', 'rail_single', 'rail.png', 'something', 4},
{'Rail Double', 'rd', 'rail_double', 'rail.png', 'something', 4}

}

for i in ipairs (ship_models) do
	local desc = ship_models[i][1]
   local name = ship_models[i][2]
   local model = ship_models[i][3]
   local tex = ship_models[i][4]
--   local colbox = ship_models[i][5]
   local lit = ship_models[i][6]

minetest.register_node('decor:ss_'..name, {
   description = desc,
   drawtype = "mesh",
   mesh = "ss_"..model..'.obj',
   paramtype = "light",
   paramtype2 = "facedir",
   light_source = lit,
--   selection_box = colbox,
--   collision_box = colbox,
   tiles = {'decor_ship_'..tex},
   groups = {oddly_breakable_by_hand=1}
})
end
