2020-04-13 01:55:39 +02:00
|
|
|
if not climate_mod.settings.skybox then return end
|
|
|
|
|
2020-04-16 08:05:16 +02:00
|
|
|
local EFFECT_NAME = "climate_api:skybox"
|
2020-04-18 11:12:47 +02:00
|
|
|
|
2020-04-24 01:35:07 +02:00
|
|
|
local function handle_effect(player_data, prev_data)
|
|
|
|
for playername, data in pairs(prev_data) do
|
|
|
|
for weather, _ in pairs(data) do
|
|
|
|
if player_data[playername] == nil or player_data[playername][weather] == nil then
|
|
|
|
climate_api.skybox.remove_layer(playername, weather)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-04-13 01:55:39 +02:00
|
|
|
for playername, data in pairs(player_data) do
|
|
|
|
for weather, value in pairs(data) do
|
2020-04-24 01:35:07 +02:00
|
|
|
climate_api.skybox.add_layer(playername, weather, value)
|
2020-04-13 01:55:39 +02:00
|
|
|
end
|
2020-04-24 01:35:07 +02:00
|
|
|
climate_api.skybox.update_skybox(playername)
|
2020-04-13 01:55:39 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function remove_effect(player_data)
|
2020-04-16 08:05:16 +02:00
|
|
|
for playername, data in pairs(player_data) do
|
2020-04-24 01:35:07 +02:00
|
|
|
for weather, _ in pairs(data) do
|
|
|
|
climate_api.skybox.remove_layer(playername, weather)
|
|
|
|
end
|
2020-04-13 01:55:39 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-16 08:05:16 +02:00
|
|
|
climate_api.register_effect(EFFECT_NAME, handle_effect, "tick")
|
|
|
|
climate_api.register_effect(EFFECT_NAME, remove_effect, "stop")
|
2020-04-24 01:35:07 +02:00
|
|
|
climate_api.set_effect_cycle("climate_api:skybox", climate_api.MEDIUM_CYCLE)
|