string.char

Creates a string containing only the byte num. Hence, the number passed must be at least 0 and at most 255, and will be floored to the nearest integer.

ExamplePrint the decoded character of the byte entered in the user's input
Read a line from the user, then prints the character that the entered codepoint represents.
Code
<nowiki>
print(string.char(tonumber(read()))
    </nowiki>
Output Depends on what the user wrote. For instance, if they were to enter 65, the character printed would be A.

string.char
Function
Syntax
string.char(
  • num : number
)

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