For example, if I were to call a function in a module containing coroutine.running() from a function in another script, would coroutine.running() return the other script, the function in that script, or the function in the module?
what it does: coroutine.running() returns a reference to the currently running coroutine (lightweight thread).
It also returns a boolean indicating if the execution is within the main coroutine.
ex:
local coroutineRef, _ = coroutine.running()
-- Here, coroutineRef will refer to the main coroutine, and _ will be true
end
isInMainCoroutine() -- Called from the main script
coroutine.running() is useful for checking the coroutine context, not for pinpointing the exact function or script.