Monitor loop not working
k1ll3rM 21 Feb 2015
I have a problem with the program I wrote but I have no idea how to fix it! I've been searching everywhere but I can't find a solution. I'm a beginner so I would love to have some help!
The problem is that the monitor is not getting it's clock updated as the loop should do! the program is for an over-complicated To Do List just so I have a little project to work on.
here is the code:
The problem is that the monitor is not getting it's clock updated as the loop should do! the program is for an over-complicated To Do List just so I have a little project to work on.
here is the code:
mon = peripheral.wrap("right") function list() local input2 = read() if input2 == ("stop") then start() else print("Unknown Command") list() end shell.run("ToDoList") while not guess == 3 do sleep(0.3) time = os.time() atime = textutils.formatTime(time, false) mon.setCursorPos(10,26) mon.write("Day " .. tostring(os.day())) mon.setCursorPos(1,26) mon.write(atime) end end function start() term.clear() term.setCursorPos(1, 1) print("Enter Command: ") local input = read() if input == ("exit") then os.reboot() elseif input == "list" then list() start() else print("Unknown Command") start() end end start()
HPWebcamAble 21 Feb 2015
What I think is happening is your program never gets to the loop
I'm bored so I rewrote your program
I used the Parallel API. I'd bet you haven't used it before, but it's pretty simple. Here is the Wiki for it: http://computercraft...allel_%28API%29
I'm bored so I rewrote your program
I used the Parallel API. I'd bet you haven't used it before, but it's pretty simple. Here is the Wiki for it: http://computercraft...allel_%28API%29
mon = peripheral.wrap("right") function list() --#shell.run("ToDoList") No idea what this is. Probably another program of yours? while true do sleep(1) local cTime = os.time() cTime = textutils.formatTime(cTime, false) mon.setCursorPos(10,26) mon.write("Day " .. tostring(os.day())) mon.setCursorPos(1,26) mon.write(atime) end end function getInput() while true do --#loops forever local input = read() --#Waits for input if input == "stop" then break --#stops the loop else print("Unknown Command") end end end while true do --#Continues forever term.clear() term.setCursorPos(1, 1) print("Enter Command:") local input = read() if input == "list" then parallel.waitForAny(list,getInput) --#Basically this allows both to run at the same time. When either stops, the other is also stopped elseif input == "exit" then print("Exiting...") sleep(1) break --#Stops the loop else print("Unknown command") end end
k1ll3rM 21 Feb 2015
HPWebcamAble, on 21 February 2015 - 08:39 PM, said:
What I think is happening is your program never gets to the loop
I'm bored so I rewrote your program
I used the Parallel API. I'd bet you haven't used it before, but it's pretty simple. Here is the Wiki for it: http://computercraft...allel_%28API%29
I'm bored so I rewrote your program
I used the Parallel API. I'd bet you haven't used it before, but it's pretty simple. Here is the Wiki for it: http://computercraft...allel_%28API%29
mon = peripheral.wrap("right") function list() --#shell.run("ToDoList") No idea what this is. Probably another program of yours? while true do sleep(1) local cTime = os.time() cTime = textutils.formatTime(cTime, false) mon.setCursorPos(10,26) mon.write("Day " .. tostring(os.day())) mon.setCursorPos(1,26) mon.write(atime) end end function getInput() while true do --#loops forever local input = read() --#Waits for input if input == "stop" then break --#stops the loop else print("Unknown Command") end end end while true do --#Continues forever term.clear() term.setCursorPos(1, 1) print("Enter Command:") local input = read() if input == "list" then parallel.waitForAny(list,getInput) --#Basically this allows both to run at the same time. When either stops, the other is also stopped elseif input == "exit" then print("Exiting...") sleep(1) break --#Stops the loop else print("Unknown command") end end
k1ll3rM 21 Feb 2015
k1ll3rM, on 21 February 2015 - 10:15 PM, said:
HPWebcamAble, on 21 February 2015 - 08:39 PM, said:
What I think is happening is your program never gets to the loop
I'm bored so I rewrote your program
I used the Parallel API. I'd bet you haven't used it before, but it's pretty simple. Here is the Wiki for it: http://computercraft...allel_%28API%29
I'm bored so I rewrote your program
I used the Parallel API. I'd bet you haven't used it before, but it's pretty simple. Here is the Wiki for it: http://computercraft...allel_%28API%29
mon = peripheral.wrap("right") function list() --#shell.run("ToDoList") No idea what this is. Probably another program of yours? while true do sleep(1) local cTime = os.time() cTime = textutils.formatTime(cTime, false) mon.setCursorPos(10,26) mon.write("Day " .. tostring(os.day())) mon.setCursorPos(1,26) mon.write(atime) end end function getInput() while true do --#loops forever local input = read() --#Waits for input if input == "stop" then break --#stops the loop else print("Unknown Command") end end end while true do --#Continues forever term.clear() term.setCursorPos(1, 1) print("Enter Command:") local input = read() if input == "list" then parallel.waitForAny(list,getInput) --#Basically this allows both to run at the same time. When either stops, the other is also stopped elseif input == "exit" then print("Exiting...") sleep(1) break --#Stops the loop else print("Unknown command") end end