From ComputerCraft
Jump to navigation Jump to search

  • toPrint... : any

Returns number linesPrinted
API BIOS globals
Source CC:Tweaked (source)

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.
ExampleExamplePrint a basic string
Prints "Hello, world!" to the current term.
print("Hello, world!")
Hello, world!
ExampleExamplePrint multiple strings
Prints "foo bar" to the current term.
print("foo", "bar")
foo bar
ExampleExamplePrint multiple types
Prints strings and numbers to the current term in a single print call.
local cats = 5
local dogs = 3
print("Cats:", cats, "Dogs:", dogs)
Cats: 5 Dogs: 3