# Lua

> A small, fast script language made to live inside games and apps.

**Field:** Software Development  
**Category:** Languages  
**Also known as:** Lua Language, Lua Script

## Think of it like

It is like a tiny brain you put in a toy. It teaches the toy new tricks.

## Definition

Lua is a small, fast scripting language made to be put inside other programs. A game or app is written in a big language like C. It then lets Lua scripts control parts of it, like how a level plays. Lua was made at a university in Brazil, called PUC-Rio. It is a leading scripting language in games.

## Example

A game lets players write Lua scripts for their own levels. The game engine itself stays in C++.

## Example code

```lua
for i = 1, 3 do
  print("Hello " .. i)
end
```

Print a hello three times. The two dots join text together.

## Why it matters

It lets people change a program without rebuilding it. Many games and tools use it for mods and settings.

## Common mistake

Counting from 0. Lua lists start at 1, so code ported from other languages is often off by one.

## Three principles

- **Small.** Fits inside other programs.
- **Embeddable.** The host app runs it.
- **Starts at 1.** Lists count from one.

## Related terms

- [Scripting Language](https://learn.benibix.com/term/development/scripting-language)
- [Game Engine](https://learn.benibix.com/term/development/game-engine)
- [Luau](https://learn.benibix.com/term/development/luau)
- [C](https://learn.benibix.com/term/development/c-language)

## Told apart from

- [Lua vs Luau](https://learn.benibix.com/compare/lua-vs-luau): People think Luau is just another name for Lua, and it is not. Luau is based on Lua 5.1, and much simple Lua code runs in it unchanged. But Luau is made for Roblox games. It adds types you can choose to use, and it shuts off parts of Lua that would be unsafe in a game, such as reading files. A Lua script for another app may not run in Roblox.

## Taught in

- [Shell Scripts, Perl and Lua](https://learn.benibix.com/learn/development-languages/shell-scripts-perl-and-lua): Programming Languages, 12/12

![Four labelled shelves of languages. Data science: R, MATLAB and Julia, beside a small bar chart. Functional: Haskell, Scala, Elixir, beside an arrow that turns a list into a new list. Shell and scripting: shell script, PowerShell, Perl and Lua, beside a terminal prompt. Close to the hardware: assembly language and Objective-C, beside a chip and a phone.](https://learn.benibix.com/diagrams/dev4-language-families.svg)

---

Source: https://learn.benibix.com/term/development/lua
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
