Posted 09 August 2013 - 02:04 AM
Here's the code:
Now, my hanldeEvents method only print out "Click!" if I make a mouse click before the very first timer finishes. After the time starts updating, no amount of clicking works. Am I missing a yield somewhere in there that's preventing the print or something? I'm thoroughly confused. Any help on this would be appreciated.
EDIT: The clicks should be clearing every time drawTime is called, which is after every timer event.
function drawTime()
local gameTime = os.time()
term.setCursorPos(1, 1)
term.clear()
term.write(textutils.formatTime(gameTime, false))
end
function updateTime()
while true do
os.sleep(4.15) --Yeilds here
drawTime()
end
end
function handleEvents()
local e = {os.pullEvent()} --Yields here
if e[1] == "mouse_click" then
term.setCursorPos(1, 2)
print("Click!")
end
end
--Main Program
local main = coroutine.create(handleEvents)
local time = coroutine.create(updateTime)
local evt = {}
while true do
coroutine.resume(time, unpack(evt))
coroutine.resume(main, unpack(evt))
evt = {os.pullEvent()}
end
Now, my hanldeEvents method only print out "Click!" if I make a mouse click before the very first timer finishes. After the time starts updating, no amount of clicking works. Am I missing a yield somewhere in there that's preventing the print or something? I'm thoroughly confused. Any help on this would be appreciated.
EDIT: The clicks should be clearing every time drawTime is called, which is after every timer event.