Redo fire protection for claimed areas.

Take out the bugged attempt to override flame_should_extinguish
and override on_construct instead. In addition, an abm was added
to catch basic_flame set by voxelmanip (e.g. when TNT explodes).
This commit is contained in:
Foz 2016-05-06 19:26:05 -04:00
parent fd0157f399
commit c5af920590
4 changed files with 49 additions and 19 deletions

View File

@ -1,2 +1,3 @@
whoison?
fire?
doors

View File

@ -1,20 +1,28 @@
if minetest.get_modpath("fire") and rawget(_G, "fire") then
landrush.default_flame_should_extinguish = fire.flame_should_extinguish
function fire.flame_should_extinguish(pos)
corner0 = landrush.can_interact({x=pos.x-1,y=pos.y-1,z=pos.z-1},"-!-")
corner1 = landrush.can_interact({x=pos.x-1,y=pos.y-1,z=pos.z+1},"-!-")
corner2 = landrush.can_interact({x=pos.x-1,y=pos.y+1,z=pos.z-1},"-!-")
corner3 = landrush.can_interact({x=pos.x-1,y=pos.y+1,z=pos.z+1},"-!-")
corner4 = landrush.can_interact({x=pos.x+1,y=pos.y-1,z=pos.z-1},"-!-")
corner5 = landrush.can_interact({x=pos.x+1,y=pos.y-1,z=pos.z+1},"-!-")
corner6 = landrush.can_interact({x=pos.x+1,y=pos.y+1,z=pos.z-1},"-!-")
corner7 = landrush.can_interact({x=pos.x+1,y=pos.y+1,z=pos.z+1},"-!-")
if corner0 and corner1 then
return landrush.default_flame_should_extinguish(pos)
else
return true
end
local def = minetest.registered_nodes["fire:basic_flame"]
if def then
-- Do not allow flames in or around protected areas
local default_on_construct = def.on_construct
def.on_construct = function(pos)
if landrush.can_interact_in_radius(pos, "", 1) then
return default_on_construct(pos)
end
minetest.remove_node(pos)
end
-- Extinguish flames in and around protected areas
-- this is needed because voxelmanip can set a node without
-- triggering the on_construct callback
minetest.register_abm({
nodenames = {"fire:basic_flame"},
interval = 3,
chance = 1,
catchup = true,
action = function(pos)
if not landrush.can_interact_in_radius(pos, "", 1) then
minetest.remove_node(pos)
minetest.sound_play("fire_extinguish_flame",
{pos = pos, max_hear_distance = 16, gain = 0.25})
end
end
})
end

View File

@ -118,12 +118,16 @@ if ( minetest.get_modpath("money2") ) then
dofile(path.."/landsale.lua")
end
if ( minetest.get_modpath("fire") ) then
minetest.log('action','[landrush] adding fire protection to claimed areas')
dofile(path.."/fire.lua")
end
minetest.after(0, function ()
dofile(path.."/default.lua")
--dofile(path.."/bucket.lua")
dofile(path.."/doors.lua")
dofile(path.."/fire.lua")
dofile(path.."/chatcommands.lua")
--dofile(path.."/screwdriver.lua")
dofile(path.."/snow.lua")

View File

@ -28,6 +28,23 @@ function landrush.grief_alert(pos, name)
)
end
function landrush.can_interact_in_radius(pos, name, r)
local corners = { {x=pos.x+r, y=pos.y+r, z=pos.z+r},
{x=pos.x+r, y=pos.y+r, z=pos.z-r},
{x=pos.x+r, y=pos.y-r, z=pos.z+r},
{x=pos.x+r, y=pos.y-r, z=pos.z-r},
{x=pos.x-r, y=pos.y+r, z=pos.z+r},
{x=pos.x-r, y=pos.y+r, z=pos.z-r},
{x=pos.x-r, y=pos.y-r, z=pos.z+r},
{x=pos.x-r, y=pos.y-r, z=pos.z-r} }
for _, corner in ipairs(corners) do
if not landrush.can_interact(corner,"") then
return false
end
end
return true
end
function landrush.can_interact(pos, name)
--if ( pos.y < -200 or name == '' or name == nil ) then