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.


In the Lau language, lists are created with the '' symbol to store multiple pieces of data in an organized way.

Curly braces are always used to create an empty or filled list.

To name data within a list, the ["name"] = value format is used. This makes it easier to organize data.

varol droneData = {
["Speed"] = 15,
["Mode"] = "Automatic",
["Order"] = 1
}
-- Numerical (Ordered) List:
varol fruits = {"Apple", "Pear", "Banana"}

There are three different ways to access or change data in a list in the Lau language:

  • Dot (.) or Colon (:): You can access data as list.speed or list:speed.
  • Square Brackets ([]): Provides access by both name (["Speed"]) and index number.

Lau allows you to perform mathematical operations inside [] brackets. The system performs the calculation first, then searches the list based on the result.

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

Access and Mathematical Search:

lau-compiler.exe
varol inventory = {"Wheat", "Corn", "Tomato"}
-- Assignment with Dot and Colon:
inventory.new = "Potato"
inventory:old = "ORANGE"
-- Mathematical Indexing:
print(inventory[3 - 1]) -- Retrieves "Corn" at index 2
print(inventory[1 + 1]) -- Also retrieves "Corn"
-- Dynamic Change:
varol index = 1
inventory[index + 2] = "Watermelon" -- Updates the 3rd item
OUTPUT:
Corn Corn

Length (#): Just like with strings, you can instantly see how many elements are in a list using the # operator.

inpairs: The inpairs keyword is used to iterate through lists in a loop.

lau-compiler.exe
varol car = {
["Color"] = "Red",
["Speed"] = 100
}
-- Completely delete the 'Speed' property
car.Speed = null
-- Now 'Speed' doesn't exist anymore
print(car.Speed) -- Prints 'null'
-- Iterating through the remaining items:
for key, value inpairs(car) do
print(key + ": " + value) -- Only prints "Color: Red"
end
OUTPUT:
null Color: Red

To completely remove a property or an item from a list, you simply assign its value to null. When a key is set to null, the engine permanently deletes it from the list.


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.

In the Lau language, texts and strings are subject to special rules. Before diving into the rules, let’s briefly look at all available data types in the engine.

  1. Number: Mathematical values, whole or decimal (e.g., 10, 3.14).
  2. String: Text data enclosed in double quotes (e.g., “Lau”).
  3. Boolean: Logical values representing ‘true’ or ‘false’.
  4. List: Collections of multiple data enclosed in brackets.
  5. Function: Custom, reusable code blocks created by the player.
  6. BuiltInFunction: Pre-coded core engine commands (like print).
  7. null: Represents the intentional absence of any value (empty).
  8. Enum: Read-only system categories (e.g., Enum.Direction.North).
  9. Color: RGB or Hex visual color objects (created via colorRgb).
  10. Event: Dynamic game triggers you can listen to (e.g., player.chatted).
  11. Connection: The active link created when an Event is connected, which can be disconnected later.

  • Concatenation (+): The + operator is used to join two strings. In the Lau language, the use of .. is not supported and will result in an error.
  • Length (#): To find out how many characters a string has, simply place # at the beginning.
  • String Module: For more advanced operations, you can use the ‘string’ library.

String Operations Example:

lau-compiler.exe
varol name = "Lau"
varol message = "Hello " + name -- Concatenation with '+'
print(message) -- "Hello Lau"
varol length = #message -- Find character count with '#'
print("Character count: ", length)
-- Incorrect usage (Throws error):
-- varol error = "Lau" .. "Engine"
OUTPUT:
Hello Lau Character count: 10

The varol keyword is not used when assigning values inside lists. If the list is already defined, you can update its content directly by saying list.property = value.