Lua Primer

While the Lua reference manual is indispensable, here are the most important parts of Lua you’ll need to get started. This is meant to give a very brief overview and let you know where in the manual to look for further details, not to teach Lua.

Important functions

Note that tostring on tables will give unsatisfactory results; simply evaluating the table in the REPL will invoke fennelview for you and show a human-readable view of the table (or you can invoke fennelview explicitly in your code).

Important modules

You can explore a module by evaluating it in the REPL (which will use fennelview to display all the functions and values it contains.

In particular table.insert and table.remove are intended for sequential tables; they will shift over the indices of every element after the specified index. To remove something from a non-sequential table simply set the field to nil.

Note that Lua does not implement regular expressions but its own more limited pattern language for string.find, string.match, etc.


Lua loading

These are used for loading Lua code. The load* functions return a “chunk” function which must be called before the code gets run, but dofile executes immediately.


source for this site