write

Writes text at the current cursor position in the current term. Unlike print, this function does not automatically move to the next line after writing, however it does perform text wrapping, meaning if the string is too big for the term, it will continue writing on the next line. write returns the number of extra lines it printed (i.e. if it did not need to wrap to the next line, it will return 0).

  • N This function will not insert a newline after printing.
  • N This function does not support printing multiple objects. You will have to concatenate them together into a single string.
  • 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, or would like to print multiple objects, consider using print instead.
  • If you would like lower level access to the terminal object, consider using term.write instead.
ExampleWrite to the term
Writes "Hello, world!" to the current term.
Code
<nowiki>
write("Hello, world!")
    </nowiki>
Output
Hello, world!
ExampleWrite multiple strings the term
Writes "foobar" to the current term. Note how there is no space between writes.
Code
<nowiki>
write("foo")
write("bar")
    </nowiki>
Output
foobar
ExampleWrite a very long string
Writes "foo" to the current term 50 times. Note how it automatically wraps to the next line where necessary.
Code
<nowiki>
write(("foo "):rep(50))
    </nowiki>
Output

write
Function
Syntax
write(
  • text : string
)

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.