Lesson 1 of 8 · 5 min

Hello, Lua

Lua is a small, fast scripting language. You will find it inside games (Roblox, World of Warcraft add-ons), text editors, network equipment and countless devices, because it is tiny and easy to embed.

Printing works like this:

print("Mhoro, world!")
print(2 + 3)          -- 5

Text after -- is a comment, ignored by Lua.

Variables

local name = "Rudo"
local score = 10
score = score + 5
print(name, score)    -- Rudo	15

local creates a variable that belongs to the current block. Always use local unless you really need a global: it avoids accidentally sharing names across your program.

print with several values separates them with a tab. To join text yourself, use .. (two dots):

print(name .. " scored " .. score)   -- Rudo scored 15

Lua turns the number into text for you when you join it with ...

Your task

  1. Print Hello from Lua!.
  2. Create player with the value "Tariro" and lives with the value 3.
  3. Print Tariro has 3 lives using .. and your variables.
main.lua
-- Your Lua code here

Lua 5.4 runs right here in your browser. The first run downloads about 0.4 MB; after that it is instant.

Discussion

Stuck? Ask here. Be kind, and share hints rather than full answers.

Loading the discussion…