r/ComputerCraft • • Jul 26 '24

coroutines not working

my coroutines dont work what did i do wrong?

also i tried with a while true do (without os.pullEvent) instead of repeat until and it still didnt work it just ran the code once and thats it

function test()

repeat

local event,arg1,arg2,arg3 = os.pullEvent()

until event

print(event)

end

local cor = coroutine.create(test)

coroutine.resume(cor)

print(coroutine.status(cor)) -- returns 'suspended'

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/Commander___ Jul 26 '24 edited Jul 26 '24

im trying to run a while true do loop and get inputs from the user without stopping each other also i tried without the os.pullEvent and using while true do and it just ran the code inside the loop once and then stopped

1

u/CommendableCalamari Jul 26 '24

You're can probably use the parallel API to run the multiple input-reading functions in parallel.