if CLIENT then
//This is the fun stuff!

local OldBox = nil
local Box = true
local SkyBoxMaterials = {}
local SkyBoxSuffixes = {"up", "dn", "lf", "rt", "bk", "ft"}
local env_sun
 
// This funciton gets the current skybox materials and saves them
local function GetSkyboxMats()
    OldBox = GetConVarString("sv_skyname")
	
    for _, Suffix in ipairs(SkyBoxSuffixes) do 
		//this prettyuch just makes the code neater, i could also do it like this:
		// SkyBoxUpMat = Material("skybox/"..OldBox.."up") and then dupe the line 6 times.
        SkyBoxMaterials[Suffix] = Material("skybox/"..OldBox..Suffix)  
    end
	
	SetSkyBox("sky_day02_09") // sets it to this when you firs spawn, so you dont have turn it on/off
	
	//messing with sun here	
	/*env_sun = ents.FindByClass('env_sun') //gets the sun entity, hopfully i can get the sucker to move eventualy.
	if (env_sun) then
		local sun
		for _ , sun in pairs(env_sun) do
			sun:SetKeyValue('material','')
			sun:SetKeyValue('overlaymaterial','')
			sun:Fire('addoutput',Angle(0,200,0),0)
			sun:Activate()
		end
	end*/
end

//replace the current skybox mat with the given one
function SetSkyBox(name)
    for Suffix, SkyMat in pairs(SkyBoxMaterials) do
        SkyMat:SetMaterialTexture("$basetexture", Material("skybox/"..name..Suffix ):GetMaterialTexture("$basetexture"))
    end
end

hook.Add("InitPostEntity", "SkyBox.InitPostEntity", GetSkyboxMats)

concommand.Add("snow_skyboxswap", function()//the fucntion that determines what to swap for what
	Box = not Box
	if (Box) then
		SetSkyBox("sky_day02_09")
	else
		SetSkyBox(OldBox)
	end
end)
end