fix weather count being 0

This commit is contained in:
theFox6 2020-10-07 07:49:05 +02:00
parent 660c09fa7c
commit b9aa145de3
No known key found for this signature in database
GPG Key ID: 7F519E4C6DDAED4A
1 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,5 @@
weather_mod.registered_downfalls = {} weather_mod.registered_downfalls = {}
weather_mod.registered_downfall_count = 0
weather_mod.registered_weather_change_callbacks = {} weather_mod.registered_weather_change_callbacks = {}
local function check_modname_prefix(name) local function check_modname_prefix(name)
@ -86,6 +87,7 @@ function weather_mod.register_downfall(id,def)
end end
--actually register the downfall --actually register the downfall
weather_mod.registered_downfalls[name]=ndef weather_mod.registered_downfalls[name]=ndef
weather_mod.registered_downfall_count = weather_mod.registered_downfall_count + 1
end end
function weather_mod.register_on_weather_change(callback) function weather_mod.register_on_weather_change(callback)
@ -200,7 +202,7 @@ minetest.register_globalstep(function()
end end
weather_mod.handle_weather_change({type = "none", reason = "globalstep"}) weather_mod.handle_weather_change({type = "none", reason = "globalstep"})
else else
local cnum = 10000 * #weather_mod.registered_downfalls local cnum = 10000 * weather_mod.registered_downfall_count
for id,w in pairs(weather_mod.registered_downfalls) do for id,w in pairs(weather_mod.registered_downfalls) do
if math.random(1, cnum) == 1 then if math.random(1, cnum) == 1 then
weather.wind = { weather.wind = {