Hello. I found this on the wiki
[CODE]function GM:PreDrawSkyBox() return true
end[/CODE]
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.
[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
[/code]
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.
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?
[QUOTE=mil0001;34427426]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?[/QUOTE]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[/code]
Just a thought :P
[QUOTE=ash47;34431032]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[/code]
Just a thought :P[/QUOTE]
[code]ents.FindByClass("sky_camera")[1][/code]
:v:
[QUOTE=Gmod4ever;34432050][code]ents.FindByClass("sky_camera")[1][/code]
:v:[/QUOTE]
Ah, thought it was something like that, couldn't quite remember exactly though :P
I only can change the skybox material once. Is it normal ?
I really need an answer.
Why the fuck did you bump this?
Sorry, you need to Log In to post a reply to this thread.