API Docs for:
Show:

FormatHelper Class

The format-helper contains a of functions usable inside of scripts or javascript formulas which are in regular used to calculate display text. The functions are technically not bound to a FormatHelper class. Example:

WRONG: { ........ "valueFormula": "return FormatHelper.fmtNumVar(p.variable)" } CORRECT: { ........ "valueFormula": "return fmtNumVar(p.variable)" }

Methods

fmtBoolVar

(
  • variableOrValue
)
String | Boolean

Returns the display text for the specified boolean variable (Switch) or value. If the specified variable is actually a boolean value the boolean value will be returned without any formatting.

Parameters:

  • variableOrValue Variable | Boolean
    • The variable or constant value.

Returns:

String | Boolean:

The formatted display text or the constant boolean value.

fmtColor

(
  • color
)
String

Returns the display text for the specified color.

Parameters:

  • color Color
    • The color to get the display text for.

Returns:

String:

The formatted display text.

fmtDocument

(
  • uid
)
String

Returns the display text for the specified document.

Parameters:

  • uid String
    • The UID of the document to get the diplay text for.

Returns:

String:

The formatted display text.

fmtDuration

(
  • durationValue
)
String

Returns the display text for a duration value. It converts the duration value, which is stored in frames internally, into milliseconds and adds "ms" suffix. So an input value of 60 results in "1000ms" display text. (If GS.CONST.GAME_FRAME_RATE is 60).

Parameters:

  • durationValue Number
    • The duration value to get the display text for.

Returns:

String:

The display text.

fmtListVar

(
  • variable
)
String

Returns the display text for the specified list variable.

Parameters:

  • variable Variable
    • The list variable

Returns:

String:

The formatted display text.

fmtNumVar

(
  • variableOrValue
)
String | Number

Returns the display text for the specified number variable or value. If the specified variable is actually a number value the number value will be returned without any formatting.

Parameters:

  • variableOrValue Variable | Number
    • The variable or constant value.

Returns:

String | Number:

The formatted display text or the constant number value.

fmtRecord

(
  • category
  • index
)
String

Returns the display text for the specified database record.

Parameters:

  • category String
    • The database category name
  • index Number
    • The index of the database record to get the display text for. The index starts at 0.

Returns:

String:

The formatted display text.

fmtResource

(
  • resource
)
String

Returns the display text for a resource. The specified resource can also be a string variable.

Parameters:

  • resource Resource
    • The resource to get the display text for.

Returns:

String:

The display text.

fmtStrVar

(
  • variableOrValue
)
String

Returns the display text for the specified string variable or value. If the specified variable is actually a string value the string value will be returned without any formatting.

Parameters:

  • variableOrValue Variable | String
    • The variable or constant value.

Returns:

String:

The formatted display text or the constant string value.

fmtTone

(
  • tone
)
String

Returns the display text for the specified tone.

Parameters:

  • tone Tone
    • The tone to get the display text for.

Returns:

String:

The formatted display text.

fmtVar

(
  • variableOrValue
  • type
)
String | Number | String | Boolean

Returns the display text for the specified variable or value. If the specified variable is actually a constant value the value will be returned without any formatting.

Parameters:

  • variableOrValue Variable | Number | String | Boolean
    • The variable or constant value.
  • type String
    • The variable type, can be: "numbers", "strings", "booleans" or "lists".

Returns:

String | Number | String | Boolean:

The formatted display text or the constant number value.

isVar

(
  • value
)
Boolean

Indicates if the specified value is actually a variable.

Parameters:

  • value Object
    • The value to check.

Returns:

Boolean:

If true the value is a variable. Otherwise false.

lcs

(
  • key
  • bundleName
)
String

Returns the translated phrase for the specified phrase-key. The name "lcs" originally stand for "Language Configuration String".

Parameters:

  • key String
    • The phrase's key. It can also be . to directly specify the bundle.
  • bundleName String
    • The name of the bundle to read the phrase from. Can be omitted if the bundle name is already specified in key-string.

Returns:

String:

The translated phrase.

lcsg

(
  • text
)
String

Returns the text for the specified localizable string. It can be a localized string object like or a constant string. The function will check if a text for the lcId of the localized string object exists in the game's language configuration. If not, the defaultText property of the localized string object will be returned. If that property is null or not present the function returns:

STRING NOT FOUND:

If a constant string is specified the function will just return that string. The name "lcsg" originally stand for "Language Configuration String Game". See data-format reference for more info about LocalizedString object.

Parameters:

  • text String | LocalizedString
    • The localized string object to get the text for.

Returns:

String:

The text for the localized string object.

record

(
  • category
  • index
)
Object

Returns database record at the specified index.

Parameters:

  • category String
    • The database category name
  • index Number
    • The index of the database record to get. The index starts at 0.

Returns:

Object:

The database record which is not the whole document but only the items.data content.

scase

(
  • value
  • values
  • results
)
Object

Executes a quick switch-case on the specified values. For Example:

scase(1, [0, 1, 2], ["Apple", "Orange", "Banana"])

Output:

Orange

The name "scase" stands for "switch-case".

Parameters:

  • value Object
    • The value to check.
  • values Object
    • The values to check against.
  • results Object
    • The result values.

Returns:

Object:

The matching value or null if none of the specified values matches.