Aaron Suen 19652c2fe1 Begin major rework of nodenames matching, autostart DNTs
- Unify logic for expanding nodenames/itemnames lists into indexes
  of matching names, and comparing item names/defs to lists,
  with group expansion and deferral.
- Add "autostart" option to DNTs which registers construction traps
  and a patrol ABM automatically, use for some things that are a
  good match.
- Note that some things are doing more complex logic in ABMs, such
  as determining if a node is eligible, or custom timing logic;
  leave these as-is for now.
2021-08-04 07:41:00 -04:00

42 lines
1.1 KiB
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore, pairs
= minetest, nodecore, pairs
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
minetest.register_abm({
label = "scaling decay",
interval = 1,
chance = 1,
nodenames = {"group:" .. modname},
ignore_stasis = true,
action = function(pos)
local data = minetest.get_meta(pos):get_string("data")
if (not data) or (data == "") then
return minetest.remove_node(pos)
end
data = minetest.deserialize(data)
if minetest.get_node(data.pos).name ~= data.node then
return minetest.remove_node(pos)
end
for _, p in pairs(minetest.get_connected_players()) do
if nodecore.scaling_closenough(pos, p) then return end
end
return minetest.remove_node(pos)
end
})
local dntname = modname .. ":particles"
nodecore.register_dnt({
name = dntname,
time = 1,
loop = true,
autostart = true,
nodenames = {"group:" .. modname .. "_fx"},
action = function(pos)
nodecore.scaling_particles(pos)
return nodecore.dnt_set(pos, dntname, 1)
end
})