2021-03-24 06:55:30 -04:00
|
|
|
-- 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({
|
2021-08-07 00:33:48 -04:00
|
|
|
amount = 5,
|
2021-03-24 06:55:30 -04:00
|
|
|
time = 2,
|
|
|
|
minpos = vector.add(item.pos,
|
2021-08-07 00:33:48 -04:00
|
|
|
vector.multiply(item.plane, -0.5)),
|
2021-03-24 06:55:30 -04:00
|
|
|
maxpos = vector.add(item.pos,
|
2021-08-07 00:33:48 -04:00
|
|
|
vector.multiply(item.plane, 0.5)),
|
|
|
|
minacc = vector.multiply(item.plane, -0.05),
|
|
|
|
maxacc = vector.multiply(item.plane, 0.05),
|
|
|
|
minsize = 0.2,
|
2021-03-24 06:55:30 -04:00
|
|
|
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,
|
2022-02-10 22:08:58 -05:00
|
|
|
autostart = true,
|
2021-03-24 06:55:30 -04:00
|
|
|
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
|
|
|
|
})
|