lua
Lua is a programming language.
A table is a data structuring mechanism used for arrays, sets, queues. Tables are objects. Functions and tables can be used to emulate OOP. TODO: read more about metatables
table = {a = 3, b = { c = 2 }}
print(table[a]) nil
print(table["a"]) 3
print(table.a) 3
print(table["b"]["c"]) 2
print(table.b.c) 2
k = "key"
table[k] = "value"
-- prints "value"
print(table["key"])
print(table[k])
print(table.k)equality
print(10 == 10) true
print(10 ~= 11) trueGreater-/lesser-than (or equal-to) operators work as usual, but an error is thrown if a number is compared with another number in string form:
test = "9" >= 3
print(test)
attempt to compare number with stringlogic
nil and false are false
The and operator returns the first argument if it’s false and the second otherwise. or is the opposite, returning the first argument if it is true.
print(nil and 1) nil
print(0 and 1) 1
print(0 or 1) 0
print(nil or 1) 1
print(false or nil) nilconcat
print("hello " .. "moon") hello moon
x = 0 .. 1
print(x) 01
print(type(x)) stringlöve
LÖVE is a framework for making 2D games, using Lua.
Reload with lovelier:
pnpm i -g lovelier
lovelier dev .