forked from Mineclonia/Mineclonia
clean up tick logic
This commit is contained in:
parent
4a582ba5fb
commit
f2b399cbbd
|
@ -235,11 +235,10 @@ function mcl_weather.tick()
|
|||
local pos=player:get_pos()
|
||||
local cdef=mcl_weather.get_weatherdef(mcl_weather.current)
|
||||
|
||||
if cdef.at_pos ~= nil then --switch to defined weather in at_pos conditions
|
||||
if not cdef.at_pos(pos) and cdef.change_at_pos ~= nil and cdef.change_at_pos(pos) then
|
||||
mcl_weather.change_player(name,cdef.change_at_pos(pos))
|
||||
elseif not cdef.at_pos(pos) then
|
||||
mcl_weather.stop_weather_player(name,cdef)
|
||||
if type(cdef.change_at_pos) == "function" then --switch to returned weather in at_pos conditions
|
||||
local cap=cdef.change_at_pos(pos)
|
||||
if cap then
|
||||
mcl_weather.change_player(name,cap)
|
||||
else
|
||||
mcl_weather.change_player(name,mcl_weather.current)
|
||||
end
|
||||
|
@ -250,12 +249,20 @@ function mcl_weather.tick()
|
|||
mcl_weather.stop_weather_player(name,cdef)
|
||||
players.weatheractive[name] = false
|
||||
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
|
||||
if mcl_weather.player_has_weather(player) then
|
||||
mcl_weather.start_weather_player(name,cdef)
|
||||
players.weather[name]=mcl_weather.current
|
||||
players.weatheractive[name] = true
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue