Browse docsstring.format
On this page
API method

string.format

Returns a string where each {} in fmt is replaced by the next argument in order.

Syntax

Atlas Script
string.format(fmt, ...args)

Parameters

fmt
Format string whose {} placeholders are filled by the following arguments in order.
...args Optional
Additional values substituted in order for the remaining {} placeholders in the format string.

Return value

Returns string.

Remarks

Returns a string where each {} in fmt is replaced by the next argument in order. Extra {} with no argument become empty; extra arguments are ignored. Example: string.format("this {} is a test {}", 10, "cool") -> "this 10 is a test cool".

Examples

Inspect the controller family.atlas
event on_connect() {
    system.log(string.format("Controller at Run: {}", system.controller));
}

event on_input() {
    if (input.pressed("options")) {
        if (input.controller == controller.ps5) {
            system.log("PlayStation 5 controller");
        } else if (input.controller == controller.xb) {
            system.log("Xbox controller");
        } else {
            system.log(string.format("Controller family: {}", input.controller));
        }
    }
}
Reference details are generated from the Atlas Script schema in this documentation source snapshot. Confirm release-specific behavior in the Atlas for Windows build you use.