There is one room with a lot of Ind.Craft2/Redpower stuff. Two cobblestone generators, recycler, mass-fabricator, filters, retrievers, item detectors, lights and so on. Most of cables does an infinity loop of on/off signals with various time intervals to machines. And I need these being controlled by CC terminal. It should be controlled by pressing a key (on/off).
But I have encountered a problem. As I said, most of a signals are looped. And I can't switch on some machines at the same time.
local keys = {"1", "2", "3", "4", "5", "6"}
local wires = {colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow, colors.lime, colors.pink, colors.gray, colors.lightGray, colors.cyan, colors.purple, colors.blue, colors.brown, colors.green, colors.red}
local num = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}
local function CobGen1()
rs.setBundledOutput("back", colors.combine(rs.getBundledInput("back"), wires[1]))
sleep(1)
rs.setBundledOutput("back", colors.subtract(rs.getBundledInput("back"), wires[1]))
sleep(1)
end
local function CobGen2()
rs.setBundledOutput("back", colors.combine(rs.getBundledInput("back"), wires[3]))
sleep(1)
rs.setBundledOutput("back", colors.subtract(rs.getBundledInput("back"), wires[3]))
sleep(1)
end
local function Manage()
while true do
local event, key = os.pullEvent()
if event == "char" and key = keys[1] then
rs.setBundledOutput("back", colors.subtract(rs.getBundledInput("back"), wires[2]))
while true do
CobGen1()
end
else
rs.setBundledOutput("back", colors.combine(rs.getBundledInput("back"), wires[2]))
end
if event == "char" and key = keys[2] then
rs.setBundledOutput("back", colors.subtract(rs.getBundledInput("back"), wires[4]))
while true do
CobGen2()
end
else
rs.setBundledOutput("back", colors.combine(rs.getBundledInput("back"), wires[4]))
end
end
end
Manage()
It is an example of a code. Of course there will be much more functions and conditions.
May be I should make a lot of events and then do a parallel,waitForAny(Event1, Event2,…..)? Is it possible?
Any ideas?