Lua – first steps – part 001.

The name Lua comes from Portuguese meaning moon and is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded use in applications.
Lua was originally designed in 1993 as a language for extending software applications to meet the increasing demand for customization at the time.
Lua is cross-platform since the interpreter of compiled bytecode is written in ANSI C.
Lua has a relatively simple C API to embed into applications.
Let’s start with some information and basic examples, see also this online tool for lua with these examples:

  • Lua is case-sensitive: and is a reserved word, example: And and AND are two other different identifiers;
  • following words are reserved and we cannot use them as identifiers – variables for example:
  • comments on many rows start anywhere with :
  • a single row comment starts with a double hyphen is a punctuation mark (-), start a row commented with anywhere outside a string, see:
  • Global variables − all variables are considered global unless explicitly declared as local, see:
  • Local variables − when the type is specified as local for a variable, its scope is limited with the functions inside their scope, see:
  • Table fields − this is a special type of variable that can hold anything except nil including functions – can contain functions, but you can assign nil to a table field to delete it.
  • These strings denote other tokens:
  • There are 8 basic types in Lua:
  • Relational operators and always result in false or true:
  • Bitwise operators:
  • Statements contains words like: If, For, While, Repeat and Table.
  • Concatenation or combine:

The next tutorial will be more complex.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.