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

os.pullEvent() or read() do not work in my window manager

Started by Zecradox, 26 May 2018 - 11:35 AM
Zecradox #1
Posted 26 May 2018 - 01:35 PM
I can do simple things in a floating window (like print), but os.pullEvent or read() do not function at all.
(it uses loadfile and coroutines)
Bomb Bloke #2
Posted 26 May 2018 - 02:05 PM
Seems you forgot to link to said window manager. You've also neglected to mention what os.pullEvent() / read() do do - what errors or other unexpected behaviour are you actually encountering?
Zecradox #3
Posted 26 May 2018 - 02:09 PM
Seems you forgot to link to said window manager. You've also neglected to mention what os.pullEvent() / read() do do - what errors or other unexpected behaviour are you actually encountering?
With read(), I get no errors, it just says 'press any key to continue'.
Source code: https://pastebin.com/M4TVQQ8r
/firefly/sys/test.lua is just 'term.write' and 'read()'.
Edited on 26 May 2018 - 12:11 PM
Bomb Bloke #4
Posted 26 May 2018 - 02:19 PM
Ah, right, I'm afraid you can't just resume a coroutine once and expect it to run to completion - ComputerCraft scripts commonly yield, and you need to catch data from them as they do so, before resuming them again with whatever type of event data they might request.

See this example, and / or read this treatise.
Zecradox #5
Posted 31 May 2018 - 02:46 PM
(Fixed)