How to install Lua on Windows?

eyexo

New Member
Joined
Jan 6, 2020
Messages
2
Reaction score
2
I'm new to the Lua programming language. How to install Lua on Windows?
I've searched for videos but no luck.
 

stetre

Member
Joined
Jan 8, 2020
Messages
9
Reaction score
10
Location
Italy
There are several ways to do it. I personally favour using the MSYS2 installer because it also allows me
to build a lot of useful other packages. The method goes as follows:

1) Download and install MSYS2 following the instructions at the link above. Then, assuming MSYS2 is installed
at the default location C:\msys32 (if not, change the paths below accordingly):

2) Open a MinGW shell using the launcher C:\msys32\mingw64.exe (or C:\msys32\mingw32.exe if you
have a 32-bit system), and install Lua using the following command (here the $ sign is the shell prompt):
Bash:
$ pacman -S ${MINGW_PACKAGE_PREFIX}-lua
Now you can use the Lua interpreter from any MinGW shell, by just typing the lua command in it:

Bash:
$ lua
If you want to use it also from the Windows command prompt, you have to append the path C:\msys32\mingw64\bin
to the Windows PATH environment variable (or C:\msys32\mingw32\bin, on a 32-bit system).

(If you don't know what PATH is ,or how to modify it, just google "windows PATH environment variable" and you'll
find plenty of instructions).
 

kinderalpha

Member
Joined
Jan 9, 2020
Messages
8
Reaction score
10
Age
22
Location
Chicago
Lua is often times uses as an embedded language, or an API for scripting within a game environment so Lua outside of either of those implementations isn't quite useful. Are you asking how to install Lua to use it for something specific?

If you're looking to use it for game development, I would suggest looking into Love2D as that's the most recent and to-date usage of Lua for a game development framework.
 

eyexo

New Member
Joined
Jan 6, 2020
Messages
2
Reaction score
2
There are several ways to do it. I personally favour using the MSYS2 installer because it also allows me
to build a lot of useful other packages. The method goes as follows:

1) Download and install MSYS2 following the instructions at the link above. Then, assuming MSYS2 is installed
at the default location C:\msys32 (if not, change the paths below accordingly):

2) Open a MinGW shell using the launcher C:\msys32\mingw64.exe (or C:\msys32\mingw32.exe if you
have a 32-bit system), and install Lua using the following command (here the $ sign is the shell prompt):
Bash:
$ pacman -S ${MINGW_PACKAGE_PREFIX}-lua
Now you can use the Lua interpreter from any MinGW shell, by just typing the lua command in it:

Bash:
$ lua
If you want to use it also from the Windows command prompt, you have to append the path C:\msys32\mingw64\bin
to the Windows PATH environment variable (or C:\msys32\mingw32\bin, on a 32-bit system).

(If you don't know what PATH is ,or how to modify it, just google "windows PATH environment variable" and you'll
find plenty of instructions).
Is there any program with highlighting and error checking where I can just click build like Netbeans?
 

stetre

Member
Joined
Jan 8, 2020
Messages
9
Reaction score
10
Location
Italy
Is there any program with highlighting and error checking where I can just click build like Netbeans?
I'm pretty sure that there are IDEs with support for Lua. I often read good things about Zerobrane, for example,
but honestly I'm not the right person to suggest one because I'm a vim addicted and I develop under Linux using
command line tools and window terminals (and less need for RAM...).

Hopefully some other user can give you more informed suggestion about the available IDEs.
 

kinderalpha

Member
Joined
Jan 9, 2020
Messages
8
Reaction score
10
Age
22
Location
Chicago
Zerobrane is the way to go for that in my opinion. It kinda varies based on what environment you're using Lua for. I use it for Love2D so zerobrane offers out of the box debug and highlighting support for Lua and syntax completion for Love. It has standard highlighting for Lua too. It also is configurable to setup a 'build' path depending on what you need. In my case, I can use it to build, debug, scratchpad, and Iog errors on completion. If you just want a text editor with highlighting then Atom, sublime, and notepad++ are good lightweight options.
 

Ray

New Member
Joined
Feb 4, 2020
Messages
3
Reaction score
2
Age
62
Location
USA
If you're running Cygwin (or MobaXterm, which has Cygwin built in) on your Windows PC, you can install Lua from inside Cygwin. Just use Cygwin's or Lua's package manager, search for "lua", select all of the packages that it offers you (well, that may be too many, but I can't tell you which ones NOT to select), and tell Cygwin to install them.

Then you can type "lua" at the command prompt to get the Lua shell, or "lua myfilename.lua" to execute a Lua file.

(What's "Cygwin"? It's a Linux-like environment, similar to Msys/MinGW.)
 
Top