Author Topic: Need help changing the skybox texture  (Read 216 times)

0 Members and 2 Guests are viewing this topic.

Offline Jeff43

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Need help changing the skybox texture
« on: October 24, 2017, 10:23:38 AM »
Has nothing to do with ulx, so I thought maybe off-topic was the way to go. I tried Facepunch, but no one seems to know a solution.
Code: [Select]
Material("painted"):SetTexture("$basetexture","sky_day01_09") -- also tried skybox/sky_day01_09
« Last Edit: October 24, 2017, 06:58:49 PM by Jeff43 »

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2572
  • Karma: 395
    • View Profile
    • |G4P| Gman4President
Re: bad argument #2 to 'SetTexture' (ITexture expected, got userdata)
« Reply #1 on: October 24, 2017, 11:57:01 AM »
"painted" isn't the material.

There are individual materials for the skybox.

 "up", "dn", "lf", "rt", "bk", "ft"

For example:

lua_run_cl print(Material("painted"))
Material [___error]


But...

lua_run_cl print(Material("skybox/paintedup"))
Material [skybox/paintedup]

so you would need..

Material("skybox/paintedup")
Material("skybox/painteddn")
Material("skybox/paintedlf")
Material("skybox/paintedrt")
Material("skybox/paintedbk")
Material("skybox/paintedft")

Not sure if the rest of your code will work as I didn't try it.. but that should help you get started.

Offline Jeff43

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: bad argument #2 to 'SetTexture' (ITexture expected, got userdata)
« Reply #2 on: October 24, 2017, 01:36:05 PM »
Code: Lua
  1. function Example()
  2. local SourceSkyname = GetConVar("sv_skyname"):GetString() --We need the source of the maps original skybox texture so we can manipulate it.
  3. local SourceSkyPre  = {"lf","ft","rt","bk","dn","up",}
  4. local SourceSkyMat  = {
  5.     Material("skybox/"..SourceSkyname.."lf"),
  6.     Material("skybox/"..SourceSkyname.."ft"),
  7.     Material("skybox/"..SourceSkyname.."rt"),
  8.     Material("skybox/"..SourceSkyname.."bk"),
  9.     Material("skybox/"..SourceSkyname.."dn"),
  10.     Material("skybox/"..SourceSkyname.."up"),
  11. }
  12.     for i = 1,6 do
  13.                 local D = Material("skybox/"..SourceSkyname..SourceSkyPre[i]):GetTexture("$basetexture")
  14.         SourceSkyMat[i]:SetTexture("$basetexture", "skybox/sky_day01_09")
  15.     end
  16. end

This is what I have so far, I got it from https://facepunch.com/showthread.php?t=1076425, but it's outdated and no longer works for me.
No errors, I think I got something slightly wrong because when I did
Code: [Select]
lua_run Example() it reset the painted sky, but it didn't actually change the skybox to "sky_day01_09"
« Last Edit: October 24, 2017, 01:40:38 PM by Jeff43 »

Offline Jeff43

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: bad argument #2 to 'SetTexture' (ITexture expected, got userdata)
« Reply #3 on: October 24, 2017, 06:39:12 PM »
Scratch that, it didn't reset the sky, that was just the sky entity I added in and since I was on gm_flatgrass the sky texture was already painted so it reset the sky.
It's actually not working at all, and I cannot figure out why.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 7759
  • Karma: 353
  • Sertafide Ulysses Jenius
    • View Profile
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Need help changing the skybox texture
« Reply #4 on: October 24, 2017, 08:12:08 PM »
I'd start with print statements to print convar and lua var names out to console.
I'd be extremely surprised if there's not actually lua errors being shown in game or server console, somewhere.
At the least, print statements would show if the variable names being fed to the code you're expecting to take action on those variable names is being fed proper info.
The price one pays for pursuing any profession or calling is an intimate knowledge of its ugly side. - James Baldwin