Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Abyss custom sky stuff
- local skypaint
- local sun
- hook.Add("InitPostEntity", "SkyPaint", function()
- if SERVER then
- RunConsoleCommand("sv_skyname", "painted")
- local skypaints=ents.FindByClass("env_skypaint")
- if #skypaints==0 then
- skypaint = ents.Create("env_skypaint")
- skypaint:Spawn()
- skypaint:Activate()
- elseif #skypaints >= 1 then
- skypaint=skypaints[1]
- end
- local suns=ents.FindByClass("env_sun")
- if #suns >= 1 then
- sun=suns[1]
- end
- end
- end)
- /*
- local function UpdateDusk(p)
- print(p)
- if p > 135 and p < 225 then
- skypaint:SetDuskIntensity( p/36 )
- print(p/36)
- elseif p > 360 and p < 450 then
- if p > 360 and p < 405 then
- skypaint:SetDuskIntensity( p/81 )
- print(p/81)
- else
- skypaint:SetDuskIntensity( p/81 )
- print( p/81 )
- end
- else
- skypaint:SetDuskIntensity( 0 )
- print(0)
- end
- end
- */
- local function SetSunAngle(ang)
- sun:SetKeyValue( "sun_dir", tostring( ang:Forward() ) )
- //UpdateDusk(ang.p)
- end
- local function SetSkyColor(top,bottom)
- skypaint:SetTopColor( top )
- skypaint:SetBottomColor( bottom )
- end
- local function UpdateSky(time)
- local day={}
- day.top=Vector( 0.2, 0.5, 1.0 )
- day.bottom=Vector( 0.8, 1.0, 1.0 )
- local night={}
- night.top=Vector( 0, 0, 0 )
- night.bottom=Vector( 0, 0, 0 )
- local lerptime=math.sqrt((100-(100/12)*time)^2)/100
- local top=LerpVector(lerptime, day.top, night.top)
- local bottom=LerpVector(lerptime, day.bottom, night.bottom)
- SetSkyColor(top,bottom)
- end
- local function UpdateSun(time)
- SetSunAngle(Angle((time*15)+90,0,0))
- end
- local function round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- local function round(n, mult)
- mult = mult or 1
- return math.floor((n + mult/2)/mult) * mult
- end
- local function UpdateLighting(time)
- local L={"a","b","c","d","e","f","g","h","i","j","k","l"}
- local n=round(-math.sqrt((11-(11/12)*time)^2)+12)
- engine.LightStyle(0,L[n])
- timer.Simple(0.5,function()
- umsg.Start("UpdateLighting")
- umsg.End()
- end)
- end
- usermessage.Hook("UpdateLighting",function()
- render.RedownloadAllLightmaps()
- end)
- if SERVER then
- timer.Create("UpdateSky", 60, 0, function()
- local time=os.date("%H")+(os.date("%M")*(1+(2/3))/100)
- UpdateSky(time)
- if IsValid(sun) then
- UpdateSun(time)
- end
- UpdateLighting(time)
- end)
- end
- function UpdateSkyManual(time)
- UpdateSky(time)
- if IsValid(sun) then
- UpdateSun(time)
- end
- UpdateLighting(time)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement