Difference between revisions of "Term (API)"

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

Revision as of 08:45, 20 January 2013

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)
Function Return values Description
term.write(text) Writes text to the screen. odd
term.clear() Clears the entire screen
term.clearLine() Clears the line the cursor is on odd
term.getCursorPos() Returns two arguments containing the x and the y position of the cursor.
term.setCursorPos(x, y) Sets the cursor's position. odd
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) odd
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. odd
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. odd
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. odd