{} in lua code example

Example 1: lua operators

== -- Equal to whatever
<= -- Less than or equal to
>= -- Greater than or equal to
< -- Less than
> -- Greater Than
~= -- Doesnt equal
# -- Length of something

Example 2: lua tables

local Table = {
	["TABLE_info"] = "TABLE_response"
}

for i, v in pairs(Table) do
	print(v)
end

Example 3: table in lua

local myTable = {}

Example 4: table lua

a = {}
    x = "y"
    a[x] = 10                 -- put 10 in field "y"
    print(a[x])   --> 10      -- value of field "y"
    print(a.x)    --> nil     -- value of field "x" (undefined)
    print(a.y)    --> 10      -- value of field "y"

Example 5: how to lua

-- Well, first, you could make a variable

local variable = true

-- If you want to print something in the output
print("Hello Output!")

-- Finally, the rest is up to you.

Example 6: how to access an index of a table lua

--How to access something in a table by its index in lua:

local mytable = {"Hi", 6,"Bye"}

--To access it:

mytable[1]
--or
mytable[2]
--or
mytable[3]

Tags: