What is Lua?

Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.

Developed in Brazil in 1993, Lua is known for its simplicity, speed, and ease of integration with applications written in other languages like C and C++. This makes it a popular choice for game development (e.g., Roblox, World of Warcraft addons), embedded systems, and configuration files.

Key Features of Lua

Example Lua Code

-- Simple Lua example demonstrating functions and tables
local player = {
  name = "Hero",
  level = 1,
  inventory = {"sword", "potion"}
}

function greet(name)
  print("Hello, " .. name .. "!") -- String concatenation
end

function levelUp(character)
  character.level = character.level + 1
  print(character.name .. " reached level " .. character.level .. "!")
end

greet("World")          -- Output: Hello, World!
levelUp(player)         -- Output: Hero reached level 2!
print("Inventory size: " .. #player.inventory) -- Output: Inventory size: 2