Lua for Windows – A Short Introduction.

1. What is Lua?
2. What is Lua for Windows?
3. What comes with Lua for Windows?
4. Using Lua for Windows.
   4.1 Running Lua Programs.
   4.2 Editing Lua Programs.
   4.3 Debugging Lua Programs.
   4.4 Using Lua without command console.
5. Concise Overview of Lua Programming Language.
6. Libraries included with Lua for Windows.
7. Learn more about Lua.
8. Acknowledgments.



1. What is Lua?

Lua is a small, fast, interpreted scripting language. Lua is the result of a merger of a configuration language (SOL) and a data entry language (DEL) . Lua's original goal was to be an extensible embedded scripting language inside software applications. Lua has been highly successful as an embedded scripting language and is used in many games, firmware and software applications. With the recent addition of modules, Lua now has a standard method to load libraries. Lua together with Lua libraries enables a complete standalone scripting language. 

Lua’s unique focus on extensibility, simplicity, efficiency and portability make it a small yet powerful scripting language. Lua is often used as a Domain Specific Language due to its small size, embeddability and portability.  Lua supports a small set of general features and provides meta-mechanisms to allow the programmer to support programming styles of their choice. 

Lua was developed by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes at the Pontifical University of Rio de Janeiro (PUC-Rio), in Brazil.

Lua means Moon in Portuguese, so be ready for libraries with references to space or the moon, and enjoy.
^

2. What is Lua for Windows?

Lua for Windows is a 'batteries included environment' for the Lua scripting language on Windows.

Lua for Windows combines Lua binaries, Lua libraries with a Lua-capable editor in a single install package for the Microsoft Windows operating system. Lua for Windows contains everything you need to write, run and debug Lua scripts on Windows. A wide variety of libraries and examples are included that are ready to use with Microsoft Windows. Lua for Windows runs on Windows 2000 and newer versions of Windows. Lua and its associated libraries are also available for other operating systems, so most scripts will be automatically cross-platform.

^


3. What comes with Lua for Windows?

Lua for Windows comes with:
Lua Interpreter: Start/Programs/Lua/Lua (Command Line)
Lua Reference: Start/Programs/Lua/Documentation/Lua 5.1 Reference Manual.        
Quick Lua Tour: Start/Programs/Lua/Lua Examples/QuickLuaTour.lua
Examples: Start/Programs/Lua/Lua Examples.
Documents: Start/Programs/Lua/Documentation.
Libraries: See Section 6. Libraries included with Lua for Windows
^

4. Using Lua for Windows.

   4.1  Running Lua Programs. 

The interpreter can be run by typing lua.exe from command prompt:
C:\>lua.exe
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
>
Type in print("hello") press enter, should get back hello
        > print("hello") 
hello
>

To run Lua Script from command line, goto directory containing Lua script and type in name of script at command prompt. 

From Explorer double click on .lua file and Lua interpreter will run that .lua file.

  
From Start/Programs/Lua/SciTE, edit lua script from SciTE press F5 to run. 

^

   4.2  Editing Lua Programs.

From explorer or command line use any text editor you wish.  Save with .lua file name extension and run as decribed above.


From Start/Programs/Lua/SciTE, use SciTE editor to edit a Lua script. 

^

   4.3  Debugging Lua Programs.

From Start/Programs/Lua/SciTE , open your Lua script, then 
Press ALT-R to starting Debug/Continue,

        F9 to toggle breakpoints,
        ALT-C to step one line at a time,
        ALT-N to step over,

        ALT-M to step out,

        ALT-K to kill debug session,

        ALT-L to show local variables,

        ALT-I to inspect variable,

        ALT-CTRL-B for stack stack,

        ALT-W to watch variable,

        ALT-G goto a specific line as debugging.

SciTE also has toolbar buttons for most common debug operations. 

^ 

   4.4 Using Lua without command console.

To run Lua scripts without a command console use wlua.exe. GUI examples from IUP library have been renamed to *.wlua and run without a  console. For example, from Start/Programs/Lua/Lua Examples go to iup\elem\iupmenu directory and double click on iupmenu.wlua to run a GUI app. 

^

5. Concise Overview of Lua Programming Language.

Lua is a simple yet powerful dynamically typed programming language. Lua is one of the fastest, if not fastest, interpreted scripting languages available, see http://dada.perl.it/shootout/craps.html.

Lua has 8 basic types: nil, boolean, number, string, table, function, thread, userdata.

Numbers are floating point values. Strings are non-mutable. Table is the basic data structure used to represent complex data. 

Lua has 21 reserved keywords: and, break, do, else, elseif, end, false, for, function, if, in, local, nil, not, or, repeat, return, then, true, until, while.

Lua has 6 control structures: do end block statement, if statement, while statement, repeat until statement, for statement and break statement.

Lua has multiple assignments and  return multiple values from functions.

Lua has garbage collection, closures, tail calls, coercion, co-routines, first order functions, meta-mechanisms and loadable libraries.

Lua is a multi-paradigm language and uses meta-mechanisms to extend Lua to support different styles of programming including object-oriented and functional styles.

Lua is a very powerful; condensed scripting language.
^

6. Libraries included with Lua for Windows

Library

Version

Description

Alien

0.5.0

Provides access to functions in an unknown or new .dll.

IUP

3.5.0

Light Portable Graphical User Interface library.

CD

5.4.1

Canvas Draw: A platform-independent graphic library.

IM

3.6.3

A toolkit for Digital Imaging.

Ex

Jan 07

Adds environment, file system, I/O (Locking and pipes), and process control.

LPeg

0.10

Pattern-matching library based on Parsing Expression Grammars (PEGs).

Lua-GD

2.9.33r2

Image manipulation library based on Thomas Boutell’s GD library.

LuaCOM

1.4

Enable use & implementation of Microsoft’s Component Object Model.

LuaCURL

1.0

Interface to Internet browsing capabilities based on the cURL library.

Date

2

Date and Time library for Lua.

LuaDoc

3.01

Documentation tool for Lua source code.

LuaExpat

1.1.0

Lua interface to XML Expat parsing library.

LuaFileSystem

1.4.2

Access the directory structure and file attributes.

LuaLogging

1.2.0

Logging features in Lua, based on log4j.

LuaProfiler

2.0.1

Time profiler designed to find bottlenecks in Lua programs.

LuaSocket

2.0.2

Lua interface to support HTTP,FTP,SMTP, MIME, URL & LTN12.

LuaSQL

2.1.1

Lua interface for PostgreSQL, ODBC, MySQL, SQLite, Oracle, and ADO dbms.

LuaUnit

1.3

Testing framework for Lua.

LuaZip

1.2.3

Read files from zip files.

stdlib

21


Library of modules for common programming tasks, including list, table and functional operations, regexps, objects, pretty-printing and getopt.

lrexlib

2.2

Regular expression library for Lua.

MD5

1.1.2

Basic cryptographic facilities for Lua.

Copas
1.1.5
Dispatcher based on coroutines that can be used by TCP/IP servers.
Coxpcall
1.13
Encapsulates the protected calls with a coroutine based loop,
so errors can be dealed without the usual pcall/xpcall issues with coroutines.
Rings
1.2.2
Provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states.
LOOP
2.3 Beta
LOOP stands for Lua Object-Oriented Programming and is a set of packages for supporting different models of object-oriented programming in the Lua language.
LuaTask
1.6.4
Implements a concurrent and independent Lua execution
environment model.
LuaInterface
1.5.3
Integration between the Lua language and Microsoft .NET platform's Common Language Runtime (CLR).
wxLua
2.8.10
Lua binding to the wxWidgets library
lpack
29 Jun 2007 19:27:20
Lua library for packing and unpacking binary data
VStruct
1.0.2
Provides functions for manipulating binary data
LuaBitOps
1.0.1
Lua BitOp is a C extension module for Lua 5.1 which adds bitwise operations on numbers.
LuaXML
1.3
A module that maps between Lua and XML without much ado
Lanes
2.0.4
Provides the possibility to run multiple Lua states in parallel.
MetaLua
0.5-rc1
A complete macro system with full compatibility with Lua 5.1 sources and bytecode: clean, elegant semantics and syntax, amazing expressive power, good performances, near-universal portability.
LuaGL
1.3
It’s a library that provides access to all of the OpenGL functionality from Lua.
Penlight
0.9.4
Penlight is a set of pure Lua libraries, with only lfs dependency, for extended operations on tables, lists and strings, partially implementing some useful parts of the Python libaries.
lbase64
for Lua 5.1
A base64 library for Lua.
gzio
0.9.0
The Lua gzip file I/O module emulates the standard I/O module, but operates on compressed gzip format files.
Markdown
0.32
This is an implementation of the popular text markup language Markdown in pure Lua.
LuaRS232 1.0.0 Lua binding to librs232 which is a cross-platform rs232 (serial) library.
LeMock 0.6 LeMock (Lua Easy Mock) is a mock creation module intended for use together with a unit test framework such as LuaUnit, lunit or lunity.
Oil 0.4-beta It is a simple, efficient and flexible object request broker written in the Lua language.
LuaJSON 1.2.2 JSON parser/encoder for Lua Parses JSON using LPEG for speed and flexibility. Depending on parser/encoder options, various values are preserved as best as possible
^

7. Learn more about Lua.

Books:

Programming in Lua, 2nd Edition by Robert Ierusalimschy.

This book is also referred to as the Blue PIL. The first

edition is free online at http://www.lua.org/pil/.


Lua Reference Manual, by R. Ierusalimschy, L. H. de Figueiredo, W. Celes. 

Available online at http://www.lua.org/manual/5.1/.


Beginning Lua Programming by Kurt Jung & Aaron Brown. 

Covers many aspects of Lua programming & Lua libraries. 

Web Sites:

http://www.lua.org - Home for the Lua Programming Language.
http://lua-users.org/wiki/TutorialDirectory - Lua tutorials.
http://luaforge.net/ - Home for most Lua Libraries.
http://en.wikipedia.org/wiki/Lua_(programming_language) - Description of Lua. 
^

8. Acknowledgments.

Thanks to Ryan Pusztai for writing Inno Setup scripts from which Lua for Windows is created, and for gathering all the Lua libraries together.

Thanks to Neil Hodgson (Scintilla) , Dave Nicols (clidebugger), and especially Steve Donovan (integrating Lua debugging into SciTE) as well as all the others who worked on SciTE.

Special thanks to Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes for creating the Lua programming language.

And special thanks to all the individuals who created these great Lua libraries; these libraries make Lua for Windows possible.  
^