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.lua
it 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.:
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> ).
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.
Add io.read() at the end of your script.
The easiest way would be to just add a 'pause' at the end of your script:
print 'Hello World'
os.execute 'pause'
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