Skip to content

Instantly share code, notes, and snippets.

@dowoge
Created June 6, 2023 23:28
Show Gist options
  • Save dowoge/9c16fd891009a73135c58bafebd69fac to your computer and use it in GitHub Desktop.
Save dowoge/9c16fd891009a73135c58bafebd69fac to your computer and use it in GitHub Desktop.
sky and lighting script generator
local numberFloatNumberRounding = 5 --5 decimal places
local LightingProperties = {
'Ambient',
'Brightness',
'ClockTime',
'ColorShift_Bottom',
'ColorShift_Top',
'EnvironmentDiffuseScale',
'EnvironmentSpecularScale',
'ExposureCompensation',
'FogColor',
'FogEnd',
'FogStart',
'GeographicLatitude',
'GlobalShadows',
'OutdoorAmbient',
'ShadowSoftness',
'TimeOfDay'
}
local SkyProperties = {
'CelestialBodiesShown',
'MoonAngularSize',
'SkyboxBk',
'SkyboxDn',
'SkyboxFt',
'SkyboxLf',
'SkyboxRt',
'SkyboxUp',
'MoonTextureId',
'SkyboxBk',
'SkyboxDn',
'SkyboxFt',
'SkyboxLf',
'SkyboxRt',
'SkyboxUp',
'StarCount',
'SunAngularSize',
'SunTextureId'
}
local format=string.format
local tonumber=tonumber
local function round(n,d)
return tonumber(format('%.'..(d or 0)..'f',n))
end
function instanceToString(instance)
if typeof(instance)=='Color3' then
local R,G,B = instance.R,instance.G,instance.B
return 'Color3.fromRGB('..round(R*255)..','..round(G*255)..','..round(B*255)..')'
elseif type(instance)=='string' then
return '\''..instance..'\''
elseif type(instance)=='number' then
return round(instance,numberFloatNumberRounding)
elseif type(instance)=='boolean' then
return tostring(instance)
end
return tostring(instance)
end
local Lighting = game:GetService('Lighting')
local Sky = Lighting:WaitForChild('Sky')
local SkyText = [[--sky generator by tommy ooo la la
local Lighting = game:GetService('Lighting')
local Sky = Instance.new('Sky',Lighting)
]]
local LightingText = '\n'
if not Sky then
warn('no sky in lighting!')
return
end
for Index,Property in next,SkyProperties do
SkyText ..= 'Sky.'..Property..'='..instanceToString(Sky[Property])..'\n'
end
for Index,Property in next,LightingProperties do
LightingText ..= 'Lighting.'..Property..'='..instanceToString(Lighting[Property])..'\n'
end
local Script = Instance.new('Script',workspace)
Script.Name='Sky and Lighting'
Script.Source = SkyText..LightingText..'\nscript:Destroy()'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment