Posted 14 September 2013 - 01:04 PM
Hello!
I'm working on this lift code. My problem is the marked part of the code. So, what kind of code should I use so that ths part of the code works so that it lets you input and the same time checks the rs-signal. By using a while loop it does it so fast that you simply can't input.
function inputting()
input=read()
end
function rsCheckUp()
if rs.testBundledInput("back",colors.brown)== true then
print("hello")
end
end
function callLift()
for i=1,26 do
rs.setBundledOutput("back",colors.yellow)
sleep(1)
rs.setBundledOutput("back",0)
sleep(1)
end
end
function Up()
end
function start()
rs.setBundledOutput("back",0)
term.clear()
term.setCursorPos(1,1)
print("Lift Control")
print("")
print("1) Call Lift")
parallel.waitForAny(inputting, rsCheckUp) <———————————————————————————————————– THE PROBLEM
if input=="1" and rs.testBundledInput("back",colors.black)==true then
print("Lift Is Already On Current Floor")
sleep(2)
elseif input=="1" then
callLift()
end
end
while true do start()
sleep(5)
end
I'm working on this lift code. My problem is the marked part of the code. So, what kind of code should I use so that ths part of the code works so that it lets you input and the same time checks the rs-signal. By using a while loop it does it so fast that you simply can't input.
function inputting()
input=read()
end
function rsCheckUp()
if rs.testBundledInput("back",colors.brown)== true then
print("hello")
end
end
function callLift()
for i=1,26 do
rs.setBundledOutput("back",colors.yellow)
sleep(1)
rs.setBundledOutput("back",0)
sleep(1)
end
end
function Up()
end
function start()
rs.setBundledOutput("back",0)
term.clear()
term.setCursorPos(1,1)
print("Lift Control")
print("")
print("1) Call Lift")
parallel.waitForAny(inputting, rsCheckUp) <———————————————————————————————————– THE PROBLEM
if input=="1" and rs.testBundledInput("back",colors.black)==true then
print("Lift Is Already On Current Floor")
sleep(2)
elseif input=="1" then
callLift()
end
end
while true do start()
sleep(5)
end