1. Post #1
    Gold Member
    mil0001's Avatar
    January 2010
    485 Posts
    Hello. I found this on the wiki

    Code:
    function GM:PreDrawSkyBox()    return true
    end
    And it seems to do the job. But how can I change it to a different texture AFTER that has been called? I'm not even sure if this is possible, but it's worth a try I guess.

  2. Post #2
    sabreman's Avatar
    January 2010
    475 Posts
    Code:
    if CLIENT then
    //This is the fun stuff!
    
    local NewBoxName = "sky_day02_09"
    local OldBox = nil
    local Box = false
    local SkyBoxMaterials = {}
    local SkyBoxSuffixes = {"up", "dn", "lf", "rt", "bk", "ft"}
     
    // This funciton gets the current skybox materials and saves them
    local function GetSkyboxMats()
        OldBox = GetConVarString("sv_skyname")
    	
        for _, Suffix in ipairs(SkyBoxSuffixes) do 
            SkyBoxMaterials[Suffix] = Material("skybox/"..OldBox..Suffix)  
        end
    	
    end
    
    //replace the current skybox mat with the given one
    local function SetSkyBox(name)
        for Suffix, SkyMat in pairs(SkyBoxMaterials) do
            SkyMat:SetMaterialTexture("$basetexture", Material("skybox/"..name..Suffix ):GetMaterialTexture("$basetexture"))
        end
    end
    
    concommand.Add("snow_skyboxswap", function()//the fucntion that determines what to swap for what
    	Box = not Box
    	if (Box) then
    		SetSkyBox(NewBoxName)
    		
    	else
    		SetSkyBox(OldBox)
    	end
    end)
    
    //hooks
    hook.Add("InitPostEntity", "SkyBox.InitPostEntity", GetSkyboxMats)
    end
    This will swap between two skyboxes on demand. Note: if you reload the script, the skybox get's stuck at whatever it is atm, so you have to actually rejoin.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Lua Helper Lua Helper x 2 (list)

  3. Post #3
    Gold Member
    mil0001's Avatar
    January 2010
    485 Posts
    Thanks. That didn't work for what I needed it for but pretty cool :P

    Anyways, another question is it possible to remove say a sky_camera with lua at a specific location? or just with the entity name?

  4. Post #4
    ash47's Avatar
    March 2010
    724 Posts
    Thanks. That didn't work for what I needed it for but pretty cool :P

    Anyways, another question is it possible to remove say a sky_camera with lua at a specific location? or just with the entity name?
    Ya, you could loop through all the entities and search for sky_camera, or if you know the position of the sky camera, you could loop through all the entities and check if they are at that position, and if so, remove them...

    There's probably a better way, but anyways :P

    Code:
    for k,v in pairs(ents.GetAll()) do
    if v:GetClass() == "sky_camera" then
    v:Remove()
    end
    
    // OR
    
    if v:GetPos() == Vector(X,Y,Z) then
    v:Remove()
    end
    end
    Just a thought :P

  5. Post #5
    Please waste more of your money changing this title again.
    Gmod4ever's Avatar
    August 2005
    6,671 Posts
    Ya, you could loop through all the entities and search for sky_camera, or if you know the position of the sky camera, you could loop through all the entities and check if they are at that position, and if so, remove them...

    There's probably a better way, but anyways :P

    Code:
    for k,v in pairs(ents.GetAll()) do
    if v:GetClass() == "sky_camera" then
    v:Remove()
    end
    Just a thought :P
    Code:
    ents.FindByClass("sky_camera")[1]
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Agree Agree x 6 (list)

  6. Post #6
    ash47's Avatar
    March 2010
    724 Posts
    Code:
    ents.FindByClass("sky_camera")[1]
    Ah, thought it was something like that, couldn't quite remember exactly though :P

  7. Post #7
    MrManiak's Avatar
    January 2012
    79 Posts
    I only can change the skybox material once. Is it normal ?
    Reply With Quote Edit / Delete Reply Windows 7 Canada Show Events Dumb Dumb x 1 (list)

  8. Post #8
    MrManiak's Avatar
    January 2012
    79 Posts
    I really need an answer.
    Reply With Quote Edit / Delete Reply Windows 7 Canada Show Events Dumb Dumb x 1 (list)

  9. Post #9
    SeveredSkull's Avatar
    October 2008
    1,316 Posts
    Why the fuck did you bump this?
    Reply With Quote Edit / Delete Reply Windows Vista United States Show Events Funny Funny x 3 (list)