mon = peripheral.wrap("right")
mon.clear()
mon.setCursorPos(1,1)
print("Elevator System")
local wires = {colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow, colors.lime, colors.pink, colors.gray}
local num = {1, 2, 4, 8, 16, 32, 64, 128, 256}
local function MidUp()
i = 12
repeat
i = i - 1
rs.setBundledOutput("top", colors.combine(rs.setBundledInput("top"), wires[5]))
sleep(0,5)
rs.setBundledOutput("top", colors.subtract(rs.getBundledInput("top"), wires[5]))
sleep(1)
until
i == 0
end
local function UpMid()
i = 12
repeat
i = i - 1
rs.setBundledOutput("top", colors.combine(rs.getBundledInput("top"), wires[6]))
sleep(0,5)
rs.setBundledOutput("top", colors.subtract(rs.getBundledInput("top"), wires[6]))
sleep(1)
until
i == 0
end
local function DownMid()
i = 12
repeat
i = i - 1
rs.setBundledOutput("top", colors.combine(rs.getBundledInput("top"), wires[7]))
sleep(0,5)
rs.setBundledOutput("top", colors.subtract(rs.getBundledInput("top"), wires[7]))
sleep(1)
until
i == 0
end
local function MidDown()
i = 12
repeat
i = i - 1
rs.setBundledOutput("top", colors.combine(rs.getBundledInput("top"), wires[8]))
sleep(0,5)
rs.setBundledOutput("top", colors.subtract(rs.getBundledInput("top"), wires[8]))
sleep(1)
until
i == 0
end
while true do
local event = os.pullEvent()
if event == "redstone" and rs.testBundledInput("top", wires[1] == true then
print("1")
sleep(2)
UpMid()
sleep(2)
print("1 - done")
elseif event == "redstone" and rs.testBundledInput("top", wires[2] == true then
print("2")
sleep(2)
MidUp()
sleep(2)
print("2 - done")
elseif event == "redstone" and rs.testBundledInput("top", wires[3] == true then
print("3")
sleep(2)
MidDown()
sleep(2)
print("3 - done")
elseif event == "redstone" and rs.testBundledInput("top", wires[4] == true then
print("4")
sleep(2)
DownMid()
sleep(2)
print("4 - done")
end
end
Program doesn't show a mistake, it runs up to print("%n% - done").
May be I should replace
rs.setBundledOutput("top", colors.combine(rs.getBundledInput("top"), wires[8]))
withrs.setBundledOutput("top", colors.combine(rs.setBundledOutput("top"), wires[8]))
But it writes "Bad argument: int expected, got nil".I've got stuck. Show me my mistake, please. I have a strong feeling that I am misunderstanding what I've written.