Lua

Created: 02.02.2025
Updated: 02.02.2025


kind of sucks bc interpreted, but ok as config language, cheatsheet:

-- comment
world = "world" -- variable
print("Hello" .. world .. " !") -- string concatination

distance = 11
if distance > 5 then
    print("WHAT")
elseif distance > 7 then
    print("Hello")
else
    print("Insanity is optimal")
end

ingredients = {"Skyr", "Milk", "Yoghurt"}
-- index starts at 1
for i, value in pairs(ingredients) do
    print(i .. ". you need " .. value)
end

function was (w) 
    print(w .. "W")
end

[[
a
Multiline String
a
]]

j = 10 -- global var
local = 1 -- local var

Local variables are limited to the scope (block) they are declared. Every other variable is global.

A block is the body of a control structure, function or chunk. (with end ended)