In this post I will give information about Lua. I will tell how to install it. I will give my personal opinions about Lua, what I consider its pros and cons as I understand it right now.
I stress that I have never worked with Lua. Therefore there is a lot to learn.
I installed Lua on Linux Mint 19.3.
I recommend that everyone first installs Lua on a virtual machine. VirtualBox is excellent for this use. Download the Linux Mint 19.3 iso and install it on VirtualBox.
Lua itself is found on
as lua-5.3.5.tar.gz
Before building Lua install this:
sudo apt-get install build-essential
sudo apt-get install libreadline-dev
Then extract and:
cd ~/Downloads/lua-5.3.5
make linux
Install Lua with:
sudo make linux install
lua and luac will now be in /usr/local/bin
luac is the ‘compiler’ of Lua scripts
lua both runs Lua scripts and compiled Lua scripts
In Geany:
luac -o “%e” “%f” as Build command
lua “%e” as Run command
As I understand it, the most used libray for making Lua GUI componets is wxWidgets.
Latest Stable Release: 3.0.4
Before building install this:
sudo apt-get install libgtk2.0-dev
sudo apt-get install freeglut3-dev
sudo apt-get install libcppunit-dev
sudo apt-get install libwebkitgtk-dev
Then extract to wxWidgets-3.0.4 and:
cd wxWidgets-3.0.4
mkdir buildgtk
cd buildgtk
First you need to configure the Make. There are many options and for the time being I chose these:
../configure --with-opengl --with-gtk –with-regex
The option –enable-debug will of course be of use (and many others). Then:
make
sudo make install
sudo ldconfig
The ‘make’ step will take some time.
wxLua is a “Lua scripting language wrapper around the wxWidgets cross-platform C++ GUI library”.
wxlua.sourceforge.net/download.php
wxLua-2.8.12.3-src.tar.gz
First install Cmake-qt-gui in Software Manager. You also need to install this:
sudo apt-get install libncurses5-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install doxygen
Then (in any location)
mkdir wxLua-build
Start Cmake and locate extracted wxLua-2.8.12.3-src folder and the wxLua-build folder. I recommend
Options->Warning Messages->Suppress Warnings->Developer Warnings
Remove media from wxLuaBind_COMPONENTS and xWidgets_COMPONENTS
Click Configure several times. Finally press Generate. Go to wxLua-build and
make
There is a tool for building self-running Lua programs called srlua.
webserver2.tecgraf.puc-rio.br/~l … lua/#srlua
Extract to folder srlua-102. In folder:
make
sudo make install
I have found that srlua works well for non-wx scripts.
srglue /usr/local/bin/srlua test.lua test
./test
For wx scripts add this at the top:
package.cpath = '../wxLua-build/lib/Debug/lib?.so'
require('wx')
It compiles without errors but running it (as lua ./wxtest) gives a Segmentation fault (core dumped).
But this works for the same script:
../wxLua-build/bin/Debug/wxLua -c wxtest.lua
It would be nice if a compiled Lua script could be distributed without the user having to download anything else (like we have to download the Java run-time).
Pros and cons for Lua in my opinion:
Pros:
- Sandboxing for security, see lua-users.org/wiki/SandBoxes. Obviously Lua must have the ability to save games on the host file system.
- Lua has its own IDE with debugging, see f.ex studio.zerobrane.com/
- The huge flexibility of a scripting language. In Vassal all modules are really just scripts. Instead of inventing a meta-language (or making java custom classes) the modules can use the script Vassal itself is made of.
Cons:
- Lua is unknown to many (ulike Java) and needs to be learned. It is a different language from, say, Javascript. It does not have the wide knowledge-base as Java has.
- Lua programs need to be distributed in different variants, for Windows, Linux, Mac and Andriod. In Java the work is already done for us in the Java runtime.
- Lua is not strictly an object-orientated language though it has object orientation features,
read here: lua-users.org/wiki/ObjectOrientationTutorial. What impact this will have on the development of a large program I don’t know. A strong-typed language is always an advantage.
As I said, this is just based on my very superficial knowledge of Lua. I hope others can expand on it. The ability and proficiently of manipulating images in the GUI (scaling and rotating) will be most important.