Post #2651378
2025-09-25 19:11 UTC
Normally I'm not a fan of coroutines in #lua, they tend to just make the code confusing.
However, when you have a long, looping process that would normally be run in one go (pathfinding, recursive tree iteration, proc. gen., etc.), coroutines let you run it step-by-step *without changing the code structure at all*, which is awesome for debugging.
Wherever you want to pause your loop, just add:
if coroutine.running() then
coroutine.yield(coroutine.running())
end
...
Replies (0)
No replies.