mirror of
https://github.com/t-affeldt/climate_api.git
synced 2025-04-30 08:21:46 -04:00
Remove is_connected() and use minetest counterpart
This commit is contained in:
parent
a56116e8ab
commit
31462ab08e
2 changed files with 3 additions and 12 deletions
|
@ -212,4 +212,4 @@ local function handle_effect(player_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
climate_api.register_effect(EFFECT_NAME, handle_effect, "tick")
|
climate_api.register_effect(EFFECT_NAME, handle_effect, "tick")
|
||||||
climate_api.set_effect_cycle(EFFECT_NAME, CYCLE_LENGTH)
|
climate_api.set_effect_cycle(EFFECT_NAME, CYCLE_LENGTH)
|
||||||
|
|
13
lib/main.lua
13
lib/main.lua
|
@ -1,15 +1,6 @@
|
||||||
local GSCYCLE = 0.03 * climate_mod.settings.tick_speed -- only process event loop after this amount of time
|
local GSCYCLE = 0.03 * climate_mod.settings.tick_speed -- only process event loop after this amount of time
|
||||||
local WORLD_CYCLE = 30.00 * climate_mod.settings.tick_speed -- only update global environment influences after this amount of time
|
local WORLD_CYCLE = 30.00 * climate_mod.settings.tick_speed -- only update global environment influences after this amount of time
|
||||||
|
|
||||||
local function is_connected(playername)
|
|
||||||
local connected = minetest.get_connected_players()
|
|
||||||
for _, player in ipairs(connected) do
|
|
||||||
local name = player:get_player_name()
|
|
||||||
if playername == name then return true end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
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)
|
||||||
|
@ -29,7 +20,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- skip weather changes for offline players
|
-- skip weather changes for offline players
|
||||||
for effect, data in pairs(previous_effects) do
|
for effect, data in pairs(previous_effects) do
|
||||||
for playername, _ in pairs(data) do
|
for playername, _ in pairs(data) do
|
||||||
if not is_connected(playername) then
|
if not minetest.get_player_by_name(playername) then
|
||||||
previous_effects[effect][playername] = nil
|
previous_effects[effect][playername] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -47,4 +38,4 @@ minetest.register_globalstep(function(dtime)
|
||||||
climate_mod.cycles[name].timer = climate_mod.cycles[name].timer + dtime
|
climate_mod.cycles[name].timer = climate_mod.cycles[name].timer + dtime
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Add table
Reference in a new issue