term.current

From ComputerCraft
Jump to navigation Jump to search

term.current
Function
Syntax
term.current()
Returns table
API term
Source CC:Tweaked

Returns the current terminal object of the computer. This is useful to keep track of terminal objects when term.redirect was used.

ExampleExampleReturn to the previous term
Finds a monitor, redirects the term object and afterwards redirects back to the original term.
Code
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.