Text Functions

From Danmakufu Wiki
Jump to: navigation, search

InstallFont

Arguments:
 1) Path to font

Loads the given font, which can be used with ObjText_SetFontType, allowing for usage of fonts that are not standard to Windows. Returns true if successful. Note, anything other than a Shift-JIS font will not be displayed properly if Danmakufu is run with AppLocale (before ph3 [.1 pre2]).

ToString

Arguments:
 1) value

Returns the value as a string, able to be used by text functions. (Text functions cannot normally read numbers.)

IntToString

Arguments:
 1) value

Returns the value as a string, omits any decimal places.

itoa

(integer to string)
Arguments:
 1) value

Converts an integer value to a string, but leaves out decimal places. (This function might behave identically to IntToString.)

rtoa

(real number to string)
Arguments:
 1) value

Converts any real number to a string.

rtos

(real number to string)
Arguments:
 1) format
 2) value
Format:
 "0" digit
 "." decimal position
 "#" space

Returns the value as a string, with some filtering options. The format is presented as a string that determines how many digits will be shown; it can contain any combination of the following three characters: "0", ".", "#". "0" is a slot for a digit. "." represents the decimal place in the string. "#" creates a space in the string.

For example, rtos("000.000", 1.23) = "001.230", and rtos("#00", 1.23) = " 01".

vtos

(variable to string)
Arguments:
 1) format
 2) value
Format:
 "-" right-justified
 "0" outputs 0 at unused places
 "d" integer
 "f" real
 "s" string

Returns the value as a string, with some more filtering options. The format string is different from rtos in that it's more of a code than directly defining the digits that will be shown. First, the number of digits on each side of the decimal are specified (000.00 is 3.2 in the format string). Unused digits will be filled with spaces. If preceded by a "-", the digits will be right-justified, adding blank spaces to the right instead of the left. If preceded by a "0", all digits not occupied by the value will be filled by zeroes. If ended with a "d", the value will be presented as an integer. If ended with an "f", the value will be presented as a real number. If ended with an "s", this indicates the value given was in the form of a string.

For example, vtos("03d", 1.23) = "001", vtos("3d", 1.23) = " 1", vtos("-3d", 1.23) = "1 ", and vtos("03.5f", 1.23) = "001.23000"

atoi

(string to integer)
Arguments:
 1) value

Converts a string to an integer. If there is a decimal part, then it will be truncated. If the string does not represent a valid number, then 0 will be returned.

ator

(string to real number)
Arguments:
 1) value

Converts a string to a real number. If the string does not represent a valid number, then 0 will be returned.

TrimString

Arguments:
    1) String
Returns:
    String

Returns the string with spaces removed from the beginning and ending of the text. For example, TrimString(" ABC ") will return "ABC".

SplitString

Arguments:
    1) Original String
    1) Delimiter
Returns:
    Array

Returns an array containing the split strings. For example, SplitString("A/123/BCD", "/") will return ["A", "123", "BCD"].