Things to remember when working with Lua
The following are concepts that you need to keep in mind when working with Lua.
Comments
A comment can be anything in between two hyphens and the next end of line:
--This is a comment
Comment blocks are also supported. They are delimited by the characters --[[
and ]]
:
--[[ This is a multi-line comment block. ]]
Dummy assignments
There are occasions where you don’t need all the information returned by a function, and in Lua, you can use dummy assignments to discard a return value. The operator is _
(underscore):
local _, _, item = string.find(<string>, <pattern with capture>)
Indexes
Indexes start at one, not zero:
z={"a","b","c"} z[1]="b" --This assignment will change the content of the table to {"b","b","c"}
However, you can initialize an array at any value:
nmap = {} for x=-1337, 0 do nmap[x] = 1 end
Note
Keep in mind that all Lua libraries will stick to this convention.
Semantics
Due to its flexibility...