add rainbow wires

This commit is contained in:
Redo0 2021-06-07 15:38:25 -05:00
parent bfa1190cfe
commit 7109dd70a2
3 changed files with 9 additions and 2 deletions

View File

@ -100,6 +100,8 @@ function network_update()
local wire = Simulation.getwirebyref(sim, tonumber(data[i+1]))
if wire ~= nil then
Wire.setlayer(wire, tonumber(data[i+2]))
else
error("Setlayer: no wire for objref "..tonumber(data[i+1]))
end
i = i + 2

View File

@ -184,7 +184,10 @@ function Simulation.connectwireat(sim, wire, x, y, z)
for k, obj in pairs(objs) do
if obj ~= wire and obj.group ~= nil then
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)
end
else -- port

View File

@ -20,7 +20,9 @@ function Wire.setlayer(wire, layer)
end
function Wire.update(wire)
if wire.layer~=-1 then
network_send("WU\t" .. (wire.group.state~=0 and "1" or "0") .. "\t" .. wire.objref .. "\n")
end
end
function Wire.setgroup(wire, group)