My problem is that I have a function a() that I need to exit unconditionally at certain times. My question is how would I achieve the goal of exiting a function without conditions.
Example:
local function a()
--Do Stuff
end
a()
Another words, is there a way to exit a() with a single command?
There are only few ways to "exit" a function: return, coroutine.yield (if the function is executed as a coroutine), and error() call (which you can trap with pcall around the function).
I'm not sure what you mean by "exiting a function without conditions", but one of these options should work for you as there is nothing else available. (You can also use debug hook and call error() from it without modifying your function code at all, but I would not expect this to be needed in your case.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With