support for weathers to change according to pos

This commit is contained in:
cora 2021-09-27 02:31:46 +02:00
parent cd67354725
commit f98058a853
3 changed files with 17 additions and 15 deletions

View File

@ -232,8 +232,10 @@ function mcl_weather.tick()
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 then
mcl_weather.change_player(name,cdef.change_at_pos)
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)
else
mcl_weather.change_player(name,mcl_weather.current)
end

View File

@ -94,7 +94,12 @@ mcl_weather.register_weather("rain",{
return true
end
end,
change_at_pos = "snow"
change_at_pos = function(pos)
local biome=minetest.get_biome_data(pos)
if mcl_worlds.has_weather(pos) and biome.heat < 15 then
return "snow"
end
end
})
if mcl_weather.allow_abm then

View File

@ -57,18 +57,13 @@ mcl_weather.register_weather("snow",{
}
},
start = function() end,
start_player = function(name)
local player=minetest.get_player_by_name(name)
if not mcl_weather.snow.at_pos(player:get_pos()) then
return true
end
end,
start_player = function(name)end,
clear = function() end,
at_pos = function(pos)
local biome=minetest.get_biome_data(pos)
if mcl_worlds.has_weather(pos) and biome.heat < 15 then
return true
at_pos = function(pos) end,
change_at_pos = function(pos)
local biome=minetest.get_biome_data(pos)
if pos.y > 50 or (mcl_worlds.has_weather(pos) and biome.heat > 15 ) then
return "rain"
end
end,
change_at_pos = "rain"
end
})