This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
What does coroutine.resume() return? And what does it mean?
Started by Jummit, 20 September 2018 - 09:38 AMPosted 20 September 2018 - 11:38 AM
If you call os.pullEvent() in a coroutine, what does coroutine.resume() return?
Edited on 20 September 2018 - 09:40 AM
Posted 20 September 2018 - 11:58 AM
From Lua's documentation on coroutine.resume:
os.pullEvent just passes off it's arguments to coroutine.yield, so you'll either receive true plus the optional filter, or false and an error message.If the coroutine runs without any errors, resume returns true plus any values passed to yield (when the coroutine yields) or any values returned by the body function (when the coroutine terminates). If there is any error, resume returns false plus the error message.
Posted 20 September 2018 - 12:07 PM
Ah, thats where that true comes from! Thanks!From Lua's documentation on coroutine.resume:os.pullEvent just passes off it's arguments to coroutine.yield, so you'll either receive true plus the optional filter, or false and an error message.If the coroutine runs without any errors, resume returns true plus any values passed to yield (when the coroutine yields) or any values returned by the body function (when the coroutine terminates). If there is any error, resume returns false plus the error message.
Posted 20 September 2018 - 12:13 PM
Does the os.pullEvent function just do
function os.pullEvent(filter)
local event, var1, var2, var3 = os.pullEventRaw(filter)
if event=="terminate" then
error("terminated")
end
return event, var1, var2, var3
end
?Edited on 20 September 2018 - 10:13 AM
Posted 20 September 2018 - 12:33 PM
Yes.Does the os.pullEvent function just do -snip-?
Posted 20 September 2018 - 12:53 PM
I didn't expect that to be so close to the actual code :D/>, thanks for the file, there are some other interesting functions in there!Yes.Does the os.pullEvent function just do -snip-?
Posted 20 September 2018 - 04:42 PM
You may find this useful too: http://www.computercraft.info/forums2/index.php?/topic/26369-computercraft-event-system-flowchart/
Posted 21 September 2018 - 09:12 PM
Yeah, I am aware of this. Its pretty damn useful, I just find it hard to wrap my head around what is done by the program, the OS or by the mod.You may find this useful too: http://www.computerc...stem-flowchart/