nodecore-cd2025/mods/nc_optics/domainwalls.lua
Aaron Suen a2f81d9ee1 DNT auto-start refinements
- Regen with LBM too.
- Allow different delay time for "just loaded" case.
- Use DNT auto-start for more things, replacing
  regen ABM/LBM where possible.

Also tried to improve door ablation reliabiity:
- Use DNT autostart for door ablation.
- Faster DNT check so we don't need the ABM
  neighbor scan anymore.
- On early ablation trigger, set DNT for right after
  cooldown ends instead of letting DNT loop die,
  removing one scenario that could cause
  sponge squeezer stalls.
2022-02-10 22:08:58 -05:00

69 lines
1.9 KiB
Lua

-- LUALOCALS < ---------------------------------------------------------
local ipairs, minetest, nodecore, pairs, vector
= ipairs, minetest, nodecore, pairs, vector
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local active = {}
local function particles(item, player)
local key = player:get_player_name() .. minetest.pos_to_string(item.pos, 1)
.. minetest.pos_to_string(item.plane)
local found = active[key]
local now = minetest.get_us_time() / 1000000
if found and found.exp > now then return end
found = {
exp = now + 2,
id = minetest.add_particlespawner({
amount = 5,
time = 2,
minpos = vector.add(item.pos,
vector.multiply(item.plane, -0.5)),
maxpos = vector.add(item.pos,
vector.multiply(item.plane, 0.5)),
minacc = vector.multiply(item.plane, -0.05),
maxacc = vector.multiply(item.plane, 0.05),
minsize = 0.2,
maxsize = 0.5,
minexptime = 1,
maxexptime = 2,
texture = modname .. "_port_output.png",
playername = player.name
})
}
active[key] = found
end
local function processcbb(item)
for _, player in ipairs(minetest.get_connected_players()) do
local pos = player:get_pos()
local diff = pos and vector.subtract(pos, item.pos)
if diff and vector.dot(diff, diff) < 64 then
particles(item, player)
end
end
end
local get_node = minetest.get_node
nodecore.register_dnt({
name = modname .. ":cbbs",
time = 2,
loop = true,
ignore_stasis = true,
autostart = true,
nodenames = {"group:optic_source"},
action = function(pos, node)
local def = minetest.registered_nodes[node.name] or {}
local src = def.optic_source
if not src then return end
src = src(pos, node)
if not src then return end
local cbbs = {}
for _, dir in pairs(src) do
nodecore.optic_scan(pos, dir, nil, get_node, cbbs)
end
for i = 1, #cbbs do processcbb(cbbs[i]) end
end
})