Term API

Returns the current terminal object of the computer. This is useful to keep track of terminal objects when term.redirect was used.
Syntax term.current()
Returns table
Part of CC:Tweaked
API term
ExampleReturn to the previous term
Finds a monitor, redirects the term object and afterwards redirects back to the original term.
local mon = peripheral.find("monitor")
local previousTerm = term.current()
term.redirect(mon) -- Redirects the terminal object to a monitor.
term.write("Hello, World") -- This will show on the monitor
term.redirect(previousTerm) -- Redirects back to the original terminal object.
Output Prints "Hello, World" on the first monitor peripheral.find discovers.
Returns the native terminal object of the current computer. This is useful if you want to return to your previous term when term.redirect was used. It is recommended that you avoid using this function when possible. May cause problems with multi-shell and other windowed applications. Instead keep track of the terminal object you want to return to using term.current.
Syntax term.native()
Returns table
Part of CC:Tweaked
API term
Redirects to a terminal, and returns all Term objects available in the specified terminal.
Syntax term.redirect(
  • term : table
Returns table terminal
Part of CC:Tweaked
API term
ExampleMake a window and write some text in it
Makes a window, redirects to it, writes some text, and then goes back to the native window.
local win = window.create(2, 2, 10, 10, term.native())
print("Hello world!")
print("This is in the main area.")
Output Shows a window with some text in it and some text in the main term.
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.