clean up tick logic

This commit is contained in:
cora 2021-09-27 23:00:46 +02:00
parent 4a582ba5fb
commit f2b399cbbd
1 changed files with 12 additions and 5 deletions

View File

@ -235,11 +235,10 @@ function mcl_weather.tick()
local pos=player:get_pos() local pos=player:get_pos()
local cdef=mcl_weather.get_weatherdef(mcl_weather.current) local cdef=mcl_weather.get_weatherdef(mcl_weather.current)
if cdef.at_pos ~= nil then --switch to defined weather in at_pos conditions if type(cdef.change_at_pos) == "function" then --switch to returned weather in at_pos conditions
if not cdef.at_pos(pos) and cdef.change_at_pos ~= nil and cdef.change_at_pos(pos) then local cap=cdef.change_at_pos(pos)
mcl_weather.change_player(name,cdef.change_at_pos(pos)) if cap then
elseif not cdef.at_pos(pos) then mcl_weather.change_player(name,cap)
mcl_weather.stop_weather_player(name,cdef)
else else
mcl_weather.change_player(name,mcl_weather.current) mcl_weather.change_player(name,mcl_weather.current)
end end
@ -250,12 +249,20 @@ function mcl_weather.tick()
mcl_weather.stop_weather_player(name,cdef) mcl_weather.stop_weather_player(name,cdef)
players.weatheractive[name] = false players.weatheractive[name] = false
end end
if type(cdef.at_pos) == "function" and cdef.at_pos(pos) then
mcl_weather.stop_weather_player(name,cdef)
players.weatheractive[name] = false
end
else else
if mcl_weather.player_has_weather(player) then if mcl_weather.player_has_weather(player) then
mcl_weather.start_weather_player(name,cdef) mcl_weather.start_weather_player(name,cdef)
players.weather[name]=mcl_weather.current players.weather[name]=mcl_weather.current
players.weatheractive[name] = true players.weatheractive[name] = true
end end
if type(cdef.at_pos) == "function" and not cdef.at_pos(pos) then
mcl_weather.start_weather_player(name,cdef)
players.weatheractive[name] = false
end
end end
end) end)