Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua (Command Line) remain open after execution

I have searched far and wide for this but I cannot seem to find it. Is there any way to execute a Lua script via double clicking it (to execute it in Lua (Command Line)) and keep it open after execution?

For example:

print("Hello World")

This code compiles and runs, however if I double click on hello.luait runs and closes immediately without leaving my text on screen. I want something more like this, but without having to go to Command Prompt, changing directory a bunch of times, typing lua file.lua, etc.:

Command Prompt

like image 381
MrHappyAsthma Avatar asked Jun 12 '13 17:06

MrHappyAsthma


People also ask

How do I turn off Lua interpreter?

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> ).

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.


2 Answers

Add io.read() at the end of your script.

like image 91
Paul Kulchenko Avatar answered Oct 07 '22 23:10

Paul Kulchenko


The easiest way would be to just add a 'pause' at the end of your script:

print 'Hello World'
os.execute 'pause'
like image 33
greatwolf Avatar answered Oct 07 '22 22:10

greatwolf