Experiences from Lua programming

Cuong Do
cuongdd2
Published in
1 min readFeb 16, 2017

In process of studying and evaluating current game engines, I found out Lua is used quite popular for scripting language in games.

Currently, I am getting started with Defold game engine. Not like Unity, we can use C#, UnityScript (JavaScript likes syntax) or Boo, Lua is the only scripting language we can use with Defold

The differences of Lua to most high level languages or modern scripting languages.

Concatenate string:

Lua:
"10.2" + 1 = 11.2
"10.2" .. 1 = "10.21"
Other languages:
"10.2" + 1 = "10.21"

Indices of table / array

Lua:
a = {4, 2, 8, 6}
a[1] = 4 // array's indices start from 1
Other languages:
a = [4, 2, 8, 6]
a[1] = 2 // array's indices start from 0

^ operator

Lua:
2 ^ 4 = 16 // exponent operator
Other languages:
2 ^ 4 = 6 // bitwise operator
2 ** 4 = 16 // javascript's exponent

Not equal

Lua:
1 ~= 2
Other languages:
1 != 2

In the process of studying Lua, if there is any discovery I will update soon…

--

--