Difference between revisions of "Term (API)"

From ComputerCraft Wiki
Jump to: navigation, search
m (Turtles -> Turtle)
(Updated to API overview v2)
Line 3: Line 3:
 
Methods in ''italics'' are available only to [[Advanced Computer|Advanced Computers]] and [[Advanced Monitor|Advanced Monitors]].
 
Methods in ''italics'' are available only to [[Advanced Computer|Advanced Computers]] and [[Advanced Monitor|Advanced Monitors]].
  
{| border="1" cellpadding="2" cellspacing="0"
+
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
!style="background:#EEE" width="200px"|Method name
+
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
!style="background:#EEE" width="*"|Description
+
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;
|-
+
Term (API)
|[[term.write]](text)
+
</td></tr>
|Writes text to the screen.
+
 
|-
+
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
|[[term.clear]]()
+
 
|Clears the entire screen
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.write]](text)</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Writes text to the screen.</td></tr>
|[[term.clearLine]]()
+
 
|Clears the line the cursor is on
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.clear]]()</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Clears the entire screen</td></tr>
|[[term.getCursorPos]]()
+
 
|Returns two arguments containing the x and the y position of the cursor.
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.clearLine]]()</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Clears the line the cursor is on</td></tr>
|[[term.setCursorPos]](x, y)
+
 
|Sets the cursor's position.
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.getCursorPos]]()</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns two arguments containing the x and the y position of the cursor.</td></tr>
|[[term.setCursorBlink]](bool)
+
 
|Disables the blinking or turns it on.
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.setCursorPos]](x, y)</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets the cursor's position.</td></tr>
|[[term.isColor]]()
+
 
|Returns if the computer supports color. (Used to determine whether or not an advanced computer is being used)
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.setCursorBlink]](bool)</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Disables the blinking or turns it on.</td></tr>
|[[term.getSize]]()
+
 
|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 [[Turtle|Turtles]] and [[Computer|Computers]].)
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.isColor]]()</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns if the computer supports color. (Used to determine whether or not an [[Advanced Computer]] is being used)</td></tr>
|[[term.scroll]](n)
+
 
|Scrolls the terminal ''n'' lines.
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.getSize]]()</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">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 [[Turtle|Turtles]] and [[Computer|Computers]].)</td></tr>
|[[term.redirect]](target)
+
 
|Redirects terminal output to a monitor or other redirect target. (Use [[peripheral.wrap]] to acquire a monitor "object".)
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.scroll]](n)</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Scrolls the terminal ''n'' lines.</td></tr>
|[[term.restore]]()
+
 
|Restores terminal output to the previous target.
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.redirect]](target)</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Redirects terminal output to a monitor or other redirect target. (Use [[peripheral.wrap]] to acquire a monitor "object".)</td></tr>
|''[[term.setTextColor]]([[Colors (API)|color]])''
+
 
|Sets the text-color of the terminal. Available only to [[Advanced Computer|Advanced Computers]] and [[Advanced Monitor|Advanced Monitors]].
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[term.restore]]()</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Restores terminal output to the previous target.</td></tr>
|''[[term.setBackgroundColor]]([[Colors (API)#Colors|color]])''
+
 
|Sets the background color of the terminal. Available only to [[Advanced Computer|Advanced Computers]] and [[Advanced Monitor|Advanced Monitors]].
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">''[[term.setTextColor]]([[Colors (API)|color]])''</td>
|-
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets the text-color of the terminal. Available only to [[Advanced Computer|Advanced Computers]] and [[Advanced Monitor|Advanced Monitors]].</td></tr>
|}
+
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">''[[term.setBackgroundColor]]([[Colors (API)#Colors|color]])''</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets the background color of the terminal. Available only to [[Advanced Computer|Advanced Computers]] and [[Advanced Monitor|Advanced Monitors]].</td></tr>
 +
</table>
 +
 
 +
 
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 22:49, 30 November 2012

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.

Grid disk.png   Term (API)

Method NameDescription
term.write(text) Writes text to the screen.
term.clear() Clears the entire screen
term.clearLine() Clears the line the cursor is on
term.getCursorPos() Returns two arguments containing the x and the y position of the cursor.
term.setCursorPos(x, y) Sets the cursor's position.
term.setCursorBlink(bool) Disables the blinking or turns it on.
term.isColor() Returns if the computer supports color. (Used to determine whether or not an Advanced Computer is being used)
term.getSize() 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(n) Scrolls the terminal n lines.
term.redirect(target) Redirects terminal output to a monitor or other redirect target. (Use peripheral.wrap to acquire a monitor "object".)
term.restore() Restores terminal output to the previous target.
term.setTextColor(color) Sets the text-color of the terminal. Available only to Advanced Computers and Advanced Monitors.
term.setBackgroundColor(color) Sets the background color of the terminal. Available only to Advanced Computers and Advanced Monitors.