pullEvent isn't resumed when run in a coroutine
RobertBouillon opened this issue ยท 0 comments
Minecraft Version
1.19.x
Version
1.101.4
Details
Description
If os.pullEvent
is called in a coroutine, it hangs and is never resumed by the cooperative scheduler.
I could be misunderstanding something here, so I apologize if I am. My understanding is that calling pullEvent
should yield until an event occurs. When an event occurs, the task scheduler should call coroutine.resume(co,<event args>...)
on the coroutine that has yielded.
I don't want to use the parallel API because its methods block - I need to run my code in a loop and I want to avoid blocking.
local function CheckInput()
while true do
print("Waiting...")
local evt, key = os.pullEvent("key")
print(key)
end
end
local co = coroutine.create(CheckInput)
coroutine.resume(co) --Start
while true do
--local _, key = os.pullEvent("key")
--print("Works in main loop")
sleep(0)
end
pullEvent
works as expected on the computer's coroutine, but it won't work on a custom one. Am I missing something that might put my custom coroutine on the scheduler's queue?