Lesson 1 of 10

Your first script

Goal

The local keyword, print and the .. operator for joining strings

01

Explanation

Lua was designed to be embedded inside bigger programs, which is why you find it in game engines and game servers: Roblox and FiveM scripts, World of Warcraft add-ons and LÖVE games are all written in Lua or a language close to it.

You define a variable with the local keyword, like this: local name = "Layan". If you leave out local, the variable becomes global and every script in the game can see it, which causes hard-to-track bugs when two scripts use the same name.

You join strings with two dots .., not with +, as in "Level " .. level, because + between two strings tries to convert them to numbers and fails.

02

Your task

Use local to define two variables: name holding a string and level holding an integer. Then print a single line that contains both, joined with ...

Checks

5 checks
  1. name is a non-empty string
  2. level is an integer
  3. Both variables are defined with local
  4. The name was printed
  5. The level was printed on the same line
03

Hints

0/3
main.lua
OutputLua 5.4 (wasmoon)

Loading Lua.

–/5

Checks start once the environment is ready.

5 checks listed under “Your task”.