Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.00

Description

Description:

Composes a string from the defined text, replacing any variables with the passed arguments.

To convert a string back to a number, use parseNumber.

Syntax

Syntax:format [formatString, var1, var2, ...]
Parameters:
  • formatString: String - A string containing text and / or references to the variables passed after the string. The references appear in the form of %1%2, and so on. Line breaks can be defined as \n.
  • var1: Any Value - Variable referenced by %1.
  • var2: Any Value - Variable referenced by %2.
Return Value:String - The full string (with replaced variables). In versions below V3.5, the maximum length for a string is 2048. In V3.5+, the limit is only restricted by the available memory, and is "unlimited" for all practical purposes.

Examples

Examples:
hint format ["Player: %1\nSide: %2\nPosition: %3", player, side player, getPos player]
// Might return:
// Player: WEST 1-1-A:1 (Username)
// Side: WEST
// Position: [2500.20,3100.00,0.00]

Additional Information

See also: str
Multiplayer:
Problems:

Notes







Kronzky
Since any percent sign in the 'formatString' is interpreted as a variable (whether it's followed by a number or not), it can be tricky to output the sign itself. Here's a method that works by putting it into a variable:
hint format["100%1 true","%"] // outputs "100% true"