forked from mtcontrib/weather_pack
rainy weather now extinguish fire (if fire directly under sky)
This commit is contained in:
parent
f1011e800f
commit
e230ba82c3
@ -1,6 +1,13 @@
|
||||
rain = {}
|
||||
rain = {
|
||||
-- max rain particles created at time
|
||||
particles_count = 35,
|
||||
|
||||
rain.particles_count = 35
|
||||
-- flag to turn on/off extinguish fire for rain
|
||||
extinguish_fire = true,
|
||||
|
||||
-- flag useful when mixing weathers
|
||||
raining = false,
|
||||
}
|
||||
|
||||
rain.sound_handler = function(player)
|
||||
return minetest.sound_play("weather_rain", {
|
||||
@ -111,6 +118,7 @@ end
|
||||
|
||||
-- callback function for removing rain
|
||||
rain.clear = function()
|
||||
rain.raining = false
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
rain.remove_sound(player)
|
||||
rain.remove_player(player)
|
||||
@ -126,6 +134,7 @@ minetest.register_globalstep(function(dtime)
|
||||
end)
|
||||
|
||||
rain.make_weather = function()
|
||||
rain.raining = true
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
if (is_underwater(player)) then
|
||||
return false
|
||||
@ -142,3 +151,19 @@ if weather.reg_weathers.rain == nil then
|
||||
clear = rain.clear
|
||||
}
|
||||
end
|
||||
|
||||
-- ABM for extinguish fire
|
||||
if weather.allow_abm then
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame"},
|
||||
interval = 4.0,
|
||||
chance = 2,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if rain.raining and rain.extinguish_fire then
|
||||
if weather.is_outdoor(pos) then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
@ -24,7 +24,10 @@ weather = {
|
||||
reg_weathers = {},
|
||||
|
||||
-- automaticly calculates intervals and swap weathers
|
||||
auto_mode = true
|
||||
auto_mode = true,
|
||||
|
||||
-- global flag to disable/enable ABM logic.
|
||||
allow_abm = true,
|
||||
}
|
||||
|
||||
weather.get_rand_end_time = function(min_duration, max_duration)
|
||||
@ -35,6 +38,13 @@ weather.get_rand_end_time = function(min_duration, max_duration)
|
||||
end
|
||||
end
|
||||
|
||||
weather.is_outdoor = function(pos)
|
||||
if minetest.get_node_light({x=pos.x, y=pos.y + 1, z=pos.z}, 0.5) == 15 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- checks if player is undewater. This is needed in order to
|
||||
-- turn off weather particles generation.
|
||||
function is_underwater(player)
|
||||
@ -152,6 +162,13 @@ minetest.register_chatcommand("set_weather", {
|
||||
end
|
||||
})
|
||||
|
||||
-- Configuration setting which allows user to disable ABM for weathers (if they use it).
|
||||
-- Weather mods expected to be use this flag before registering ABM.
|
||||
local weather_allow_abm = minetest.setting_getbool("weather_allow_abm")
|
||||
if weather_allow_abm ~= nil and weather_allow_abm == false then
|
||||
weather.allow_abm = false
|
||||
end
|
||||
|
||||
-- Overrides nodes 'sunlight_propagates' attribute for efficient indoor check (e.g. for glass roof).
|
||||
-- Controlled from minetest.conf setting and by default it is disabled.
|
||||
-- To enable set weather_allow_override_nodes to true.
|
||||
|
Loading…
Reference in New Issue
Block a user