YouTip LogoYouTip

Lua Tutorial - Getting Started

Lua Basics

local name = "Alice"
local age = 25
print("Hello, " .. name .. "!")

for i = 1, 5 do
    print(i)
end

function greet(name)
    return "Hello, " .. name
end

Tables

local person = {name = "Alice", age = 25}
print(person.name)

local nums = {10, 20, 30}
for i, v in ipairs(nums) do print(i, v) end

Summary

  • Lua is lightweight and embeddable
  • Tables are the only data structure
← Perl Tutorial - Getting StarteDart Tutorial - Getting Starte β†’