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.
🔡 Case Manipulation
Section titled “🔡 Case Manipulation”These functions are useful for making chat commands “case-insensitive” (so your drone understands both “START” and “start”).
| Function | Description |
|---|---|
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
🔍 Searching & Analysis
Section titled “🔍 Searching & Analysis”Use these functions to find specific words within a message or to check how long a string is.
| Function | Returns | Description |
|---|---|---|
string.len(text) | number | Returns the total number of characters. |
string.find(text, target) | number | Returns the start index of the target word, or null. |
string.match(text, pattern) | string | Searches 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
✂️ Modification & Subsets
Section titled “✂️ Modification & Subsets”These functions allow you to cut strings into pieces or replace specific words.
| Function | Description |
|---|---|
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
-- Substitutionvarol 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
💡 Pro Tip: String Concatenation
Section titled “💡 Pro Tip: String Concatenation”Unlike standard Lua which uses .., Lau uses the + operator to join strings and numbers together.
varol weight = 2.5player.sent("The crop weighs " + weight + "kg")