Posted 18 July 2014 - 12:42 AM
I want to have 3 functions/blocks of code running at the same time/parallel.
I need to have a mouse event listener, and a keyboard event listener working parallel, separately from the main loop i'm working in.
How would I achieve this? I tried coroutine.wrap but it had no successful results
Code I tried but didn't have the 2 runtime functions running parallel:
I need to have a mouse event listener, and a keyboard event listener working parallel, separately from the main loop i'm working in.
How would I achieve this? I tried coroutine.wrap but it had no successful results
Code I tried but didn't have the 2 runtime functions running parallel:
function runtimeMouse()
while true do
local event, button, xPos, yPos = os.pullEvent("mouse_click")
print("Mouse button clicked: ", button, " => Click Position X: ", xPos, " => Click Position Y: ", yPos)
end
end
function update()
print("hey gimme input;")
local i = read()
if i == "exit" then
return false
end
return true
end
function runtime()
while true do
local cont = update()
if not cont then
break
end
end
end
coroutine.resume(coroutine.create(runtimeMouse))
runtime()
Edited on 17 July 2014 - 10:51 PM