Skip to content

String Module

The string module contains functions to analyze and modify text. In Lau, strings are wrapped in double quotes "" and have a maximum length of 10,000 characters.


These functions are useful for making chat commands “case-insensitive” (so your drone understands both “START” and “start”).

FunctionDescription
string.upper(text)Converts every character to UPPERCASE.
string.lower(text)Converts every character to lowercase.
lau-compiler.exe
varol toUpper = "shouting"
varol toLower = "WHISPERING"
print(string.upper(toUpper))
print(string.lower(toLower))
OUTPUT:
SHOUTING whispering

Use these functions to find specific words within a message or to check how long a string is.

FunctionReturnsDescription
string.len(text)numberReturns the total number of characters.
string.find(text, target)numberReturns the start index of the target word, or null.
string.match(text, pattern)stringSearches for a pattern and returns the match.
lau-compiler.exe
varol input = "Hello Drone"
print("Length: " + string.len(input))
varol pos = string.find(input, "Drone")
print("Found 'Drone' at index: " + pos)
OUTPUT:
Length: 10 Found 'Drone' at index: 7

These functions allow you to cut strings into pieces or replace specific words.

FunctionDescription
string.sub(text, start, end?)Cuts the string from the start index to the end index.
string.gsub(text, pattern, repl)Global Substitution: Replaces all instances of a word with another.
lau-compiler.exe
-- Substitution
varol base = "Lau is bad"
varol fixed = string.gsub(base, "bad", "cool")
print("Result: " + fixed)
-- Substring (cutting)
varol fullName = "Unit-Drone-V2"
varol nick = string.sub(fullName, 6, 10)
print("Nickname: " + nick)
OUTPUT:
Result: Lau is cool Nickname: Drone

Unlike standard Lua which uses .., Lau uses the + operator to join strings and numbers together.

varol weight = 2.5
player.sent("The crop weighs " + weight + "kg")