I can't find a function for this on the wiki, I need it for a user-input system on my WIP hacking game.
break
is the way to break a loop. return
also works (but obviously has extra functionality of completely exiting a function block instead of just a loop and giving a [set of] value[s]).
The only other way to prevent a loop from continuing is to cause its condition to be false, but in the context of a for
loop that is essentially impossible.
I suppose a third way to stop it would be an error. Those break execution all the way up to the next protected call (pcall
, ypcall
, xpcall
), which is obviously a horrible way to manage your code but maybe something interesting could come of it.