Skip to content

Tables & Collections

In Lau, we use the {} symbols to create Tables. These are the most powerful part of the language, allowing you to store lists of items or complex data structures.


A list is a collection of items stored in a specific order.

To get the total number of items in a list, use the # (Length) operator.

lau-compiler.exe
varol mySeeds = {"Wheat", "Potato", "Tomato"}
print("Total Seeds: " + #mySeeds)
print("First Seed: " + mySeeds[1])
OUTPUT:
Total Seeds: 3 First Seed: Wheat

Sometimes you want to store data by name instead of by number. This is called a Dictionary. This is perfect for storing Drone settings or player stats.

lau-compiler.exe
varol droneSettings = {
autoBuy = true,
autoSell = true,
nickname = "FarmBot-9000"
}
-- You can access data using a dot
print(droneSettings.nickname)
OUTPUT:
FarmBot-9000

The most common use for tables is looping through them to perform actions on every item. As learned in the Logic & Loops section, we use inpairs for this.

lau-compiler.exe
varol inventory = {"Apple", "Banana"}
for i, itemName inpairs(inventory) do
print("Checking slot " + i + ": " + itemName)
end
OUTPUT:
Checking slot 1: Apple Checking slot 2: Banana

To ensure game performance, the Lau engine enforces the following limits on table data:

  • Maximum Elements: A single table can hold up to 5,000 elements, although it may be hard to reach this as max character limit is 5,000 also.
  • Persistent Data: Tables saved using the data. module count toward your cloud storage limit.