Term (API)

From ComputerCraft Wiki
Revision as of 10:21, 28 June 2015 by Bomb Bloke (Talk | contribs)

Jump to: navigation, search

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

Functions in italics are only available to Monitors. Functions in bold are available only to Windows.

Grid disk.png  Term (API)
Function Return values Description
term.write(string text) nil Writes text to the screen, using the current text and background colors.
term.blit(string text, string text colors, string background colors) nil Writes text to the screen using the specified text and background colors.
term.clear() nil Clears the entire screen.
term.clearLine() nil Clears the line the cursor is on.
term.getCursorPos() number x, number y 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 whether the terminal supports color.
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) table previous terminal object Redirects terminal output to another terminal object (such as a window or wrapped monitor). Available only to the base term object.
term.current() table terminal object Returns the current terminal object. Requires version 1.6 or newer, available only to the base term object.
term.native() table terminal object Returns the original terminal object. Requires version 1.6 or newer, available only to the base term object.
term.setTextColor(number color) nil Sets the text color of the terminal. Limited functionality without an Advanced Computer / Turtle / Monitor.
term.getTextColor() number color Returns the current text color of the terminal. Requires version 1.74 or newer.
term.setBackgroundColor(number color) nil Sets the background color of the terminal. Limited functionality without an Advanced Computer / Turtle / Monitor.
term.getBackgroundColor() number color Returns the current background color of the terminal. Requires version 1.74 or newer.
monitor.setTextScale(number scale) nil Sets the text scale. Available only to monitor objects.
window.setVisible(boolean visibility) nil Determines whether subsequent renders to the window will be visible. Available only to window objects.
window.redraw() nil Redraws the contents of the window. Available only to window objects.
window.restoreCursor() nil Returns the cursor back to its position / state within the window. Available only to window objects.
window.getPosition() number x, number y Returns the top left co-ordinate of the window. Available only to window objects.
window.reposition(number x, number y [, number width, number height]) nil Moves and / or resizes the window. Available only to window objects.



Grid Modem.png  Event term_resize
Fired when the screen changes size (through opening a new tab with bg, etc). Requires version 1.6 or higher.
Returned Object 1 Nothing


Deprecated Functions

These functions have been deprecated.
These functions have been removed from ComputerCraft .
Grid disk.png  Term (API)
Function Return values Description
term.restore() nil Restores terminal output to the previous target. Removed by ComputerCraft 1.6.