-
I have tried this code: require("coroutine")
local imdone = false
local function threadhttp()
local request = http.get("https://example.tweaked.cc")
print(request.readAll()) -- (2)
request.close()
imdone = true
end
local coro = coroutine.create(threadhttp)
while imdone == false do
coroutine.resume(coro)
print(coroutine.status(coro))
sleep(0.1)
end Output:
HTTP server has already responded but code will never be executed to (2). CC:T Version: cc-tweaked-1.18.2-1.101.0 |
Beta Was this translation helpful? Give feedback.
Answered by
SquidDev
Dec 23, 2022
Replies: 1 comment 5 replies
-
Aaaah, that's not quite how coroutines and the event system work. You need to resume the coroutine with events you've pulled from further up the coroutine tree. See this recent discussion for a example of how you should be resuming coroutines! |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
rsp4jack
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aaaah, that's not quite how coroutines and the event system work. You need to resume the coroutine with events you've pulled from further up the coroutine tree. See this recent discussion for a example of how you should be resuming coroutines!