add rainbow wires
This commit is contained in:
parent
bfa1190cfe
commit
7109dd70a2
@ -100,6 +100,8 @@ function network_update()
|
|||||||
local wire = Simulation.getwirebyref(sim, tonumber(data[i+1]))
|
local wire = Simulation.getwirebyref(sim, tonumber(data[i+1]))
|
||||||
if wire ~= nil then
|
if wire ~= nil then
|
||||||
Wire.setlayer(wire, tonumber(data[i+2]))
|
Wire.setlayer(wire, tonumber(data[i+2]))
|
||||||
|
else
|
||||||
|
error("Setlayer: no wire for objref "..tonumber(data[i+1]))
|
||||||
end
|
end
|
||||||
|
|
||||||
i = i + 2
|
i = i + 2
|
||||||
|
@ -184,7 +184,10 @@ function Simulation.connectwireat(sim, wire, x, y, z)
|
|||||||
for k, obj in pairs(objs) do
|
for k, obj in pairs(objs) do
|
||||||
if obj ~= wire and obj.group ~= nil then
|
if obj ~= wire and obj.group ~= nil then
|
||||||
if is_wire(obj) then -- wire
|
if is_wire(obj) then -- wire
|
||||||
if Wire.getlayer(obj) == Wire.getlayer(wire) then -- same layer
|
local layer1 = Wire.getlayer(wire)
|
||||||
|
local layer2 = Wire.getlayer(obj)
|
||||||
|
--if they are on the same real layer, or exactly one is rainbow but not both, then connect
|
||||||
|
if ((layer1==layer2) or (layer1==-1 and layer2~=-1) or (layer1~=-1 and layer2==-1)) and (not (layer1==-1 and layer2==-1)) then
|
||||||
Group.addwire(obj.group, wire)
|
Group.addwire(obj.group, wire)
|
||||||
end
|
end
|
||||||
else -- port
|
else -- port
|
||||||
|
@ -20,7 +20,9 @@ function Wire.setlayer(wire, layer)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Wire.update(wire)
|
function Wire.update(wire)
|
||||||
network_send("WU\t" .. (wire.group.state~=0 and "1" or "0") .. "\t" .. wire.objref .. "\n")
|
if wire.layer~=-1 then
|
||||||
|
network_send("WU\t" .. (wire.group.state~=0 and "1" or "0") .. "\t" .. wire.objref .. "\n")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Wire.setgroup(wire, group)
|
function Wire.setgroup(wire, group)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user