mirror of
https://github.com/t-affeldt/climate_api.git
synced 2024-12-22 08:50:37 +01:00
Do nothing when no player online
This commit is contained in:
parent
e8f4048670
commit
5635ab4daa
@ -4,6 +4,9 @@ local WORLD_CYCLE = 30.00 * climate_mod.settings.tick_speed -- only update globa
|
|||||||
local gs_timer = 0
|
local gs_timer = 0
|
||||||
local world_timer = 0
|
local world_timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
local player_list = minetest.get_connected_players()
|
||||||
|
if #player_list == 0 then return end
|
||||||
|
|
||||||
gs_timer = gs_timer + dtime
|
gs_timer = gs_timer + dtime
|
||||||
world_timer = world_timer + dtime
|
world_timer = world_timer + dtime
|
||||||
|
|
||||||
@ -26,7 +29,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
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
|
for name, effect in pairs(climate_mod.effects) do
|
||||||
local cycle = climate_mod.cycles[name].timespan * climate_mod.settings.tick_speed
|
local cycle = climate_mod.cycles[name].timespan * climate_mod.settings.tick_speed
|
||||||
|
@ -83,12 +83,12 @@ local function get_weather_effects(player, weather_config, env)
|
|||||||
return effects
|
return effects
|
||||||
end
|
end
|
||||||
|
|
||||||
function trigger.get_active_effects()
|
function trigger.get_active_effects(players)
|
||||||
local environments = {}
|
local environments = {}
|
||||||
local effects = {}
|
local effects = {}
|
||||||
climate_mod.current_weather = {}
|
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 pname = player:get_player_name()
|
||||||
local hp = player:get_hp()
|
local hp = player:get_hp()
|
||||||
-- skip weather presets for dead players
|
-- skip weather presets for dead players
|
||||||
|
Loading…
Reference in New Issue
Block a user