Lua Snippet Library

Welcome to the lua snippet library, here you will found sound useful chunks of code

-- This is a one line comment, it begins with a double hyphen (--)
	This is a multi-line comment,
	It begins with a double hyphen plus a double open bracket and ends with a double close bracket.
	Line 1,
	Line 2,
	Line N.
	Variables in Lua don't have any type, the type of a variable is deduced from its content. We say that Lua is a dynamically typed language.
	By changing the content of a variable, you change its type, so a variable can be a number then a string then anything else.
var1 = nil  											-- nil is a spacial type for nothing, set nil to a variable to erase its value
var2 = "hello world" 									-- this is a string
var3 = 'hellow world'									-- this is also a string, single quote are more powerfull, they can escape double quote
var4 = "\"hello there\"" 								-- escape double quote or any special character with an anti-slash
var5 = '"hellow there"'  								-- escape double quote with single quote, cool isn't it
var6 = true 											-- boolean true
var7 = false											-- boolean false
var8 = 512												-- number integer
var9 = 3.14159											-- number float, that number is the number PI just for info
var10 = {} 												-- a empty table
var11 = {"one", "two", "tree"}  						-- a table of string
var12 = {true, false, true}								-- a table of boolean
var13 = {1, 3.14, 512}									-- a table of number
var14 = {"one", 3.14, true}								-- a table of anything. Table in Lua can contains any datatype at the same time
var15 = {{"one", 3.14, true}, {true, false}, nil} 		-- a table of table, realy cool isn'it, a table can contains anything 
-- A function begins with the word "function" and ends with the word "end".
-- A function can take any number of arguments and return any number of results
-- A function need a name by default, here the name is "function_1"
function function_1(arg1, arg2, argN)
   result_1 = "this is a result"
   return_2 = true
   return_N = 3.14
   return result_1, result_2, result_N 
-- A function with no argument and no result
function function_2()
	print("hello there, how to you do");