--SKY--

--Version 0.2

pos = {x=0, y=0, z=0}

local space = -31000 --value for space, change the value to however you like.

--The skybox for space, feel free to change it to however you like.
local spaceskybox = {
"sky_pos_y.png^[transform3",
"sky_neg_y.png^[transform1",
"sky_pos_z.png",
"sky_neg_z.png",
"sky_neg_x.png",
"sky_pos_x.png",
}

local time = 0

minetest.register_globalstep(function(dtime)
time = time + dtime
if time > 1 then for _, player in ipairs(minetest.get_connected_players()) do
time = 0

local name = player:get_player_name()
local pos = player:getpos()
 
   --If the player has reached Space
   if minetest.get_player_by_name(name) and pos.y >= space then
   player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
   player:set_sky({}, "skybox", spaceskybox) -- Sets skybox
   player:set_clouds({density = 0})

   --If the player is on Earth
   elseif minetest.get_player_by_name(name) and pos.y < space then
   player:set_physics_override(1, 1, 1) -- speed, jump, gravity [default]
   player:set_sky({}, "regular", {}) -- Sets skybox, in this case it sets the skybox to it's default setting if and only if the player's Y value is less than the value of space.
   player:set_clouds({density = 0.4})
      
      end
         end
            end
               end)

minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
   
   if name then

   player:set_sky({}, "regular", {})

         end
            end)

--MAPGEN--

--minetest.clear_registered_ores()
minetest.clear_registered_biomes()
minetest.clear_registered_decorations()
minetest.override_item("default:mossycobble", {tiles = {"default_ice.png"}})

	minetest.register_biome({
		name = "saturn_moon",
		node_dust = "default:gravel",
		node_top = "default:stone",
		depth_top = 1,
		node_filler = "default:stone",
		depth_filler = 3,
		node_stone = "default:stone",
		node_water_top = "air",
		depth_water_top =1 ,
		node_water = "air",
		node_river_water = "air",
		y_min = -31000,
		y_max = 200,
		heat_point = 50,
		humidity_point = 50,
	})
--[[
--the following ores were taken from default

	-- Iron

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_iron",
		wherein        = "default:stone",
		clust_scarcity = 9 * 9 * 9,
		clust_num_ores = 12,
		clust_size     = 3,
		y_min          = 1025,
		y_max          = 31000,
	})

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_iron",
		wherein        = "default:stone",
		clust_scarcity = 7 * 7 * 7,
		clust_num_ores = 5,
		clust_size     = 3,
		y_min          = -31000,
		y_max          = 0,
	})

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_iron",
		wherein        = "default:stone",
		clust_scarcity = 24 * 24 * 24,
		clust_num_ores = 27,
		clust_size     = 6,
		y_min          = -31000,
		y_max          = -64,
	})

	-- Copper

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_copper",
		wherein        = "default:stone",
		clust_scarcity = 9 * 9 * 9,
		clust_num_ores = 5,
		clust_size     = 3,
		y_min          = 1025,
		y_max          = 31000,
	})

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_copper",
		wherein        = "default:stone",
		clust_scarcity = 12 * 12 * 12,
		clust_num_ores = 4,
		clust_size     = 3,
		y_min          = -63,
		y_max          = -16,
	})

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_copper",
		wherein        = "default:stone",
		clust_scarcity = 9 * 9 * 9,
		clust_num_ores = 5,
		clust_size     = 3,
		y_min          = -31000,
		y_max          = -64,
	})

	-- Tin

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_tin",
		wherein        = "default:stone",
		clust_scarcity = 10 * 10 * 10,
		clust_num_ores = 5,
		clust_size     = 3,
		y_min          = 1025,
		y_max          = 31000,
	})

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_tin",
		wherein        = "default:stone",
		clust_scarcity = 13 * 13 * 13,
		clust_num_ores = 4,
		clust_size     = 3,
		y_min          = -127,
		y_max          = -32,
	})

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_tin",
		wherein        = "default:stone",
		clust_scarcity = 10 * 10 * 10,
		clust_num_ores = 5,
		clust_size     = 3,
		y_min          = -31000,
		y_max          = -128,
	})

	-- Gold

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_gold",
		wherein        = "default:stone",
		clust_scarcity = 13 * 13 * 13,
		clust_num_ores = 5,
		clust_size     = 3,
		y_min          = 1025,
		y_max          = 31000,
	})

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_gold",
		wherein        = "default:stone",
		clust_scarcity = 15 * 15 * 15,
		clust_num_ores = 3,
		clust_size     = 2,
		y_min          = -255,
		y_max          = -64,
	})

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:stone_with_gold",
		wherein        = "default:stone",
		clust_scarcity = 13 * 13 * 13,
		clust_num_ores = 5,
		clust_size     = 3,
		y_min          = -31000,
		y_max          = -256,
	})
]]
	
--this is an original ore-- ice (although ice is taken from default)

	minetest.register_ore({
		ore_type       = "scatter",
		ore            = "default:ice",
		wherein        = "default:stone",
		clust_scarcity = 9 * 9 * 9,
		clust_num_ores = 12,
		clust_size     = 3,
		y_min          = -31000,
		y_max          = 31000,
	})
