2017-01-08 16:03:29 -08:00
|
|
|
-- © 2017 numberZero
|
|
|
|
-- License: GNU Lesser General Public License, version 2 (or any later version)
|
|
|
|
|
2017-01-11 14:59:45 -08:00
|
|
|
local OVERLOAD_THRESHOLD = 50.0
|
2017-01-08 16:03:29 -08:00
|
|
|
|
|
|
|
local function splitter_rules_in(node)
|
2017-01-11 14:02:39 -08:00
|
|
|
return {
|
|
|
|
digiline_routing.get_base_rule(0, node.param2),
|
|
|
|
digiline_routing.get_base_rule(2, node.param2),
|
|
|
|
}
|
2017-01-08 16:03:29 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function splitter_rules_out(node)
|
2017-01-11 14:02:39 -08:00
|
|
|
return {
|
|
|
|
digiline_routing.get_base_rule(1, node.param2),
|
|
|
|
}
|
2017-01-08 16:03:29 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function splitter_place(...)
|
|
|
|
return (digiline_routing.multiblock.build2("digiline_routing:splitter", "digiline_routing:splitter_b", ...)) -- adjust to 1 value
|
|
|
|
end
|
|
|
|
|
|
|
|
local function splitter_cleanup(pos, node)
|
|
|
|
digiline_routing.overheat.forget(pos)
|
|
|
|
digiline_routing.multiblock.dig2(pos, node)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function splitter_in_action(pos, node, channel, msg)
|
2017-01-08 16:24:26 -08:00
|
|
|
if digiline_routing.overheat.heat(pos) > OVERLOAD_THRESHOLD then
|
2020-05-26 09:03:56 -07:00
|
|
|
minetest.remove_node(pos)
|
|
|
|
splitter_cleanup(pos, node)
|
2017-01-11 14:59:45 -08:00
|
|
|
minetest.add_item(pos, "digiline_routing:splitter")
|
2017-01-08 16:24:26 -08:00
|
|
|
return
|
|
|
|
end
|
|
|
|
local off = minetest.facedir_to_dir(node.param2)
|
|
|
|
local slave = vector.add(pos, off)
|
|
|
|
digiline:receptor_send(slave, splitter_rules_out(node), channel, msg)
|
2017-01-08 16:03:29 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function splitter_out_action(pos, node, channel, msg)
|
2017-01-08 16:24:26 -08:00
|
|
|
local off = minetest.facedir_to_dir(node.param2)
|
|
|
|
local master = vector.subtract(pos, off)
|
|
|
|
if digiline_routing.overheat.heat(master) > OVERLOAD_THRESHOLD then
|
2020-05-26 09:03:56 -07:00
|
|
|
minetest.remove_node(master)
|
|
|
|
splitter_cleanup(master, node)
|
2017-01-11 14:59:45 -08:00
|
|
|
minetest.add_item(master, "digiline_routing:splitter")
|
2017-01-08 16:24:26 -08:00
|
|
|
return
|
|
|
|
end
|
|
|
|
digiline:receptor_send(master, splitter_rules_in(node), channel, msg)
|
2017-01-08 16:03:29 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_node("digiline_routing:splitter", {
|
|
|
|
description = "Digiline Splitter",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {
|
|
|
|
"digiline_routing_metal.png"
|
|
|
|
},
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2017-01-11 13:51:31 -08:00
|
|
|
is_ground_content = false,
|
2017-01-08 16:03:29 -08:00
|
|
|
groups = {dig_immediate=2},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{ -1/16, -8/16, 4/16, 1/16, -7/16, 24/16 },
|
|
|
|
{ -8/16, -8/16, -1/16, 8/16, -7/16, 1/16 },
|
2017-01-08 16:24:26 -08:00
|
|
|
{ -6/16, -8/16, -2/16, 6/16, -6/16, 2/16 },
|
|
|
|
{ -5/16, -8/16, 2/16, 5/16, -6/16, 3/16 },
|
|
|
|
{ -4/16, -8/16, 3/16, 4/16, -6/16, 4/16 },
|
|
|
|
{ -3/16, -8/16, 4/16, 3/16, -6/16, 5/16 },
|
|
|
|
{ -2/16, -8/16, 5/16, 2/16, -6/16, 16/16 },
|
|
|
|
{ -4/16, -8/16, 16/16, 4/16, -6/16, 20/16 },
|
|
|
|
{ -3/16, -8/16, 20/16, 3/16, -6/16, 21/16 },
|
2017-01-08 16:03:29 -08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
on_place = splitter_place,
|
|
|
|
after_destruct = splitter_cleanup,
|
2017-01-11 13:51:47 -08:00
|
|
|
on_rotate = digiline_routing.multiblock.rotate2,
|
2017-01-08 16:03:29 -08:00
|
|
|
digiline = {
|
|
|
|
effector = {
|
|
|
|
action = splitter_in_action,
|
|
|
|
rules = splitter_rules_in,
|
|
|
|
},
|
|
|
|
receptor = {
|
|
|
|
rules = splitter_rules_in,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2020-05-20 14:00:00 -07:00
|
|
|
mesecon.register_mvps_stopper("digiline_routing:splitter")
|
2017-01-08 16:03:29 -08:00
|
|
|
|
|
|
|
minetest.register_node("digiline_routing:splitter_b", {
|
|
|
|
description = "<<INTERNAL>> Digiline Splitter (Part B)",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {
|
|
|
|
"digiline_routing_metal.png"
|
|
|
|
},
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2017-01-11 13:51:31 -08:00
|
|
|
is_ground_content = false,
|
|
|
|
pointable = false,
|
2017-01-08 16:03:29 -08:00
|
|
|
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2017-01-11 13:51:31 -08:00
|
|
|
fixed = {},
|
2017-01-08 16:03:29 -08:00
|
|
|
},
|
2017-01-11 13:51:31 -08:00
|
|
|
drop = "",
|
2018-11-29 04:29:57 -08:00
|
|
|
on_dig = digiline_routing.multiblock.dig2b,
|
2017-01-11 13:51:47 -08:00
|
|
|
on_rotate = digiline_routing.multiblock.rotate2b,
|
2017-01-08 16:03:29 -08:00
|
|
|
digiline = {
|
|
|
|
effector = {
|
|
|
|
action = splitter_out_action,
|
|
|
|
rules = splitter_rules_out,
|
|
|
|
},
|
|
|
|
receptor = {
|
|
|
|
rules = splitter_rules_out,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2020-05-20 14:00:00 -07:00
|
|
|
mesecon.register_mvps_stopper("digiline_routing:splitter_b")
|