Do nothing when no player online

This commit is contained in:
mazes-80 2022-10-01 22:05:37 +02:00
parent e8f4048670
commit 5635ab4daa
2 changed files with 6 additions and 3 deletions

View File

@ -4,6 +4,9 @@ local WORLD_CYCLE = 30.00 * climate_mod.settings.tick_speed -- only update globa
local gs_timer = 0
local world_timer = 0
minetest.register_globalstep(function(dtime)
local player_list = minetest.get_connected_players()
if #player_list == 0 then return end
gs_timer = gs_timer + dtime
world_timer = world_timer + dtime
@ -26,7 +29,7 @@ minetest.register_globalstep(function(dtime)
end
end
local current_effects = climate_mod.trigger.get_active_effects()
local current_effects = climate_mod.trigger.get_active_effects(player_list)
for name, effect in pairs(climate_mod.effects) do
local cycle = climate_mod.cycles[name].timespan * climate_mod.settings.tick_speed

View File

@ -83,12 +83,12 @@ local function get_weather_effects(player, weather_config, env)
return effects
end
function trigger.get_active_effects()
function trigger.get_active_effects(players)
local environments = {}
local effects = {}
climate_mod.current_weather = {}
for _, player in ipairs(minetest.get_connected_players()) do
for _, player in ipairs(players) do
local pname = player:get_player_name()
local hp = player:get_hp()
-- skip weather presets for dead players