Learn Lua · Strings · Lesson 1 of 3

Joining text

Text in Lua is a string, written in quotes. Join strings with .. (two dots). Numbers join too, and become text:

LUA
local name = "Ada"
"Hello, " .. name   --> "Hello, Ada"
"Order " .. 1042    --> "Order 1042"

tostring turns any value into text, which helps when you aren't sure what you have:

LUA
tostring(7.5)   --> "7.5"
tostring(true)  --> "true"

What your code receives

Your code gets its data as input. The type Input line at the top of the code lists every field, and the editor uses it to suggest field names and spot typos. Here is an example. Each check sends different values, so work from the fields rather than these exact values.

LUA
input = { name = "Ada", quantity = 3, product = "Flyer", price = 7.5 }

Steps

  1. Return greeting: "Hello, " followed by input.name.
  2. Add summary: the quantity, " x " and the product, such as "3 x Flyer".
  3. Add price: "Price: " followed by input.price.
Show a hint

Spaces matter: "Hello, " .. "Ada" gives "Hello, Ada" because the space is inside the first string.