Posted 28 March 2012 - 02:16 AM
Having trouble with some code and can't seem to figure out what I'm doing wrong.
I'm reasonably confident that the issue is with the loop. That wouldn't surprise me because its an error I'm having trouble understanding with regards to programming for some reason. In any event, when the "while true do" and the "end" that closes it are removed, the program works as expected as long as someone is at the computer terminal with it open. When the "while true do" and "end" code are added in, the program appears to run properly, however, the redstone never activates despite the computer receiving redstone input.
Thanks for any help!
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Train Control System v1.0")
textutils.slowPrint("Copyright 2012. Rights Reserved.")
print("Waiting for input...")
while true do
event, param1, param2 = os.pullEvent()
if event == "redstone" then
sleep(10)
redstone.setOutput("left", true)
sleep(1)
redstone.setOutput("left", false)
end
end
I'm reasonably confident that the issue is with the loop. That wouldn't surprise me because its an error I'm having trouble understanding with regards to programming for some reason. In any event, when the "while true do" and the "end" that closes it are removed, the program works as expected as long as someone is at the computer terminal with it open. When the "while true do" and "end" code are added in, the program appears to run properly, however, the redstone never activates despite the computer receiving redstone input.
Thanks for any help!