Skip to content

Commit ffcd4ab

Browse files
authored
restrict xmas tree lights to december (#4221)
1 parent 1e180e8 commit ffcd4ab

File tree

1 file changed

+52
-49
lines changed

1 file changed

+52
-49
lines changed

luaui/configs/DeferredLightsGL4config.lua

+52-49
Original file line numberDiff line numberDiff line change
@@ -23307,6 +23307,7 @@ if day <= 25 then
2330723307
else
2330823308
fraction = fraction + ((day - 25) * 5)
2330923309
end
23310+
2331023311
local xmaslightbase = {
2331123312
fraction = fraction,
2331223313
lightType = 'point',
@@ -23329,71 +23330,73 @@ local xmaslightbase = {
2332923330
-- White Fire Remake 1.3
2333023331
-- Ice Scream v2.5.1
2333123332

23332-
local snowy_tree_keys = {}-- { __tree_fir_tall_3 = 20, __tree_fir_tall_4 = 20, allpinesb_ad0_snow = 20}
23333-
local snowy_tree_keys = {allpinesb_ad0 = 60, __tree_fir_tall_3 = 60, __tree_fir_ = 60}
23334-
local xmasColors = {
23335-
[1] = {234,13,13}, -- red
23336-
[2] = {251,11,36}, -- orange
23337-
[3] = {251,242,26}, -- yellow
23338-
[4] = {36, 208, 36}, -- green
23339-
[5] = {10,83, 222}, -- blue
23340-
}
23333+
-- add colorful xmas lights to a percentage of certain snowy trees
23334+
if os.date("%m") == "12" and os.date("%d") >= "12" then --and os.date("%d") <= "26"
23335+
local snowy_tree_keys = {allpinesb_ad0 = 60, __tree_fir_tall_3 = 60, __tree_fir_ = 60}
23336+
local xmasColors = {
23337+
[1] = {234,13,13}, -- red
23338+
[2] = {251,11,36}, -- orange
23339+
[3] = {251,242,26}, -- yellow
23340+
[4] = {36, 208, 36}, -- green
23341+
[5] = {10,83, 222}, -- blue
23342+
}
2334123343

23342-
for featureDefID , featureDef in pairs(FeatureDefs) do
23343-
local featureName = featureDef.name
23344-
-- Check if its a snowy tree:
23345-
-- estimate its height/ radius via model extrema
23346-
-- spawn lights in a cone shape around it
23347-
for key, count in pairs(snowy_tree_keys) do
23348-
if string.find(featureName, key, nil, true) then
23349-
--Spring.Echo("Found snowy tree: " .. featureName, key)
23344+
for featureDefID , featureDef in pairs(FeatureDefs) do
23345+
local featureName = featureDef.name
23346+
-- Check if its a snowy tree:
23347+
-- estimate its height/ radius via model extrema
23348+
-- spawn lights in a cone shape around it
23349+
for key, count in pairs(snowy_tree_keys) do
23350+
if string.find(featureName, key, nil, true) then
23351+
--Spring.Echo("Found snowy tree: " .. featureName, key)
2335023352

23351-
featureDefLights[featureDefID] = {}
23352-
local maxy = featureDef.model.maxy
23353-
local maxx = featureDef.model.maxx
23354-
local maxz = featureDef.model.maxz
23353+
featureDefLights[featureDefID] = {}
23354+
local maxy = featureDef.model.maxy
23355+
local maxx = featureDef.model.maxx
23356+
local maxz = featureDef.model.maxz
2335523357

23356-
for i= 1, count do
23357-
local xmaslight = table.copy(xmaslightbase)
23358+
for i= 1, count do
23359+
local xmaslight = table.copy(xmaslightbase)
2335823360

23359-
local y = maxy * (math.random() * 0.8 + 0.1)
23360-
local rely = 1.0 - y / maxy
23361+
local y = maxy * (math.random() * 0.8 + 0.1)
23362+
local rely = 1.0 - y / maxy
2336123363

23362-
local x = rely * maxx * (math.random() - 0.5) * 1.5
23363-
local z = rely * maxz * (math.random() - 0.5) * 1.5
23364-
--Spring.Echo(maxx, maxy, maxz, x,y,z)
23365-
xmaslight.lightConfig.posy = y
23366-
xmaslight.lightConfig.posx = x
23367-
xmaslight.lightConfig.posz = z
23364+
local x = rely * maxx * (math.random() - 0.5) * 1.5
23365+
local z = rely * maxz * (math.random() - 0.5) * 1.5
23366+
--Spring.Echo(maxx, maxy, maxz, x,y,z)
23367+
xmaslight.lightConfig.posy = y
23368+
xmaslight.lightConfig.posx = x
23369+
xmaslight.lightConfig.posz = z
2336823370

23369-
local color = math.ceil(math.random() * 4)
23371+
local color = math.ceil(math.random() * 4)
2337023372

23371-
xmaslight.lightConfig.r = xmasColors[color][1] / 255
23372-
xmaslight.lightConfig.g = xmasColors[color][2] / 255
23373-
xmaslight.lightConfig.b = xmasColors[color][3] / 255
23373+
xmaslight.lightConfig.r = xmasColors[color][1] / 255
23374+
xmaslight.lightConfig.g = xmasColors[color][2] / 255
23375+
xmaslight.lightConfig.b = xmasColors[color][3] / 255
2337423376

23375-
xmaslight.lightConfig.color2r = xmasColors[color+1][1] /255
23376-
xmaslight.lightConfig.color2g = xmasColors[color+1][2] /255
23377-
xmaslight.lightConfig.color2b = xmasColors[color+1][3] /255
23377+
xmaslight.lightConfig.color2r = xmasColors[color+1][1] /255
23378+
xmaslight.lightConfig.color2g = xmasColors[color+1][2] /255
23379+
xmaslight.lightConfig.color2b = xmasColors[color+1][3] /255
2337823380

2337923381

23380-
--[[
23382+
--[[
2338123383

23382-
xmaslight.lightConfig.r = math.random() > 0.5 and 1 or 0
23383-
xmaslight.lightConfig.g = math.random()> 0.5 and 1 or 0
23384-
xmaslight.lightConfig.b = math.random()> 0.5 and 1 or 0
23384+
xmaslight.lightConfig.r = math.random() > 0.5 and 1 or 0
23385+
xmaslight.lightConfig.g = math.random()> 0.5 and 1 or 0
23386+
xmaslight.lightConfig.b = math.random()> 0.5 and 1 or 0
2338523387

23386-
xmaslight.lightConfig.color2r = math.random() > 0.5 and 1 or 0
23387-
xmaslight.lightConfig.color2g = math.random()> 0.5 and 1 or 0
23388-
xmaslight.lightConfig.color2b = math.random()> 0.5 and 1 or 0
23389-
]]--
23388+
xmaslight.lightConfig.color2r = math.random() > 0.5 and 1 or 0
23389+
xmaslight.lightConfig.color2g = math.random()> 0.5 and 1 or 0
23390+
xmaslight.lightConfig.color2b = math.random()> 0.5 and 1 or 0
23391+
]]--
2339023392

23391-
xmaslight.lightConfig.colortime = 0.005 + math.random()* 0.005
23393+
xmaslight.lightConfig.colortime = 0.005 + math.random()* 0.005
2339223394

23393-
featureDefLights[featureDefID]['xmaslight' .. tostring(i)] = xmaslight
23395+
featureDefLights[featureDefID]['xmaslight' .. tostring(i)] = xmaslight
2339423396

23397+
end
23398+
break
2339523399
end
23396-
break
2339723400
end
2339823401
end
2339923402
end

0 commit comments

Comments
 (0)