Skip to content

Logic & Control

Structures teach your drone how to think. They allow your scripts to react to the environment and repeat tasks automatically.


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.

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!")
end
OUTPUT:
Energy is normal.

Loops are essential for covering large farm plots without writing hundreds of lines of code.

Use this when you know exactly how many times you want to repeat an action.

lau-compiler.exe
-- Format: for variable = start, end do
for i = 1, 3 do
print("Moving to Tile: " + i)
end
OUTPUT:
Moving to Tile: 1 Moving to Tile: 2 Moving to Tile: 3

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 met
end
print("Status: It Looped!")
OUTPUT:
Status: Hasn't looped Status: It Looped!

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)
end
OUTPUT:
Slot 1: Lemon Slot 2: Cacao Slot 3: Lotus

LAU provides two commands to change the flow of a loop:

KeywordAction
breakImmediately exits the loop and stops all further turns.
continueSkips the current turn and jumps straight to the next one.
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
end
end
OUTPUT:
Checking slot 1 Checking slot 2 Found Cactus! Stopping search.