From 7215da0cd6723ebe147757752843c295c5f9ab03 Mon Sep 17 00:00:00 2001 From: brianluau Date: Fri, 9 Dec 2011 02:46:31 +0000 Subject: - Added ToastOfDoom's String Commands Package. (tid:53411, topic:204976) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15039 54d463be-8e91-2dee-dedb-b68131a5f0ec --- doc/script_commands.txt | 187 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) (limited to 'doc/script_commands.txt') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index f5d9a9cee..a10002f0e 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -6589,6 +6589,193 @@ This function will return 1 if the character number Position in the given string is a letter, 0 if it isn't a letter but a digit or a space. The first letter is position 0. +--------------------------------------- + +*charat(,) + + Returns char at specified index. If index is out of range, + returns empty string. + + Example: + + charat("This is a string", 10); //returns "s" + +--------------------------------------- + +*setchar(,,) + + Returns the original string with the char at the specified + index set to the specified char. If index out of range, the + original string will be returned. + Only the 1st char in the parameter will be used. + + Example: + + setchar("Cat", "B", 0); //returns "Bat" + +--------------------------------------- + +*insertchar(,,) + + Returns the original string with the specified char inserted + at the specified index. If index is out of range, the char + will be inserted on the end of the string that it is closest. + Only the 1st char in the parameter will be used. + + Example: + + setchar("laughter", "s", 0); //returns "slaughter" + +--------------------------------------- + +*delchar(,) + + Returns the original string with the char at the specified index + removed. If index is out of range, original string will be returned. + + Example: + + delchar("Diet", 3); //returns "Die" + +--------------------------------------- + +*strtoupper() +*strtolower() + + Returns the specified string in it's uppercase/lowercase form. + All non-alpha characters will be preserved + + Example: + + strtoupper("The duck is blue!!"); //returns "THE DUCK IS BLUE!!" + +--------------------------------------- + +*charisupper(,) +*charislower(,) + + Returns 1 if character at specified index of specified string is + uppercase/lowercase. Otherwise, 0. Characters not of the alphabelt + will return 0. + + Example: + + charisupper("eAthena", 1); //returns 1 + +--------------------------------------- + +*substr(,,) + + Returns the sub-string of the specified string inclusively between + the set indexes. + If indexes are out of range, or the start index is after the end + index, an empty string will be returned. + + Example: + + substr("foobar", 3, 5); //returns "bar" + +--------------------------------------- + +*explode(,,) + + Breaks a string up into substrings based on the specified delimiter. + Substrings will be stored within the specified string array. + Only the 1st char of the delimiter parameter will be used. + If an empty string is passed as a delimiter, the string will be placed + in the array in it's original form. + + Example: + + explode(.@my_array$, "Explode:Test:1965:red:PIE", ":"); + //.@my_array$ contents will be... + //.@my_array$[0]: "Explode" + //.@my_array$[1]: "Test" + //.@my_array$[2]: "1965" + //.@my_array$[3]: "red" + //.@my_array$[4]: "PIE" + + +--------------------------------------- + +*implode({,}) + + Combines all substrings within the specified string array into a single string. + If the glue parameter is specified, it will be inserted inbetween each substring. + + Example: + setarray .@my_array$[0], "This", "is", "a", "test"; + implode(.@my_array$, " "); //returns "This is a test" + +--------------------------------------- + +*sprintf([,param[,param[,...]]]) [Mirei] + + C style sprintf. The resulting string is returned same as in PHP. All C format + specifiers are supported except %n. More info: sprintf @ www.cplusplus.com. + The number of params is only limited by eA's script engine. + + See thread: http://www.eathena.ws/board/index.php?showtopic=190410 + + Example: + .@format$ = 'The %s contains %d monkeys'; + dispbottom(sprintf(.@format$, "zoo", 5)); //prints "The zoo contains 5 monkeys" + dispbottom(sprintf(.@format$, "barrel", 82)); //prints "The barrel contains 82 monkeys" + +--------------------------------------- + +*sscanf(,[,param[,param[,...]]]) [Mirei] + + C style sscanf. All C format specifiers are supported. + More info: sscanf @ www.cplusplus.com. The number of params is only limited + by eA's script engine. + + See thread: http://www.eathena.ws/board/index.php?showtopic=191157 + + Example: + sscanf("This is a test: 42 foobar", "This is a test: %d %s", .@num, .@str$); + dispbottom(.@num + " " + .@str$); //prints "42 foobar" + +--------------------------------------- + +*strpos(,{,}) + + PHP style strpos. Finds a substring (needle) within a string (haystack). + The offset parameter indicates the index of the string to start searching. + Returns index of substring on successful search, else -1. + Comparison is case sensitive. + + Example: + strpos("foobar", "bar", 0); //returns 3 + strpos("foobarfoo", "foo", 0); //returns 0 + strpos("foobarfoo", "foo", 1); //returns 6 + +--------------------------------------- + +*replacestr(, , {, {, }}) + + Replaces all instances of a search string in the input with the specified + replacement string. By default is case sensitive unless is set + to 0. If specified it will only replace as many instances as specified + in the count parameter. + + Example: + replacestr("testing tester", "test", "dash"); //returns "dashing dasher" + replacestr("Donkey", "don", "mon", 0); //returns "monkey" + replacestr("test test test test test", "yay", 0, 3); //returns "yay yay yay test test" + +--------------------------------------- + +*countstr(, {, }) + + Counts all instances of a search string in the input. By default is case + sensitive unless is set to 0. + + Example: + countstr("test test test Test", "test"); //returns 3 + countstr("cake Cake", "Cake", 0); //returns 2 + + --------------------------------------- *setfont -- cgit v1.2.3-60-g2f50