StringUtils

Utilities View source
StringUtils

Custom Function which can split strings and runs callback for each string. It can run even with no delimiter present (with single element). Example usage: “H001,H002”.forEachIn(“,”) -> doSomething()

Source on GitHub

Interfaces

ForStringSplitCallback

public interface ForStringSplitCallback

Members:

  • callback(string str)

Tuples

char

public tuple char(int c)

Functions

createCenteredTexttag

public function createCenteredTexttag(vec3 pos, string message, real size) returns texttag

char

public function char(string s) returns char

charToIndex

public function charToIndex(char c) returns int

charFromIndex

public function charFromIndex(int index) returns char

Extension Functions

texttag.center

public function texttag.center(vec3 pos, string message, real size) returns texttag

string.getWidth

public function string.getWidth() returns int

Returns the width of the string

char.toString

public function char.toString() returns string

char.toInt

public function char.toInt() returns int

char.getWidth

public function char.getWidth() returns int

string.toChar

public function string.toChar() returns char

string.toCharList

public function string.toCharList() returns LinkedList<char>

int.toChar

public function int.toChar() returns char

string.split

public function string.split(string splitBy) returns LinkedList<string>

Splits the string by another string “this..is..an..example” split by the string “..” splits into a list containing four strings [“this”, “is”, “an”, “example”]

string.reduce

public function string.reduce(string reduced) returns string

Replaces consecutive repeats of the same string with a single instance Turns “strstr” into “str”

string.reduce

public function string.reduce() returns string

Replaces consecutive repeats of the whitespace character with a single instance Turns “ “ into “ “

string.forEachIn

public function string.forEachIn(string delim, ForStringSplitCallback cb)

string.isNumber

public function string.isNumber() returns bool

Checks whether a string is a number or not.

string.isValidDescription

public function string.isValidDescription() returns bool

Checks whether a string is valid in terms of max WC3 string length for various usages (Ability Description, Quest Description,…).

string.replaceChars

public function string.replaceChars(string charset, string replacementChar) returns string

Replaces all occurences of any character from given charlist by a given replacement string.