Jump to content




Pull event without stopping execution?

api computer help

  • You cannot reply to this topic
2 replies to this topic

#1 apemanzilla

  • Members
  • 1,421 posts

Posted 18 June 2013 - 07: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!

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 18 June 2013 - 08: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)


#3 apemanzilla

  • Members
  • 1,421 posts

Posted 19 June 2013 - 05:16 AM

View PostBomb Bloke, on 18 June 2013 - 08:08 PM, said:

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!





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users