Skip to content

Parcially working #2

Description

@Ronska

For me the ressource is “kinda” working. I am able to set the weather (in zones) while I’m ingame. But my script seems not to be working, it doesn’t set up different weather zones like in my config.

`WeatherConfig = {}
WeatherConfig = setmetatable(WeatherConfig, {})

activeWeatherSystems = {}

WeatherConfig.snowEnabled = true -- Set to false if you do not want snow enabled.
WeatherConfig.decemberSnowDays = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 } -- Days that snow will appear during the month of December.

WeatherConfig.weatherTypes = {
"CLEAR",
"EXTRASUNNY",
"CLOUDS",
"OVERCAST",
"RAIN",
"CLEARING",
"THUNDER",
"SMOG",
"FOGGY",
"XMAS",
"SNOWLIGHT",
"BLIZZARD"
}

WeatherConfig.randomizeTime = 1800000 -- 1 Hour (TIME TO RANDOMIZE WEATHER SYSTEMS IN MILLISECONDS)

WeatherConfig.weatherSystems = {
{
{ "TERMINA", "ELYSIAN", "AIRP", "BANNING", "DELSOL", "RANCHO", "STRAW", "CYPRE", "SANAND" },
{ WeatherConfig.weatherTypes[6], WeatherConfig.weatherTypes[7] } -- Summer
}, -- South LS
{
{ "MURRI", "LMESA", "SKID", "LEGSQU", "TEXTI", "PBOX", "KOREAT" },
{ WeatherConfig.weatherTypes[6], WeatherConfig.weatherTypes[7] } -- Summer
}, -- Central LS
{
{ "MIRR", "EAST_V", "DTVINE", "ALTA", "HAWICK", "BURTON", "ROCKF", "MOVIE", "DELPE", "MORN", "RICHM", "GOLF", "WVINE", "DTVINE", "HORS", "LACT", "LDAM" },
{ WeatherConfig.weatherTypes[6], WeatherConfig.weatherTypes[7] } -- Summer
}, -- North LS
{
{ "BEACH", "VESP", "VCANA", "DELBE", "PBLUFF" },
{ WeatherConfig.weatherTypes[6], WeatherConfig.weatherTypes[7] } -- Summer
}, -- LS Beaches
{
{ "EBURO", "PALHIGH", "NOOSE", "TATAMO" },
{ WeatherConfig.weatherTypes[6], WeatherConfig.weatherTypes[7] } -- Summer
}, -- Eastern Valley
{
{ "BANHAMC", "BANHAMCA", "CHU", "TONGVAH" },
{ WeatherConfig.weatherTypes[6], WeatherConfig.weatherTypes[7] } -- Summer
}, -- Coastal Beaches
{
{ "CHIL", "GREATC", "RGLEN", "TONGVAV" },
{ WeatherConfig.weatherTypes[9], WeatherConfig.weatherTypes[10] }
}, -- North LS Hills
{
{ "PALMPOW", "WINDF", "RTRACK", "JAIL", "HARMO", "DESRT", "SANDY", "ZQ_UAR", "HUMLAB", "SANCHIA", "GRAPES", "ALAMO", "SLAB", "CALAFAB" },
{ WeatherConfig.weatherTypes[6], WeatherConfig.weatherTypes[7] } -- Summer
}, -- Grand Senora Desert
{
{ "MTGORDO", "ELGORL", "BRADP", "BRADT", "MTCHIL", "GALFISH" },
{ WeatherConfig.weatherTypes[1], WeatherConfig.weatherTypes[12] }
}, -- Northern Moutains
{
{ "LAGO", "ARMYB", "NCHU", "CANNY", "MTJOSE", "CCREAK" },
{ WeatherConfig.weatherTypes[2], WeatherConfig.weatherTypes[3] }
}, -- Zancudo
{
{ "CMSW", "PALCOV", "OCEANA", "PALFOR", "PALETO", "PROCOB" },
{ WeatherConfig.weatherTypes[1], WeatherConfig.weatherTypes[12] }
}, -- Palteo
}

WeatherConfig.timesOfYear = {
{ 3, 4, 5 }, --SPRING 1
{ 6, 7, 8 }, --SUMMER 2
{ 9, 10, 11 }, --FALL 3
{ 12, 1, 2 } --WINTER 4
}

function getCurrentSeason()
for i, timeOfYear in ipairs(WeatherConfig.timesOfYear) do
for k, month in ipairs(WeatherConfig.timesOfYear[i]) do
if month == os.date("*t").month then
return i
end
end
end
end

function isSnowDay()
for i, decemberSnowDay in ipairs(WeatherConfig.decemberSnowDays) do
if decemberSnowDay == os.date("*t").day then
return true
end
end
return false
end

function findZoneBySubZone(zoneName)
for i, weatherSystem in ipairs(WeatherConfig.weatherSystems) do
for _, weatherZone in ipairs(weatherSystem[1]) do
if weatherZone == zoneName then
return i
end
end
end
end

function randomizeSystems()
activeWeatherSystems = {}
for i, weatherSystem in ipairs(WeatherConfig.weatherSystems) do
local currentSeason = getCurrentSeason()
local availableWeathers = weatherSystem[currentSeason + 1]
local pickedWeather = availableWeathers[math.random(1, #availableWeathers)]
for _, weatherZone in ipairs(weatherSystem[1]) do
if os.date("*t").month == 12 and isSnowDay() and WeatherConfig.snowEnabled then
table.insert(activeWeatherSystems, {weatherZone, "XMAS"})
else
table.insert(activeWeatherSystems, {weatherZone, pickedWeather})
end
end
end
end`

Anything wrong on my end?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions