Term
A term (short for terminal) is a standardised data structure in ComputerCraft. It describes anything that can be drawn to, e.g. the screen of a Computer, a Window, or an Advanced Monitor. All term objects must implement the same functions, but can also add their own.
Term functions
These functions are shared by all term objects.
|
|||||||||||
Writes text at the current cursor position in the current term, using foreground colors from textColour (a string containing colors as used in images loadable by paintutils functions) and background colors from backgroundColour (same as textColour). All characters represent a single hexadecimal digit which is then plugged into the equation c=2^(h-1) where h is the hexadecimal plugged in and c is a the equivalent color that would be plugged into term.setTextColor. | |||||||||||
Syntax | term.blit(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
|
|
|||||||||||
Clears the terminal object using the current background colour. The term's cursor position, text colour and background colour states remain unchanged. | |||||||||||
Syntax | term.clear() | ||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
| |||||||||||
|
|
|||||||||||
Clears the line on a terminal object using the current Y cursor position and background colour. The term's cursor position, text colour and background colour states remain unchanged. | |||||||||||
Syntax | term.clearLine() | ||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
| |||||||||||
| |||||||||||
|
|
|||||||||||
Returns the numerical value of the current background colour of the terminal object. | |||||||||||
Syntax | term.getBackgroundColour() | ||||||||||
Returns | number colour | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
| |||||||||||
|
|
|||||||||||
Returns the current X and Y position of the cursor of the terminal object. | |||||||||||
Syntax | term.getCursorPos() | ||||||||||
Returns | number x, number y | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
|
|
|||||||||||
Returns the RGB values (0–1) of the specified palette colour of the terminal object. | |||||||||||
Syntax | term.getPaletteColour(
|
||||||||||
Returns | number red, number green, number blue | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
| |||||||||||
|
|
||||||||||||||||
Returns the width and height (in characters) of the terminal object.
|
||||||||||||||||
Syntax | term.getSize() | |||||||||||||||
Returns | number width, number height | |||||||||||||||
Part of | CC:Tweaked (source) | |||||||||||||||
API | term | |||||||||||||||
|
|
|||||||||||
Returns the numerical value of the current text colour of the terminal object. | |||||||||||
Syntax | term.getTextColour() | ||||||||||
Returns | number colour | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
| |||||||||||
|
|
|||||||||||
Returns whether or not this terminal object supports colour.
This returns true for Advanced Computers, Advanced Turtles, Advanced Pocket Computers, Advanced Monitors and Neural Interfaces. This returns false for Basic Computers, Basic Turtles, Basic Monitors and Basic Pocket Computers. |
|||||||||||
Syntax | term.isColour() | ||||||||||
Returns | boolean | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
|
|
|||||||||||
Moves everything on the screen up distance pixels. | |||||||||||
Syntax | term.scroll(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
|
|
|||||||||||
Sets the background colour of the terminal object. All text written after calling this function will have this background colour, until it is changed again. | |||||||||||
Syntax | term.setBackgroundColour(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
|
|
|||||||||||
Sets whether or not a blinking cursor should appear at the current cursor pos in the terminal object. When the cursor moves, the blinking cursor will move too, and it will continue to blink until it is manually turned off. | |||||||||||
Syntax | term.setCursorBlink(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
|
|
|||||||||||
Sets the X and Y position of the cursor on the terminal object. The next write on this terminal object will begin from the new cursor position. | |||||||||||
Syntax | term.setCursorPos(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
|
|
|||||||||||
Sets the RGB value of the specified palette colour of the terminal object. This allows you to change the appearance of all text and background using this colour.
The first argument is the colour that you want to change, e.g.
|
|||||||||||
Syntax | term.setPaletteColour(
term.setPaletteColour(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
| |||||||||||
|
|
|||||||||||
Sets the text colour of the terminal object. All text written after calling this function will have this colour, until it is changed again. | |||||||||||
Syntax | term.setTextColour(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
|
|
|||||||||||
Writes text at the current cursor position in the current term. Unlike print, this function does not automatically move to the next line after writing. Additionally, unlike write and print, it does not perform any text wrapping. | |||||||||||
Syntax | term.write(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | term | ||||||||||
| |||||||||||
|
Term events
Most of these events are shared by all term objects, but some, such as mouse events, are available exclusively for Advanced Interfaces.
|
|||||||||
Occurs every time the user typed a letter. | |||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
|
|
|||||||||
Occurs every time the user presses down a key or when a key is being repeated because it's being held down. | |||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
|
|
|||||||||
Occurs every time the user releases a previously pressed down key. | |||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
|
|
|||||||||
Occurs every time a mouse button is pressed.
![]() |
|||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
|
|
|||||||||
Occurs every time the mouse moves to a different position while a mouse button is held down (e.g. left click dragging). It will always be called after a mouse_click event.
![]() |
|||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
|
|
|||||||||
Occurs every time a mousewheel scrolls.
![]() |
|||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
|
|
|||||||||
Occurs every time a mouse button is released after it was pressed down.
![]() |
|||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
|
|
|||||||||
Occurs every time the user pastes text into a terminal, with Ctrl-V | |||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
| |||||||||
|
|
|||||||||
Occurs every time the term resizes. | |||||||||
Returns |
|
||||||||
Part of | CC:Tweaked | ||||||||
|
gollark: Kit imploded?
gollark: Well, the obvious solution is to make a separate "serious esolangs" and transfer executive authority over this one to me imminently.
gollark: What?
gollark: Since shiny machine learning™ things exist.
gollark: Anyway, the GPU thing is very annoying because I "need" arbitrarily large quantities of GPU power for things now.
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.