[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Enigma-devel] Level switch to Lua 5.1

From: Ronald Lamprecht
Subject: [Enigma-devel] Level switch to Lua 5.1
Date: Tue, 11 Apr 2006 19:00:23 +0200
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

To all level authors,

Yesterday I switched the enigma development trunk to Lua 5.1. I converted most levels and libs to Lua 5.1 (all libs, enigma_i - enigma_v, tutorial, sokoban, oxyd-clones).

This is a summary of the most important changes I observed. I hope it
helps you to avoid and to analyse problems with future levels:

1. Lua libraries functions now are defined inside tables:
F.e. the math "floor" function is now called as "math.floor". We preload
a compatibility script so you can use both calls. But we recommend to
make use of the new syntax for new levels.

2. Changes in error handling and file handling functions that can cause
"dofile" is no longer error safe (hangs waiting on input of stdin if
file does not exist). Use Enigmas "Require" function or the XML library
load declaration.

3. Upvalues in the form %var are obsolete:
In all observed cases the "%var" upvalue could be substituted by a
external local variables "var". The use of Lua 4 upvalues results in
error messages: "Unexpected symbol near '%'"

4. "for k,v in t", where t is a table, is not supported:
Substitute by "for k,v in pairs(t)". The use of the old syntax results
in error messages: "Attempt to call a table value  = for pairs"

5. No Linebreak between function identifier and opening argument brace:
If you need to break a long line put the first argument on the next line
and leave the opening brace together with the function identifier on the
line before: f.e.

longlinefunction (
    arg1, arg2)

The error message is: "ambiguos syntax (function call x new statement)
near ("

6. false and true are reserved words and true boolean expressions do no
longer evaluate to 1:

Expressions like

my_C_like_Boolean = (luaBoolean ~= nil) or 0

do no longer work. Use

my_C_like_Boolean = if luaBoolean then 1 else 0 end

Note: Enigma's Lua interface will still return boolean values as "nil"
and "value" which works correctly in all expressions.

7. GetStone, GetFloor, GetItem returned objects are no longer comparable:
Due to changes in the Lua userdata types you can no longer use:

if (enigma.GetStone(10,10) == enigma.GetStone(10,10)) then ...

This would now evaluate to false!
We introduced an additional interface function enigma.IsSameObject(obj1,
obj2) for comparisons.

if (enigma.IsSameObject(enigma.GetStone(10,10), enigma.GetStone(10,10))
then ...

(This problem is solvable if someone writes a metatable function for the
"eq" event!)

8. All Enigma Lua libs did move to subfolder "levels/lib/" (not caused
by Lua 5.1):

F.e. load natmaze library via:


- Ronald

reply via email to

[Prev in Thread] Current Thread [Next in Thread]