• Changing the skybox texture
    9 replies, posted
the thread has been made in the past here: [url]https://facepunch.com/showthread.php?t=1076425[/url] but, the code that was given as the answer isn't working for me. [CODE]local SourceSkyname = GetConVar("sv_skyname"):GetString() --We need the source of the maps original skybox texture so we can manipulate it. local SourceSkyPre = {"lf","ft","rt","bk","dn","up",} local SourceSkyMat = { Material("skybox/"..SourceSkyname.."lf"), Material("skybox/"..SourceSkyname.."ft"), Material("skybox/"..SourceSkyname.."rt"), Material("skybox/"..SourceSkyname.."bk"), Material("skybox/"..SourceSkyname.."dn"), Material("skybox/"..SourceSkyname.."up"), } function ChangeSkybox(skyboxname) for i = 1,6 do local D = Material("skybox/"..skyboxname..SourceSkyPre[i]):GetMaterialTexture("skybox/sky_borealis") SourceSkyMat[i]:SetMaterialTexture("skybox/sky_borealis",D) end end[/CODE] this does not change the skybox to sky_borealis
[code]Material(<string>):SetTexture("$basetexture",<texturestring>)[/code]
[QUOTE=Nak;52812828][code]Material(<string>):SetTexture("$basetexture",<texturestring>)[/code][/QUOTE] [QUOTE]bad argument #2 to 'SetTexture' (ITexture expected, got userdata)[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/IMaterial/SetTexture]IMaterial:SetTexture[/url] Read what the stuff in <> says and replace it...
[QUOTE=MelonShooter;52814444][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/IMaterial/SetTexture]IMaterial:SetTexture[/url] Read what the stuff in <> says and replace it...[/QUOTE] Yes, I did that [CODE]Material("painted"):SetTexture("$basetexture","sky_day01_09") -- also tried skybox/sky_day01_09[/CODE] Oh, btw, the error for that is: [QUOTE]bad argument #2 to 'SetTexture' (ITexture expected, got userdata)[/QUOTE]
[code]function Example() local SourceSkyname = GetConVar("sv_skyname"):GetString() --We need the source of the maps original skybox texture so we can manipulate it. local SourceSkyPre = {"lf","ft","rt","bk","dn","up",} local SourceSkyMat = { Material("skybox/"..SourceSkyname.."lf"), Material("skybox/"..SourceSkyname.."ft"), Material("skybox/"..SourceSkyname.."rt"), Material("skybox/"..SourceSkyname.."bk"), Material("skybox/"..SourceSkyname.."dn"), Material("skybox/"..SourceSkyname.."up"), } for i = 1,6 do local D = Material("skybox/"..SourceSkyname..SourceSkyPre[i]):GetTexture("$basetexture") SourceSkyMat[i]:SetTexture("$basetexture", "skybox/sky_day01_09") end end[/code] This is what I have so far, no errors, but it's not working
The second argument to SetTexture is a texture, not a string. You made the variable D which returns the texture you're trying to get but you still have skybox/sky_day01_09 as a string in the SetTexture
[QUOTE=dence47;52817995]The second argument to SetTexture is a texture, not a string. You made the variable D which returns the texture you're trying to get but you still have skybox/sky_day01_09 as a string in the SetTexture[/QUOTE] Even if I do [CODE]SourceSkyMat[i]:SetTexture("$basetexture", D)[/CODE] It doesn't work. The reason it was like that was that I did countless edits on it.
:snip: I was wrong and dumb
Sorry, you need to Log In to post a reply to this thread.