Learn Lua · Tables · Lesson 1 of 5

Lists

A list is a table of values in order: { "Flyer", "Card", "Poster" }. Positions start at 1, and # gives the length:

LUA
local items = { "Flyer", "Card", "Poster" }
items[1]   --> "Flyer"
#items     --> 3

In the Input line, { string } means a list of strings.

table.insert adds to the end. It changes the list itself, so copy a list with table.clone first when you shouldn't change the original:

LUA
local more = table.clone(items)
table.insert(more, "Sticker")
#more   --> 4
#items  --> 3

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 = { items = { "Flyer", "Card" } }

Steps

  1. Return first: the first item in input.items.
  2. Add count: how many items there are.
  3. Add withProof: a copy of the items with "Proof" added at the end. Leave input.items unchanged.
Show a hint

Copy with table.clone(input.items), then table.insert into the copy.