I want to exit execution of Lua script on some condition . Example :
content = get_content() if not content then -- ( Here i want some kind of exit function ) next_content = get_content() --example there can lot of further checks
Here I want that if I am not getting content my script suppose to terminate is should not go to check to next.
To exit the interactive mode and the interpreter, just type end-of-file ( ctrl-D in Unix, ctrl-Z in DOS/Windows), or call the exit function, from the Operating System library (you have to type os. exit()<enter> ). In interactive mode, Lua usually interprets each line that you type as a complete chunk.
Try control-D in Unix, control-Z in Windows or os. exit() if you must. I've found one situation where only os. exit() works: the interactive lua shell of the lua.
To run a Lua scriptOpen the Lua Script Library through Prepare > Run Lua Script. Use the appearing dialog to load, save, and execute Lua scripts as well as to create new ones. Select the script to be run. Click Execute Script.
wait() in lua function wait(seconds) local start = os. time() repeat until os. time() > start + seconds end --Exactly the same as the roblox one!
Use os.exit()
or just return
from some "main" function if your script is embedded.
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