How do you add Lua into the path variable so that I can just type
lua filename.lua
in cmd
to run it?
I'm using Windows 8.1 64 bit
You can also do this directly from a cmd.exe
shell. Open a "Command Prompt" and type in:
setx path "x:/your/lua/path/goes/here;%path%" /M
Restart the Command Prompt for it to take effect.
First you must ensure that lua.exe is on your PATH: from the console where you want to run it, just type "lua" and ENTER; if you end up in Lua interpreter, the answer is yes. If you get command not found, you must extend PATH, either in the console (then you will have to do it every time you open a new console), or via the operating system's environment variables (via control panel as described by Yu Hao, or via setx as descripbed by greatwolf).
Once lua.exe is in your PATH, the first command line parameter you provide to the lua.exe must be the path to the .lua file. So if the current working directory in console is C:\Foo\bar, and your script is in C:\Foo\bar, then all you need to type is "lua yourScript.lua". If your script is instead in C:\Foo\cla, then you would type "lua ..\cla\yourScript.lua". To verify what is th current working folder, type "cd" then ENTER, it is the path printed.