Goonstation 13 - Modules - TypesProc Details

/kText

Procs

autoBreakAdds linebreaks to the string every X characters. If the character at the position we want to place the linebreak at isn't whitespace, it will look for the next whitespace character before placing it. @param string The string to be modified. @param charsPerLine How many characters should be on each separate line. @return The modified string, with linebreaks placed every X characters. IE: autoBreak("I am not a crook.", 5) would return "I am\nnot a\ncrook."
autoCompleteCheck if the given needle's characters all match the string's characters. For example, the needle "ca" -- since "ca" begins the string "cake", "ca" is a match to it, thus "auto-completes" to it. @param string The string to be matched against. @param needle The string we want to know if matches. @return if needle matches string, returns string. otherwise, null. IE: autoComplete("hippo", "h") would return "hippo".
autoCompleteCaseThe case-sensitive version of autoComplete(). @see kText.autoComplete()
capitalizeCapitalize the first character in a string. @param string The string to be capitalized. @return the capitalized form of the string.
file2listReads the contents of a file and separates it into a list, using the specified delimiter to separate entries. @param file The file object, or string referring to the file. @param delimiter The delimiter used to separate the text. @return Returns the listified version of the file. null if a bad file was given.
file2listCaseThe case-sensitive version of file2list(). @see kText.file2list()
findNextWhitespaceFinds the next occurrence of white space in a string, starting at the given position. @param string The string to be queried. @param pos Where to start searching for whitespace. @return the position of the next occurrence of whitespace, or null of there is no occurrence.
findWhichFinds the xth occurence of a string within another string. @param string The string to be queried. @param sub The string to search for. @param which Which occurrence of the string {sub} to look for. @return the starting position of the xth (which) occurrence of {sub} within {string}. 0 if nothing is found. IE: findWhich("a b a", "a", 2) would return 5 (where the second occurrence of "a" is). if which is -1, it will find the last occurrence of the substring.
findWhichCaseThe case-sensitive version of findWhich(). @see kText.findWhich()
getCharacterGets the character at the given position in the string. @param string The string to be queried. @param pos The position of the character to be gotten. @return the character at the given position in the given string.
hasPrefixAttempts to determine if the string is prefixed with the given prefix. @param string The string to check against. @param prefix The prefix to check for. @return 1 if the prefix was found. Just think of it as TRUE. 0 if the prefix was not found.
hasPrefixCaseThe case-sensitive version of hasPrefix(). @see kText.hasPrefix()
hasSuffixAttempts to determine if the string is suffixed with the given suffix. @param string The string to check against. @param suffix The suffix to check for. @return The beginning of the suffix in the string (string's length - suffix's length + 1) if it is found. 0 if the suffix was not found.
hasSuffixCaseThe case-sensitive version of hasSuffix(). @see kText.hasSuffix()
isWhitespaceCheck if the character at the given position in the string is whitespace. @param string The string to be queried. @param pos The position to be checked. @return TRUE if it is whitespace. FALSE otherwise.
limitTextLimits the max length of a string. @param length The maximum length a string can be. @return If the string is longer than the given string, returns the string after it is cut short. Otherwise, the entire string.
list2textConverts a list into a string, placing a delimiter inbetween entries in the list. @param list The list to be textified. @param delimiter The string to place inbetween list entries. @return the string form of the list. IE: list2text(list("this", "is", "a", "test"), " ") would return "this is a test".
matchKeysChecks if any of the space-delimited words within {needle} match to the space-delimited words in {string}.
matchKeysCaseThe case-sensitive version of matchKeys(). @see kText.matchKeys()
noBreakRemoves linebreaks from the given string, replacing them with spaces. @param string The string to be modified. @return The string, with linebreaks replaced with spaces.
padTextPads a string so it is the given size. @param string The string to be padded. @param size The size the string should be padded to. @param padSide The side to place the padding on the string. @param padText The text to be used to pad the string. @return the padded form of the given string. IE: padText("Attributes:", 15, PAD_LEFT) would return " Attributes:".
repeatTextSimply repeats the given string a certain amount of times. @param string The string to repeat. @param count The amount to be repeated. @return The string, repeated [count] times.
replaceTextReplaces all occurrences of one string within another string, with another string. @param string The string to be queried. @param sub The string to be searched for. @param replace The string to be used as a replacement. @return the given string, with all occurrences of {sub} replaced with {replace}. IE: replaceText("i love cake", "cake", "pie") would return "i love pie".
replaceTextCaseThe case-sensitive version of replaceText(). @see kText.replaceText()
text2listConverts a string into a list, using a delimiter to determine where to separate entries. @param string The string to be listified. @param delimiter The string that will serve as a separator between entries in the list. @return the list form of the string. IE: text2list("this is a test", " ") would return list("this", "is", "a", "test").
text2listCaseThe case-sensitive version of text2list(). @see kText.text2list()
trimWhitespaceRemoves preceeding and following whitespace in a string. @param string The string to be trimmed. @return the trimmed string. IE: trimWhitespace(" this is a string ] ") would return "this is a string ]".

Proc Details

autoBreak

Adds linebreaks to the string every X characters. If the character at the position we want to place the linebreak at isn't whitespace, it will look for the next whitespace character before placing it. @param string The string to be modified. @param charsPerLine How many characters should be on each separate line. @return The modified string, with linebreaks placed every X characters. IE: autoBreak("I am not a crook.", 5) would return "I am\nnot a\ncrook."

note: To keep the newly created lines consistent, this will also remove any extra whitespace at the beginning and ends of newly added lines.

autoComplete

Check if the given needle's characters all match the string's characters. For example, the needle "ca" -- since "ca" begins the string "cake", "ca" is a match to it, thus "auto-completes" to it. @param string The string to be matched against. @param needle The string we want to know if matches. @return if needle matches string, returns string. otherwise, null. IE: autoComplete("hippo", "h") would return "hippo".

autoCompleteCase

The case-sensitive version of autoComplete(). @see kText.autoComplete()

capitalize

Capitalize the first character in a string. @param string The string to be capitalized. @return the capitalized form of the string.

file2list

Reads the contents of a file and separates it into a list, using the specified delimiter to separate entries. @param file The file object, or string referring to the file. @param delimiter The delimiter used to separate the text. @return Returns the listified version of the file. null if a bad file was given.

file2listCase

The case-sensitive version of file2list(). @see kText.file2list()

findNextWhitespace

Finds the next occurrence of white space in a string, starting at the given position. @param string The string to be queried. @param pos Where to start searching for whitespace. @return the position of the next occurrence of whitespace, or null of there is no occurrence.

findWhich

Finds the xth occurence of a string within another string. @param string The string to be queried. @param sub The string to search for. @param which Which occurrence of the string {sub} to look for. @return the starting position of the xth (which) occurrence of {sub} within {string}. 0 if nothing is found. IE: findWhich("a b a", "a", 2) would return 5 (where the second occurrence of "a" is). if which is -1, it will find the last occurrence of the substring.

findWhichCase

The case-sensitive version of findWhich(). @see kText.findWhich()

getCharacter

Gets the character at the given position in the string. @param string The string to be queried. @param pos The position of the character to be gotten. @return the character at the given position in the given string.

hasPrefix

Attempts to determine if the string is prefixed with the given prefix. @param string The string to check against. @param prefix The prefix to check for. @return 1 if the prefix was found. Just think of it as TRUE. 0 if the prefix was not found.

hasPrefixCase

The case-sensitive version of hasPrefix(). @see kText.hasPrefix()

hasSuffix

Attempts to determine if the string is suffixed with the given suffix. @param string The string to check against. @param suffix The suffix to check for. @return The beginning of the suffix in the string (string's length - suffix's length + 1) if it is found. 0 if the suffix was not found.

hasSuffixCase

The case-sensitive version of hasSuffix(). @see kText.hasSuffix()

isWhitespace

Check if the character at the given position in the string is whitespace. @param string The string to be queried. @param pos The position to be checked. @return TRUE if it is whitespace. FALSE otherwise.

limitText

Limits the max length of a string. @param length The maximum length a string can be. @return If the string is longer than the given string, returns the string after it is cut short. Otherwise, the entire string.

list2text

Converts a list into a string, placing a delimiter inbetween entries in the list. @param list The list to be textified. @param delimiter The string to place inbetween list entries. @return the string form of the list. IE: list2text(list("this", "is", "a", "test"), " ") would return "this is a test".

matchKeys

Checks if any of the space-delimited words within {needle} match to the space-delimited words in {string}.

This matching uses the same method of matching as autoComplete().

Basically, "c p" matches "cake pie", because "c" and "p" autocomplete to "cake" and "pie", respectively.

It should also be noted that if one of the keywords in {needle} does not have a match in {string}, the match will fail.

matchKeys("giant king monster", "giant monster") would return "giant king monster".

matchKeys("giant king monster", "giant snail") would return null, because "snail" has no match.

matchKeysCase

The case-sensitive version of matchKeys(). @see kText.matchKeys()

noBreak

Removes linebreaks from the given string, replacing them with spaces. @param string The string to be modified. @return The string, with linebreaks replaced with spaces.

padText

Pads a string so it is the given size. @param string The string to be padded. @param size The size the string should be padded to. @param padSide The side to place the padding on the string. @param padText The text to be used to pad the string. @return the padded form of the given string. IE: padText("Attributes:", 15, PAD_LEFT) would return " Attributes:".

note: When using PAD_BOTH, the given text will attempt to be centered. This function assumes a fixed-width font, which means if the size of the padding is uneven, then one side (the right side) will be given an extra padding.

		For example, padText("ABC", 6, PAD_BOTH, "-") would require atleast 3
		padding characters. Since this can't be split down the middle,
		one of the padding characters will be added to the end of the string:
		"-ABC--".

repeatText

Simply repeats the given string a certain amount of times. @param string The string to repeat. @param count The amount to be repeated. @return The string, repeated [count] times.

replaceText

Replaces all occurrences of one string within another string, with another string. @param string The string to be queried. @param sub The string to be searched for. @param replace The string to be used as a replacement. @return the given string, with all occurrences of {sub} replaced with {replace}. IE: replaceText("i love cake", "cake", "pie") would return "i love pie".

replaceTextCase

The case-sensitive version of replaceText(). @see kText.replaceText()

text2list

Converts a string into a list, using a delimiter to determine where to separate entries. @param string The string to be listified. @param delimiter The string that will serve as a separator between entries in the list. @return the list form of the string. IE: text2list("this is a test", " ") would return list("this", "is", "a", "test").

text2listCase

The case-sensitive version of text2list(). @see kText.text2list()

trimWhitespace

Removes preceeding and following whitespace in a string. @param string The string to be trimmed. @return the trimmed string. IE: trimWhitespace(" this is a string ] ") would return "this is a string ]".