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

Two functions at the same Time

Started by MetalMiner, 09 September 2012 - 08:37 PM
MetalMiner #1
Posted 09 September 2012 - 10:37 PM
Hi there

I want to run a function, wich updates a screen, and pull a key event at the same time.
I think, I have to use
parallel.waitForAny

I tried it with these two codes, but no one worked:


parallel.waitForAny(UpdateScreen(), os.pullEvent())

parallel.waitForAny(UpdateScreen, os.pullEvent)


Can someone help me?
(If someone understands my english :D/>/> )

Thanks!
Mmmmmmmm #2
Posted 09 September 2012 - 11:36 PM
If I remember correctly, waitForAny waits for a pull event. When you're trying to run pullEvent and your function at the same time, it's waiting for os.pullEvent to receive input. What you could do is set the os.pullEvent to wait for both a timer that will update the screen when it has counted down, and a key event.