Strings
Script location: global/strings.scr
This file holds some functions for string formatting and parsing strings in different ways. These include:
Convert a array to lower case.
Usage: exec global/strings.scr::Array_to_lower (const array of strings)
Returns: Array of lower case strings
Convert a array to upper case.
usage: exec global/strings.scr::Array_to_upper (const array of strings)
returns: Array of upper case strings
Instr will find the position in wich a string is found at.
Usage: exec global/strings.scr::InStr (string to find \ string)
returns the position of string_to_find
eg
exec global/strings.scr::InStr "\" "hell\o"
gives 4 because it starts at 0
If none found it will return NIL
Right will return a string of characters from the right.
usage: waitexec global/strings.scr::Right ( Number of characters#, STRING STRING )
Returns a string right from the number given as position
eg
local.string = waitexec global/strings.scr::Right 3 "hello"
local.string will be 'llo'
Left will return Left of the string for the given number.
usage: waitexec global/strings.scr::Right (NUMBER OF CHARACTERS LEFT, STRING STRING )
Returns a string left from the number given as position
eg
local.string = waitexec global/strings.scr::Left 3 "hello" "left"
local.string will be 'hell'
Mid will return a string from a given position for a given number of characters.
usage: local.string = waitexec global/strings.scr ( START POS, STRING, COUNT)
returns: The string from start pos of string along the count.
eg
local.string = waitexec global/strings.scr 3 "hello" 2
local.string would become 'll'
Reverse will reverse a given string.
useage:: local.string = waitexec global/strings.scr (STRING STRING)
result: gives a string that is backwards to the string given.
eg
local.string = waitexec global/strings.scr::Reverse "hello"
local.string would become 'olleh'
This will convert a given string to lower case
usage local.string = waitexec global/strings.scr::to_lower (STRING STRING, INDEX TO CONVERT)
Result: a lower case string
eg
local.string = waitexec global/strings.scr::to_lower "HELLO"
local.string will become 'hello'
eg2
local.string = waitexec global/strings.scr::to_lower "HELLO" 0
local.string will become 'hELLO'
This will convert a given string to upper case
usage local.string = waitexec global/strings.scr::to_upper (STRING STRING, INDEX TO CONVERT)
Result: a upper case string
eg
local.string = waitexec global/strings.scr::to_upper "hello"
local.string will become 'HELLO'
eg2
local.string = waitexec global/strings.scr::to_upper "hello" 0
local.string will become 'Hello'
Used to split a line of words into a array of words. return with word count
localinfo == line to split
local.say = say to admins input detected or not, set 1 usualu
local.spacer = WHat to use to split the line. If none is set then " " will be used.
usage local.wordarray = waitexec global/strings.scr::split_line ( STRING STRING , CONSOLE FEEDBACK, STRING SPACER)
eg
local.wordarray = waitexec global/strings.scr::split_line "hello_mummy" 1 "_"
local.wordarray is a const array
local.wordarray[1] = array of words
local.wordarray[2] word count
local.wordarray[3] full string with " " spaces
local.wordarray[1][1] is 'hello'
local.wordarray[1][1] is 'mummy'
local.wordarray[2] is 2 'two words'
local.wordarray[3] is 'hello mummy'
Replace is used just like replace in notepad or any text editor.
It will replace any string in a string with a string of any size.
exec global/strings::Replace ( String string , String String to replace, string string to replace with )
eg
local.string = waitexec global/strings.scr::Replace "once_upon_a_time_there_was__a_mod" "_" " " local.string would become
"once upon a time there was a mod"
Remove is used to remove words or single characters from a line.
exec global/strings::Remove ( String string , String String to replace )
eg
local.string = waitexec global/strings.scr::Remove "hello you idiot" "idiot"
local.string would become
"hello you idiot"
Format_replace is used like Replace except it will only replace a single instance in a group of the same haracter.
It will only replace single characters.
exec global/strings::Replace ( String string , String String to replace, string string to replace with )
eg
local.string = waitexec global/strings.scr::Format_replace "once_upon_a_time_there_was__a_mod" "_" " " local.string would become
"once upon a time there was_a mod"
Combine combines a array of stirngs into one single string of all.
exec global/strings:;Combine (ARRAY , INT START IN ARRAY)