Term (API)

From ComputerCraft Wiki
Revision as of 02:43, 25 August 2013 by Immibis (Talk | contribs) (Added return types)

Jump to: navigation, search

The Terminal API provides functions for writing text to the terminal and monitors, and drawing ASCII graphics.

Methods in italics are available only to Advanced Computers and Advanced Monitors. Methods in bold are available only to Monitors.

Grid disk.png  Term (API)
Function Return values Description
term.write(string text) nil Writes text to the screen.
term.clear() nil Clears the entire screen
term.clearLine() nil Clears the line the cursor is on
term.getCursorPos() nil Returns two arguments containing the x and the y position of the cursor.
term.setCursorPos(number x, number y) nil Sets the cursor's position.
term.setCursorBlink(boolean bool) nil Disables the blinking or turns it on.
term.isColor() boolean Returns if the computer supports color. (Used to determine whether or not an Advanced Computer is being used)
term.getSize() number x, number y Returns two arguments containing the x and the y values stating the size of the screen. (Good for if you're making something to be compatible with both Turtles and Computers.)
term.scroll(number n) nil Scrolls the terminal n lines.
term.redirect(target) nil Redirects terminal output to a monitor or other redirect target. (Use peripheral.wrap to acquire a monitor "object".)
term.restore() nil Restores terminal output to the previous target.
term.setTextColor(number color) nil Sets the text color of the terminal. Available only to Advanced Computers and Advanced Monitors.
term.setBackgroundColor(number color) nil Sets the background color of the terminal. Available only to Advanced Computers and Advanced Monitors.
monitor.setTextScale(number scale) nil Sets the text scale on a Monitor.