Logic & Control
Structures teach your drone how to think. They allow your scripts to react to the environment and repeat tasks automatically.
Decision Making (if)
Section titled “Decision Making (if)”The if statement evaluates a condition. If the condition is true, the code block executes. You can chain multiple checks using elseif and provide a fallback with else.
Syntax Example
Section titled “Syntax Example” lau-compiler.exe
varol energy = 50
if energy > 80 then print("Energy is full!")elseif energy > 20 then print("Energy is normal.")else print("WARNING: Energy is critical!")endOUTPUT:
Energy is normal.
Loops are essential for covering large farm plots without writing hundreds of lines of code.
1. Numerical Loops (for)
Section titled “1. Numerical Loops (for)”Use this when you know exactly how many times you want to repeat an action.
lau-compiler.exe
-- Format: for variable = start, end dofor i = 1, 3 do print("Moving to Tile: " + i)endOUTPUT:
Moving to Tile: 1
Moving to Tile: 2
Moving to Tile: 3
2. While Loops (while)
Section titled “2. While Loops (while)”The while loop runs as long as the condition remains True.
lau-compiler.exe
varol hasLooped = false
while hasLooped == false do --[[ Script will continue repeating until this variable is met, you can do `while true do` to form an infinte loop which continues forever ]] print("Status: Hasn't looped") hasLooped = true -- Condition metend
print("Status: It Looped!")OUTPUT:
Status: Hasn't looped
Status: It Looped!
Iterating Collections (inpairs)
Section titled “Iterating Collections (inpairs)”LAU uses a custom keyword inpairs to loop through lists (tables). This is perfect for checking inventory or planting a list of seeds.
lau-compiler.exe
varol seedList = {"Lemon", "Cacao", "Lotus"}
for index, seedName inpairs(seedList) do print("Slot " + index + ": " + seedName)endOUTPUT:
Slot 1: Lemon
Slot 2: Cacao
Slot 3: Lotus
Loop Controls
Section titled “Loop Controls”LAU provides two commands to change the flow of a loop:
| Keyword | Action |
|---|---|
break | Immediately exits the loop and stops all further turns. |
continue | Skips the current turn and jumps straight to the next one. |
Practical Example: Inventory Search
Section titled “Practical Example: Inventory Search” lau-compiler.exe
varol inventory = {"Wheat", "Corn", "Cactus", "Potato"}
for i, item inpairs(inventory) do print("Checking slot " + i)
if item == "Cactus" then print("Found Cactus! Stopping search.") break endendOUTPUT:
Checking slot 1
Checking slot 2
Found Cactus! Stopping search.