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.
Lists Creation and Naming
Section titled “Lists Creation and Naming”In the Lau language, lists are created with the '' symbol to store multiple pieces of data in an organized way.
Use of
Section titled “Use of ”Curly braces are always used to create an empty or filled list.
Key Definition
Section titled “Key Definition”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"}Data Access and Assignment Methods
Section titled “Data Access and Assignment Methods”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.speedorlist:speed. - Square Brackets ([]): Provides access by both name (
["Speed"]) and index number.
Mathematical Indexing
Section titled “Mathematical Indexing”Lau allows you to perform mathematical operations inside [] brackets. The system performs the calculation first, then searches the list based on the result.
varol mySeeds = {"Wheat", "Potato", "Tomato"}
print("Total Seeds: " + #mySeeds)print("First Seed: " + mySeeds[1])Access and Mathematical Search:
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 2print(inventory[1 + 1]) -- Also retrieves "Corn"
-- Dynamic Change:varol index = 1inventory[index + 2] = "Watermelon" -- Updates the 3rd itemLength and Iteration
Section titled “Length and Iteration”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.
varol car = { ["Color"] = "Red", ["Speed"] = 100}
-- Completely delete the 'Speed' propertycar.Speed = null
-- Now 'Speed' doesn't exist anymoreprint(car.Speed) -- Prints 'null'
-- Iterating through the remaining items:for key, value inpairs(car) do print(key + ": " + value) -- Only prints "Color: Red"endDeleting Elements (Null)
Section titled “Deleting Elements (Null)”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.
Dictionaries (Key-Value)
Section titled “Dictionaries (Key-Value)”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.
varol droneSettings = { autoBuy = true, autoSell = true, nickname = "FarmBot-9000"}
-- You can access data using a dotprint(droneSettings.nickname)varol farmStats = { cropsHarvested = 100 }
-- Update the valuefarmStats.cropsHarvested += 1
-- You can also use square bracketsfarmStats["cropsHarvested"] = 200Iterating Tables
Section titled “Iterating Tables”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.
varol inventory = {"Apple", "Banana"}
for i, itemName inpairs(inventory) do print("Checking slot " + i + ": " + itemName)endSystem Limits
Section titled “System Limits”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.
All 11 Data Types Overview
Section titled “All 11 Data Types Overview”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.
- Number: Mathematical values, whole or decimal (e.g., 10, 3.14).
- String: Text data enclosed in double quotes (e.g., “Lau”).
- Boolean: Logical values representing ‘true’ or ‘false’.
- List: Collections of multiple data enclosed in brackets.
- Function: Custom, reusable code blocks created by the player.
- BuiltInFunction: Pre-coded core engine commands (like print).
- null: Represents the intentional absence of any value (empty).
- Enum: Read-only system categories (e.g., Enum.Direction.North).
- Color: RGB or Hex visual color objects (created via colorRgb).
- Event: Dynamic game triggers you can listen to (e.g., player.chatted).
- Connection: The active link created when an Event is connected, which can be disconnected later.
String Rules
Section titled “String Rules”- 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:
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"Important Reminder
Section titled “Important Reminder”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.