This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
apemanzilla's profile picture

Pull event without stopping execution?

Started by apemanzilla, 18 June 2013 - 06:52 PM
apemanzilla #1
Posted 18 June 2013 - 08:52 PM
I was wondering if there was anyway that, using coroutines (possibly) I could pull events without stopping the main flow of the program? Specifically, update monitors with animations while also waiting for bundled cable updates and monitor touches. Could anyone help please?

Thanks!
Bomb Bloke #2
Posted 18 June 2013 - 09:08 PM
function pullEvents()
        while true do
                event, etc1, etc2, etc3 = os.pullEvent()
                -- Do stuff with the events that get pulled.
        end
end

function updateDisplays()
        while true do
                -- Draw stuff on screens etc.
        end
end

parallel.waitForAny(pullEvents, updateDisplays)
apemanzilla #3
Posted 19 June 2013 - 06:16 AM
function pullEvents()
        while true do
                event, etc1, etc2, etc3 = os.pullEvent()
                -- Do stuff with the events that get pulled.
        end
end

function updateDisplays()
        while true do
                -- Draw stuff on screens etc.
        end
end

parallel.waitForAny(pullEvents, updateDisplays)
Thanks for replying! I'll try this when I get home!