afterText
returns string?
afterText(text: string, marker: string) -> string?
Everything after the first appearance of a marker, or none when the marker is not there — the other half of beforeText.
| Parameter | Type | What it does |
| textrequired |
string |
the text to cut |
| markerrequired |
string |
the fragment to cut at; must not be empty |
Example
print(afterText("coal: 250", ": "))
barText
returns string
barText(percent: int, width: int) -> string
A progress bar as text, like "[####----]" — for a print or a label where the drawn paintProgress cannot go.
| Parameter | Type | What it does |
| percentrequired |
int |
how full, 0 to 100 |
| widthrequired |
int |
how many characters wide the bar is, 1 to 100 |
Example
print(barText(50, 8))
base64Decode
returns string?
base64Decode(text: string) -> string?
The text a base64 token holds, or none when the token is not valid base64 — the other half of base64Encode.
| Parameter | Type | What it does |
| textrequired |
string |
the base64 to decode |
Example
print(base64Decode("aGk="))
base64Encode
returns string
base64Encode(text: string) -> string
The text as base64 — a safe single token for saving or sending text that may hold anything.
| Parameter | Type | What it does |
| textrequired |
string |
the text to encode |
Example
print(base64Encode("hi"))
beforeText
returns string?
beforeText(text: string, marker: string) -> string?
Everything before the first appearance of a marker, or none when the marker is not there — 'name: value' reads with beforeText and afterText.
| Parameter | Type | What it does |
| textrequired |
string |
the text to cut |
| markerrequired |
string |
the fragment to cut at; must not be empty |
Example
print(beforeText("coal: 250", ":"))
betweenText
returns string?
betweenText(text: string, after: string, before: string) -> string?
The text between two markers, or none when either is missing — one call for pulling a value out of a line with a known shape.
| Parameter | Type | What it does |
| textrequired |
string |
the text to cut |
| afterrequired |
string |
the fragment the answer starts after; must not be empty |
| beforerequired |
string |
the fragment the answer ends before; must not be empty |
Example
print(betweenText("lvl [42] done", "[", "]"))
capitalize
returns string
capitalize(text: string) -> string
The string with its first letter in upper case and the rest untouched.
| Parameter | Type | What it does |
| textrequired |
string |
the string to capitalize |
Example
print(capitalize("iron"))
centerText
returns string
centerText(text: string, width: int) -> string
The text with spaces either side until it sits in the middle of a width — for lining up a console readout. Text already wider comes back whole.
| Parameter | Type | What it does |
| textrequired |
string |
the text to centre |
| widthrequired |
int |
how wide the field is, up to a million |
Example
print(centerText("hi", 8))
charAt
returns string
charAt(text: string, index: int) -> string
The single character at a position as a one-letter string, or an empty string when the position is off the end.
| Parameter | Type | What it does |
| textrequired |
string |
the string to read from |
| indexrequired |
int |
which character, counting from zero |
Example
print(charAt("hello", 0))
charOf
returns string
charOf(code: int) -> string
The one-character text for a character code — the other half of codeOf. Refuses a code outside what text can hold.
| Parameter | Type | What it does |
| coderequired |
int |
a character code, like 65 for 'A' |
Example
print(charOf(65))
chars
returns list<string>
chars(text: string) -> list<string>
A list of a string's characters, each as a one-letter string.
| Parameter | Type | What it does |
| textrequired |
string |
the string to split up |
Example
print("letters", count(chars("hello")))
codeOf
returns int
codeOf(text: string) -> int
The character code of the text's FIRST character — 'A' is 65. Refuses empty text, which has no first character.
| Parameter | Type | What it does |
| textrequired |
string |
the text whose first character is read |
Example
print(codeOf("A"))
compareText
returns int
compareText(a: string, b: string) -> int
Which of two texts sorts first: -1 when a comes before b, 0 when they are the same, 1 when a comes after — alphabetical, case-sensitive.
| Parameter | Type | What it does |
| arequired |
string |
the first text |
| brequired |
string |
the second text |
Example
print(compareText("apple", "banana"))
contains
returns bool
contains(text: string, part: string) -> bool
True when 'text' contains 'part'. Case matters - fold with lower() first to ignore it. This is how you react to a server line that is not an exact string.
| Parameter | Type | What it does |
| textrequired |
string |
the string to search |
| partrequired |
string |
the fragment to look for |
Example
on message(line, from) { if contains(lower(line), "well done") { stop } }
containsAllOf
returns bool
containsAllOf(text: string, pieces: list<string>) -> bool
True when the text holds EVERY one of the given fragments — containsAny asks for one, this asks for all.
| Parameter | Type | What it does |
| textrequired |
string |
the text to test |
| piecesrequired |
list<string> |
the fragments that must ALL appear |
Example
if containsAllOf("iron ore rock", split("iron,rock", ",")) { print("both") }
containsAny
returns bool
containsAny(text: string, parts: list<string>) -> bool
True when a string contains any one of a list of fragments. Case matters — fold with lower() first.
| Parameter | Type | What it does |
| textrequired |
string |
the string to search |
| partsrequired |
list<string> |
the fragments, any of which counts |
Example
if containsAny(lower("well done"), split("nice,well done", ",")) { stop }
countText
returns int
countText(text: string, part: string) -> int
How many times a fragment appears in a string, without overlaps. An empty fragment counts as zero.
| Parameter | Type | What it does |
| textrequired |
string |
the string to search |
| partrequired |
string |
the fragment to count |
Example
print("a's", countText("banana", "a"))
ellipsis
returns string
ellipsis(text: string, max: int) -> string
The text cut to a length with '...' marking the cut — for a readout column that must not grow. Text already short enough comes back whole.
| Parameter | Type | What it does |
| textrequired |
string |
the text to shorten |
| maxrequired |
int |
the longest the answer may be, 4 or more |
Example
print(ellipsis("a very long name", 9))
endsWith
returns bool
endsWith(text: string, suffix: string) -> bool
True when 'text' ends with 'suffix'. Case-sensitive.
| Parameter | Type | What it does |
| textrequired |
string |
the string to test |
| suffixrequired |
string |
the ending to look for |
Example
if endsWith(line, "well done") { stop }
endsWithAny
returns bool
endsWithAny(text: string, suffixes: list<string>) -> bool
True when the text ends with ANY of the given endings — the other end of startsWithAny.
| Parameter | Type | What it does |
| textrequired |
string |
the text to test |
| suffixesrequired |
list<string> |
the endings to try, any one of which passes |
Example
if endsWithAny("iron ore", split("ore,bar", ",")) { print("metal") }
ensureEnd
returns string
ensureEnd(text: string, suffix: string) -> string
The text guaranteed to end with a suffix — added when missing, left alone when already there.
| Parameter | Type | What it does |
| textrequired |
string |
the text to check |
| suffixrequired |
string |
the fragment the answer must end with |
Example
print(ensureEnd("miner", ".bot"))
ensureStart
returns string
ensureStart(text: string, prefix: string) -> string
The text guaranteed to start with a prefix — added when missing, left alone when already there.
| Parameter | Type | What it does |
| textrequired |
string |
the text to check |
| prefixrequired |
string |
the fragment the answer must start with |
Example
print(ensureStart("example.com", "https://"))
equalsIgnoreCase
returns bool
equalsIgnoreCase(a: string, b: string) -> bool
True when two strings are the same ignoring case, so "Yes" matches "yes".
| Parameter | Type | What it does |
| arequired |
string |
the first string |
| brequired |
string |
the second string |
Example
if equalsIgnoreCase("Yes", "yes") { stop }
find
returns int
find(text: string, part: string) -> int
Where a fragment first sits in a string, counting from zero, or -1 when it is not there. The position to contains()'s yes or no.
| Parameter | Type | What it does |
| textrequired |
string |
the string to search |
| partrequired |
string |
the fragment to locate |
Example
if find("iron ore", "ore") >= 0 { print("found") }
findFrom
returns int?
findFrom(text: string, piece: string, from: int) -> int?
Where a fragment appears at or after a position, counting from 0, or none when it does not — find(), resumed part way through.
| Parameter | Type | What it does |
| textrequired |
string |
the text to search |
| piecerequired |
string |
the fragment to look for; must not be empty |
| fromrequired |
int |
the position to start looking at, counting from 0 |
Example
print(findFrom("a,b,a", "a", 1))
indexesOf
returns list<int>
indexesOf(text: string, piece: string) -> list<int>
Everywhere a fragment appears in a text, as positions counting from 0 — find(), all of them at once. Overlaps step one character at a time.
| Parameter | Type | What it does |
| textrequired |
string |
the text to search |
| piecerequired |
string |
the fragment to find every appearance of; must not be empty |
Example
print(count(indexesOf("a,b,a", "a")))
initials
returns string
initials(text: string) -> string
The first character of every word, run together: "iron ore rock" reads "ior". Empty text answers empty.
| Parameter | Type | What it does |
| textrequired |
string |
the words to take the fronts of |
Example
print(initials("iron ore rock"))
isBlank
returns bool
isBlank(text: string) -> bool
True when a string is empty or only spaces — for guarding a line before reading it.
| Parameter | Type | What it does |
| textrequired |
string |
the string to test |
Example
if isBlank(lastServerMessage()) { return 600 }
isNumberText
returns bool
isNumberText(text: string) -> bool
True when the text reads whole as one number — an optional minus and digits, commas allowed. Read the number itself with numberIn, which forgives the same commas this does.
| Parameter | Type | What it does |
| textrequired |
string |
the text to test |
Example
if isNumberText("1,234") { print("numeric") }
lastFind
returns int?
lastFind(text: string, piece: string) -> int?
Where a fragment LAST appears, counting from 0, or none when it never does — for the extension of a name, cut at lastFind, not find.
| Parameter | Type | What it does |
| textrequired |
string |
the text to search |
| piecerequired |
string |
the fragment to look for; must not be empty |
Example
print(lastFind("a.b.c", "."))
left
returns string
left(text: string, count: int) -> string
The first few characters of a string. Asking for more than there are gives all of them.
| Parameter | Type | What it does |
| textrequired |
string |
the string to take from |
| countrequired |
int |
how many characters from the start |
Example
print(left("iron ore", 4))
lower
returns string
lower(text: string) -> string
The text in lower case, so a match can ignore case.
| Parameter | Type | What it does |
| textrequired |
string |
the string to fold |
Example
if contains(lower(line), "walk across") { onLog = true }
ordinal
returns string
ordinal(n: int) -> string
A number with its ordinal ending: 1 becomes 1st, 2 becomes 2nd, 21 becomes 21st.
| Parameter | Type | What it does |
| nrequired |
int |
the number to name the place of |
Example
print("you are", ordinal(21))
padEnd
returns string
padEnd(text: string, width: int) -> string
The string with spaces added on the right until it is at least the given width.
| Parameter | Type | What it does |
| textrequired |
string |
the string to pad |
| widthrequired |
int |
the least number of characters wide |
Example
uiLabel("n", padEnd("hi", 6))
padStart
returns string
padStart(text: string, width: int) -> string
The string with spaces added on the left until it is at least the given width, so a column of them lines up on the right. A longer string is unchanged.
| Parameter | Type | What it does |
| textrequired |
string |
the string to pad |
| widthrequired |
int |
the least number of characters wide |
Example
uiLabel("n", padStart("7", 4))
percentText
returns string
percentText(part: int, whole: int) -> string
The part as a percentage of the whole, written with the sign: 42 of 100 is "42%". A whole of zero or less reads as "0%" rather than faulting.
| Parameter | Type | What it does |
| partrequired |
int |
how much of the whole this is |
| wholerequired |
int |
what all of it would be |
Example
print(percentText(42, 100))
plural
returns string
plural(count: int, singular: string, plural: string) -> string
The count and the right word for it: plural(1, "log", "logs") is "1 log", plural(2, ...) is "2 logs".
| Parameter | Type | What it does |
| countrequired |
int |
how many there are |
| singularrequired |
string |
the word for one |
| pluralrequired |
string |
the word for more than one |
Example
print(plural(2, "log", "logs"))
remove
returns string
remove(text: string, part: string) -> string
The string with every occurrence of a fragment taken out — replace with nothing, spelled the way you would say it.
| Parameter | Type | What it does |
| textrequired |
string |
the string to clean up |
| partrequired |
string |
the fragment to take out |
Example
print(remove("Iron ore certificate", " certificate"))
removeEnd
returns string
removeEnd(text: string, suffix: string) -> string
The text with a suffix removed when it ends with one, unchanged when it does not — the other half of removeStart.
| Parameter | Type | What it does |
| textrequired |
string |
the text to trim |
| suffixrequired |
string |
the fragment to take off the end, if it is there |
Example
print(removeEnd("miner.bot", ".bot"))
removeStart
returns string
removeStart(text: string, prefix: string) -> string
The text with a prefix removed when it starts with one, unchanged when it does not — safe to apply without asking first.
| Parameter | Type | What it does |
| textrequired |
string |
the text to trim |
| prefixrequired |
string |
the fragment to take off the front, if it is there |
Example
print(removeStart("Mr Smith", "Mr "))
repeatText
returns string
repeatText(text: string, times: int) -> string
A string made of a piece repeated a number of times. Refuses a negative count or a result too long to be sensible.
| Parameter | Type | What it does |
| textrequired |
string |
the string to repeat |
| timesrequired |
int |
how many copies, zero or more |
Example
print(repeatText("-", 8))
replace
returns string
replace(text: string, find: string, replacement: string) -> string
The text with every occurrence of 'find' replaced. Literal and case-sensitive, like the matches above. An empty 'find' returns the text unchanged - replacing nothing is nothing.
| Parameter | Type | What it does |
| textrequired |
string |
the string to rewrite |
| findrequired |
string |
the exact fragment to replace - literal, not a pattern |
| replacementrequired |
string |
what to put where each occurrence was |
Example
print(replace("Iron ore certificate", " certificate", ""))
replaceFirst
returns string
replaceFirst(text: string, find: string, with: string) -> string
The text with only the FIRST appearance of a fragment replaced — replace() does every one.
| Parameter | Type | What it does |
| textrequired |
string |
the text to work on |
| findrequired |
string |
the exact fragment to replace; must not be empty |
| withrequired |
string |
what to put in its place |
Example
print(replaceFirst("a,a", "a", "b"))
reverseText
returns string
reverseText(text: string) -> string
The string with its characters in the opposite order.
| Parameter | Type | What it does |
| textrequired |
string |
the string to reverse |
Example
print(reverseText("abc"))
right
returns string
right(text: string, count: int) -> string
The last few characters of a string.
| Parameter | Type | What it does |
| textrequired |
string |
the string to take from |
| countrequired |
int |
how many characters from the end |
Example
print(right("iron ore", 3))
romanOf
returns string
romanOf(number: int) -> string
The number as Roman numerals: 1994 reads MCMXCIV. Refuses numbers the numerals cannot write, which is anything outside 1 to 3999.
| Parameter | Type | What it does |
| numberrequired |
int |
the number to write, 1 to 3999 |
Example
print(romanOf(1994))
shortNumber
returns string
shortNumber(number: int) -> string
The number the way a player reads money: 950 stays 950, 1200 is "1.2k", 3400000 is "3.4m", 5600000000 is "5.6b". One decimal, no rounding up past it.
| Parameter | Type | What it does |
| numberrequired |
int |
the number to shorten |
Example
print(shortNumber(3400000))
squeeze
returns string
squeeze(text: string) -> string
The text with every run of spaces collapsed to one and both ends trimmed — what to do to a line before splitting it on spaces.
| Parameter | Type | What it does |
| textrequired |
string |
the text to tidy |
Example
print(squeeze(" a b "))
startsWith
returns bool
startsWith(text: string, prefix: string) -> bool
True when 'text' begins with 'prefix'. Case-sensitive.
| Parameter | Type | What it does |
| textrequired |
string |
the string to test |
| prefixrequired |
string |
the beginning to look for |
Example
if startsWith(line, "You") { print("about you") }
startsWithAny
returns bool
startsWithAny(text: string, prefixes: list<string>) -> bool
True when the text starts with ANY of the given beginnings — startsWith over a whole list in one ask.
| Parameter | Type | What it does |
| textrequired |
string |
the text to test |
| prefixesrequired |
list<string> |
the beginnings to try, any one of which passes |
Example
if startsWithAny("You swing", split("You,The", ",")) { print("hit") }
strLen
returns int
strLen(text: string) -> int
How many characters a string holds. Empty string is zero.
| Parameter | Type | What it does |
| textrequired |
string |
the string to measure |
Example
print("length", strLen("hello"))
substring
returns string
substring(text: string, from: int, toExclusive: int) -> string
The piece of a string between two positions. Both ends are clamped to the string, so an over-long range just gives what is there rather than faulting.
| Parameter | Type | What it does |
| textrequired |
string |
the string to cut from |
| fromrequired |
int |
the first character to keep, counting from zero |
| toExclusiverequired |
int |
one past the last character to keep |
Example
print(substring("iron ore", 0, 4))
textLines
returns list<string>
textLines(text: string) -> list<string>
The text cut into its lines — split on line breaks, both Windows and Unix endings understood.
| Parameter | Type | What it does |
| textrequired |
string |
the text to cut up |
Example
print(count(textLines("a")))
title
returns string
title(text: string) -> string
The string with the first letter of every word in upper case, for a heading.
| Parameter | Type | What it does |
| textrequired |
string |
the string to title-case |
Example
print(title("iron ore"))
trim
returns string
trim(text: string) -> string
The string with spaces removed from both ends.
| Parameter | Type | What it does |
| textrequired |
string |
the string to trim |
Example
print(trim(" banked "))
trimEnd
returns string
trimEnd(text: string) -> string
The text with the spaces taken off its END only — trim() does both ends.
| Parameter | Type | What it does |
| textrequired |
string |
the text to tidy |
Example
print(trimEnd(" hi "))
trimStart
returns string
trimStart(text: string) -> string
The text with the spaces taken off its FRONT only — trim() does both ends.
| Parameter | Type | What it does |
| textrequired |
string |
the text to tidy |
Example
print(trimStart(" hi "))
upper
returns string
upper(text: string) -> string
The text in upper case.
| Parameter | Type | What it does |
| textrequired |
string |
the string to fold |
Example
print(upper(name))
urlDecode
returns string?
urlDecode(text: string) -> string?
The text a URL-encoded fragment holds, or none when it is not valid encoding — the other half of urlEncode.
| Parameter | Type | What it does |
| textrequired |
string |
the URL-encoded text |
Example
print(urlDecode("a+b%26c"))
urlEncode
returns string
urlEncode(text: string) -> string
The text escaped for use inside a URL — spaces, symbols and anything else that would break one, encoded.
| Parameter | Type | What it does |
| textrequired |
string |
the text to make URL-safe |
Example
print(urlEncode("a b&c"))
wordCount
returns int
wordCount(text: string) -> int
How many words a string holds — runs of non-space split by spaces.
| Parameter | Type | What it does |
| textrequired |
string |
the string to count words in |
Example
print("words", wordCount("one two three"))
words
returns list<string>
words(text: string) -> list<string>
A list of the words in a string, split on spaces, with empty pieces dropped.
| Parameter | Type | What it does |
| textrequired |
string |
the string to split into words |
Example
print("words", count(words("one two three")))
wrapText
returns list<string>
wrapText(text: string, width: int) -> list<string>
The text broken into lines no wider than 'width', breaking at spaces where it can — the word wrap behind a hand-drawn paragraph. Walk it with for and paintText each line.
| Parameter | Type | What it does |
| textrequired |
string |
the words to wrap |
| widthrequired |
int |
the longest a line may be, 1 or more |
Example
for line in wrapText("a few words to wrap", 8) { print(line) }
No command on this page matches that. The search box looks across every page.