Lua - First steps in programming in LuaODP Deutsch

First steps: [Hello World][Operators][Variables][If][Loops][Functions] ♦♦

You are here:Lua

Hints and Tipps for the programming language Lua

Lua is a small and compact Script langauge. Lua is attached to C-Hosts-Programms and is often used for computer games.

There are plans to include Lua to pdfLaTeX.

Using Lua as Stand-Alone-Interpreter

You can use Lua also as a stand alone scripting language.

lua [options] [script [args]]

Options are:

Executes stdin al a script
-e stat
Execute the string stat
-l file
Loads the file file
interactive mode after executing your script
Version informationen
Stop the following options


To use Lua in Scite, you must adapt the By default there is the following Definition:

command.go.*.lua=Lua-5.0.exe "$(FileNameExt)"

There you can replace Lua-5.0.exe with the interpreter (and path) you installed on your PC.


Create a file lua.bat and add the following code:

@echo off
rem Adapt for your path
Lua.exe %1 %2 %3

Coding Examples

With my first steps, I made some testing scripts. You will find them in the section First steps with Lua.

The exampls are not made for beginners, you should know the basic principles of programming. The examples show, how it is made with Lua, it shows some principles of coding.

You can see small scripts and the resulting output. If you prefer to print the examples, please use the PDF-Document Lua - First Steps in Programming (Actually only German, translation in process). You find the coding examples in the file . 1

Some generell remarks on programming in Lua:

Conventionen of Names in Lua

Lua and TeX


There is a pdfTeX -Version, with Lua as an embedded Scriptlanguage:

Target is to have TeX-Input like

\lua{a = 1.5 ; b = 1.8 ; c = a*b ; tex.print(c) ;}
    a = 1
    b = 2
    c = a*b

With the result



The TeX-Package listings.sty enables TeX to typeset programm code.

Lua is not supported up to now (7. März 2007), but it is in process. In you find a temporary defininition for listings.sty.

Lua in the net Internet

1In you get the sourcecode of the TeX-files to create the PDF.