Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exit a Lua script's execution?

Tags:

lua

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.

like image 375
Prashant Gaur Avatar asked Nov 25 '13 09:11

Prashant Gaur


People also ask

How do I exit a Lua script?

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.

How do I close Lua Windows?

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.

How do I run a Lua script from the command line?

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.

How do you wait in Lua?

wait() in lua function wait(seconds) local start = os. time() repeat until os. time() > start + seconds end --Exactly the same as the roblox one!


1 Answers

Use os.exit() or just return from some "main" function if your script is embedded.

like image 144
Oleg V. Volkov Avatar answered Sep 23 '22 15:09

Oleg V. Volkov