2021-03-21 12:08:08 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2021-12-05 14:11:01 -05:00
|
|
|
local ipairs, minetest, nodecore
|
|
|
|
= ipairs, minetest, nodecore
|
2021-03-21 12:08:08 -04:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local hash = minetest.hash_node_position
|
|
|
|
|
|
|
|
local oldreg = minetest.register_abm
|
|
|
|
function minetest.register_abm(def, ...)
|
|
|
|
if not def.neighbors_invert then return oldreg(def, ...) end
|
|
|
|
|
|
|
|
local nnames = def.nodenames
|
|
|
|
def.nodenames = def.neighbors
|
|
|
|
def.neighbors = nnames
|
|
|
|
|
|
|
|
local oldact = def.action
|
|
|
|
|
2021-12-05 14:11:01 -05:00
|
|
|
local dirty
|
|
|
|
local blocked = {}
|
|
|
|
|
2021-03-21 12:08:08 -04:00
|
|
|
function def.action(pos)
|
2021-12-05 14:11:01 -05:00
|
|
|
if not dirty then
|
|
|
|
dirty = true
|
|
|
|
minetest.after(0, function()
|
|
|
|
blocked = {}
|
|
|
|
dirty = nil
|
|
|
|
end)
|
2021-03-21 12:08:08 -04:00
|
|
|
end
|
|
|
|
for _, npos in ipairs(nodecore.find_nodes_around(pos, nnames, 1)) do
|
2021-12-05 14:11:01 -05:00
|
|
|
local key = hash(npos)
|
|
|
|
if not blocked[key] then
|
|
|
|
blocked[key] = true
|
|
|
|
oldact(npos, minetest.get_node(npos))
|
|
|
|
end
|
2021-03-21 12:08:08 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return oldreg(def, ...)
|
|
|
|
end
|