Monitors are a block which act as a terminal, displaying information on one side. This allows them to be read and
interacted with in-world without opening a GUI.
Monitors act as terminal redirects and so expose the same methods, as well as several additional
ones, which are documented below.
If the monitor is resized (by adding new blocks to the monitor, or by calling setTextScale), then a
monitor_resize event will be queued.
Like computers, monitors come in both normal (no colour) and advanced (colour) varieties. Advanced monitors be right
clicked, which will trigger a monitor_touch event.
Recipes
Monitor
Advanced Monitor
4
Usage
Write "Hello, world!" to an adjacent monitor:```lua
local monitor = peripheral.find("monitor")
monitor.setCursorPos(1, 1)
monitor.write("Hello, world!")
Write text at the current cursor position, moving the cursor to the end of the text.
Unlike functions like write and print, this does not wrap the text - it simply copies the
text to the current terminal line.
Move all positions up (or down) by y pixels.
Every pixel in the terminal will be replaced by the line y pixels below it. If y is negative, it
will copy pixels from above instead.
Parameters
ynumber The number of lines to move up by. This may be a negative number.
Determine if this terminal supports colour.
Terminals which do not support colour will still allow writing coloured text/backgrounds, but it will be
displayed in greyscale.
Determine if this terminal supports colour.
Terminals which do not support colour will still allow writing coloured text/backgrounds, but it will be
displayed in greyscale.
Writes text to the terminal with the specific foreground and background colours.
As with write, the text will be written at the current cursor location, with the cursor
moving to the end of the text.textColour and backgroundColour must both be strings the same length as text. All
characters represent a single hexadecimal digit, which is converted to one of CC's colours. For instance,"a" corresponds to purple.
Set the palette for a specific colour.
ComputerCraft's palette system allows you to change how a specific colour should be displayed. For instance, you
can make colors.redmore red by setting its palette to #FF0000. This does now allow you to draw more
colours - you are still limited to 16 on the screen at one time - but you can change which colours are
used.
Parameters
indexnumber The colour whose palette should be changed.
colournumber A 24-bit integer representing the RGB value of the colour. For instance the integer
0xFF0000 corresponds to the colour #FF0000.
Or
indexnumber The colour whose palette should be changed.
rnumber The intensity of the red channel, between 0 and 1.
gnumber The intensity of the green channel, between 0 and 1.
bnumber The intensity of the blue channel, between 0 and 1.
Usage
Change the red colour from the default #CC4C4C to #FF0000.```lua
term.setPaletteColour(colors.red, 0xFF0000)
term.setTextColour(colors.red)
print("Hello, world!")
As above, but specifying each colour channel separately.```lua
term.setPaletteColour(colors.red, 1, 0, 0)
term.setTextColour(colors.red)
print("Hello, world!")
See also
colors.unpackRGB To convert from the 24-bit format to three separate channels.
colors.packRGB To convert from three separate channels to the 24-bit format.
Set the palette for a specific colour.
ComputerCraft's palette system allows you to change how a specific colour should be displayed. For instance, you
can make colors.redmore red by setting its palette to #FF0000. This does now allow you to draw more
colours - you are still limited to 16 on the screen at one time - but you can change which colours are
used.
Parameters
indexnumber The colour whose palette should be changed.
colournumber A 24-bit integer representing the RGB value of the colour. For instance the integer
0xFF0000 corresponds to the colour #FF0000.
Or
indexnumber The colour whose palette should be changed.
rnumber The intensity of the red channel, between 0 and 1.
gnumber The intensity of the green channel, between 0 and 1.
bnumber The intensity of the blue channel, between 0 and 1.
Usage
Change the red colour from the default #CC4C4C to #FF0000.```lua
term.setPaletteColour(colors.red, 0xFF0000)
term.setTextColour(colors.red)
print("Hello, world!")
As above, but specifying each colour channel separately.```lua
term.setPaletteColour(colors.red, 1, 0, 0)
term.setTextColour(colors.red)
print("Hello, world!")
See also
colors.unpackRGB To convert from the 24-bit format to three separate channels.
colors.packRGB To convert from three separate channels to the 24-bit format.