print

Prints any number of arguments (space separated) at the current cursor position in the current term. All the arguments will automatically be converted to a string using the tostring function, and concatenated, separated by spaces. This function automatically moves to the next line after writing. As well as this, it performs text wrapping, meaning if the string is too big for the term, it will continue writing on the next line. print returns the number of lines it printed.

  • Y This function will insert a newline after printing.
  • Y This function supports writing multiple objects. They will all be converted to strings using the tostring method, and automatically separated with spaces.
  • Y This function supports writing newlines (e.g. via the \n character).
  • Y This function will wrap the text when it is longer than the screen width.
  • If you don't want a trailing newline, consider using write or io.write instead.
  • If you would like lower level access to the terminal object, consider using term.write instead.
ExamplePrint a basic string
Prints "Hello, world!" to the current term.
Code
<nowiki>
print("Hello, world!")
    </nowiki>
Output
Hello, world!
ExamplePrint multiple strings
Prints "foo bar" to the current term.
Code
<nowiki>
print("foo", "bar")
    </nowiki>
Output
foo bar
ExamplePrint multiple types
Prints strings and numbers to the current term in a single print call.
Code
<nowiki>
local cats = 5
local dogs = 3
print("Cats:", cats, "Dogs:", dogs)
    </nowiki>
Output
Cats: 5 Dogs: 3

print
Function
Syntax
print(
  • toPrint... : any
)

Returns number linesPrinted
API BIOS globals
Source CC:Tweaked (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.