string.format

Replaces placeholder strings in a string with the specified arguments.

ExampleReplace placeholders in a string
Replace %s with what the user enters.
Code
<nowiki>
local name = read()
print(string.format("Hello, %s!", name))
    </nowiki>
Output Prints "Hello," and whatever the user entered.
ExampleReplace placeholders in a variable
Replace %s with what the user enters.
Code
<nowiki>
local name = read()
local output = "Hello, %s!"
print(output:format(name))
    </nowiki>
Output Prints "Hello," and whatever the user entered.

string.format
Function
Syntax
string.format(
  • str : string
  • strings... : any
)

Returns string output
API string
Source Lua
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.