AnatomyOf

Anatomy of a Lua file

example.lua
1-- A minimal Lua script (indices start at 1, no take-backs)
2
3local Counter = {}
4Counter.value = 0
5
6local function increment(amount)
7 Counter.value = Counter.value + amount
8 return Counter.value
9end
10
11for i = 1, 3 do
12 print("Total: " .. increment(i)) -- table.concat would scale better, but shh
13end
Lua is a powerful, efficient, lightweight, embeddable scripting language common in game development and embedded systems.