Only allow trigger nodes if they don’t connect through one directly

This commit is contained in:
Valentin Anger 2017-08-21 18:20:39 +02:00
parent a526fc56ea
commit 93f98146e1

View File

@ -34,6 +34,8 @@ local function net_build(pos, callerpos, master_arg)
master = master_arg
end
local onode = minetest.get_node(pos)
-- Add node to the list of processed nodes so that it wont be processed again
-- A node can show up multiple times in this list!
processed[#processed + 1] = pos
@ -67,11 +69,12 @@ local function net_build(pos, callerpos, master_arg)
-- net passives are followed along to create the network (aka cables) but they do not get power,
-- and are not considered by the network
-- TODO recursion
local ntrigontrig = (net_trigger == 1 and (minetest.get_item_group(onode.name, "sparktech_net_trigger") == 0)) -- Only allow trigger node if the source node it not a trigger node
if (net_trigger == 1 and master == nil) then
master = nodepos;
meta:set_string("net_master", nil)
end -- if no master is set the code will just run around checking for one, if it doesnt find one well, doesnt matter, its just cables then
if (master ~= nil and net_trigger == 1 and nodepos ~= master) then -- we have a master, so we can store stuff in it :D
if (master ~= nil and ntrigontrig and nodepos ~= master) then -- we have a master, so we can store stuff in it :D
meta:set_string("net_master", nil)
-- the node is a trigger, so we store their stuff in the master node
-- at this point it could be the master if we set it above
@ -80,7 +83,7 @@ local function net_build(pos, callerpos, master_arg)
-- Now the node shouldnt be processed by the net_build anymore
processed[#processed + 1] = nodepos
end
if (net_passive == 1 or net_trigger == 1) then
if (net_passive == 1 or ntrigontrig) then
net_build(nodepos, pos)
end
end