LUA Programming Introduction
|
|
|
|
|
Before I start throwing any technical mumbo jumbo about LUA programming, first question I need
to answer, which I get asked all the time, is... What is LUA? If you play online game like
World Of Warcraft (WOW) and have used WOW MODs then you know you already know little bit about
LUA. But if you are new to term LUA, then lets say that LUA is a scripting language like Ruby or Javascript.
There is no one to one comparison between LUA and other scripting languages. But we will start with simple
notion of scripting language.
Before we start with introduction to LUA, let me give you the links to official LUA site from where
you can read more about it. The current official version of LUA is 5.1.
Getting started
Every developer starts learning a programming language by writing their "Hello World" program. We will do the same but
first we need to get our environment setup. I will be basing all the discussions about LUA programming for Windows
platform. Lets start by doing the following steps.
Download binaries for LUA from LUA web site by click this link.
For now download lua5_1_Win32_bin.tar.gz file. This compressed file contains the binary files that you will need
to run your LUA scripts. The file contains following files.
- bin2c5.1.exe
- lua5.1.dll
- lua5.1.exe
- luac5.1.exe
For now we only need lua5.1.exe which is standalone interpretter for LUA scripts. I will discuss the details
about each files in later articles when we get our hands little wet with LUA.
-
Uncompress this file into a folder.
-
Modify your system environment to include this folder's path in executable search folders. This way you can execute
LUA scripts from any folder on your system. Otherwise you will have to reference lua5.1.exe with full path.
-
To verify if you have modified the PATH environment variable correctly,
Open a command window and type "lua5.1.exe". You should a message like the following image.
Hello LUA
Now we are ready to write our first LUA script. Open Notepad and type following line of code as save the file with extension .lua.
print("Hello LUA")
Now from command prompt type the command as show in following image and you will see message displayed on console.
It could not get simpler than this. In next article we will see how you can declare variables, write functions and call them in
your script's flow.
|