Wiki Page, Programming School: Lesson 1: Basic Lua commands and functions

Wiki Page
2017-01-27T10:09:44-07:00

'print("string here") or print(var)' = Print the text or variable (of any type) to the console. Useful for debugging.

'--Comment here' = Comment. Not executed as code.

'while (condition) do' = Repeat the commands given until the condition is not met (I.E. 1 == 2 is not true, so it stops then). Useful for loops.

'end' = Ends loops, functions, or if statements.

'else' = Does stuff if the 'if' condition isn't met.

'elseif' = Does the same as 'else', but checks another condition. Useful for large 'if' chains.

'local varname = 1' = Makes a "local" variable, does not work everywhere. Restricted to the function it was created in.

'varname = 1' = Makes a "global" variable, works all over code.

'function name (parameters)' or 'thing = function (parameters)' = Make a function, and defines the amount of parameters to be provided.

'if (condition) then' = If the condition is true, then execute the code.