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]))
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -20,8 +20,10 @@ 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)
|
||||
wire.group = group
|
||||
|
Loading…
x
Reference in New Issue
Block a user