Skip to content

Commit

Permalink
check if server_announce was enabled before changing it
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay authored and BuckarooBanzay committed Jan 6, 2020
1 parent e6ef5aa commit 932cc69
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@

local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer < 15 then
return
end
if minetest.settings:get_bool("server_announce", false) then
-- only change announce setting if it was enabled in the first place

timer = 0
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer < 15 then
return
end

local threshold = tonumber(minetest.settings:get("server_cloak.threshold") or "15")
local player_count = #minetest.get_connected_players()
timer = 0

minetest.settings:set_bool("server_announce", player_count < threshold)
end)
local threshold = tonumber(minetest.settings:get("server_cloak.threshold") or "15")
local player_count = #minetest.get_connected_players()

minetest.settings:set_bool("server_announce", player_count < threshold)
end)

end

0 comments on commit 932cc69

Please sign in to comment.