Difference between revisions of "Monitor"

From ComputerCraft Wiki
Jump to: navigation, search
(Peripheral Functions)
m (Added elaboration on monitor wrapping.)
Line 17: Line 17:
 
[[Category:Blocks]]
 
[[Category:Blocks]]
  
==Using the Monitor==
+
==Redirecting Programs to a Monitor==
 
[[File:Computer_w_DiskDrive_w_Monitor.png|frame|428x241px|right|A 2x2 [[Monitor]], connected to a [[Computer]], with a [[Disk Drive]] connected.]]
 
[[File:Computer_w_DiskDrive_w_Monitor.png|frame|428x241px|right|A 2x2 [[Monitor]], connected to a [[Computer]], with a [[Disk Drive]] connected.]]
The command used to control a monitor: monitor [top, bottom, left, right, front or back] [the name of the command to display]
+
From the CraftOS shell, type <tt>monitor [top|bottom|left|right|front|back] [a-program-name]</tt>. For example, typing <tt>monitor top hello</tt> would show "Hello world." on the top Monitor.
  
So, in this case, if you typed "hello" in the name of the program part, the monitor would display "Hello World!".
+
==Monitor as a Peripheral==
 +
To use a Monitor, you need to either call a method directly using [[peripheral.call]](), or, wrap the monitor using the [[Peripheral_(API)|Peripheral API]]. Wrapped monitors provide all functions listed in the [[Term_(API)|Term API]].
  
==Using the Monitor within the Lua interface==
+
For this example, we have a Monitor connected to the top of our [[Computer]]:
The monitor can be summoned through a command or through coding with the Lua command.
+
  
The command used to control a monitor within the Lua interface: shell.run("monitor" "[top, bottom, left, right, front or back]" "[the name of the command to display]")
+
-- Immediately invoke a method without wrapping
 +
peripheral.call("top", "write", "Hello World!")
  
For example, here is a way of summoning the monitor through a command:
+
-- You can also "wrap" the peripheral side to a variable:
 
+
local monitor = peripheral.wrap("top")
<tt>[[print]]("Hello Monitor!")
+
monitor.write("Hello World!")
 
+
[[Shell (API)|shell]].[[Shell.run|run]]("monitor", "right", "hello")</tt>
+
 
+
== See also ==
+
[[Monitor (API)]]
+
  
 
[[Category:Blocks]][[Category:Peripherals]]
 
[[Category:Blocks]][[Category:Peripherals]]

Revision as of 13:40, 20 January 2013

Grid workbench.png   Monitor
Iso Monitor.png
Item ID 4094
Damage Value 0
Peripheral? Yes

The Monitor is a block that can display text on its front side. When several screen blocks are placed on the same plane, it will form a single monitor. It is useful for displaying information at a server spawn, showing a program on the monitor, and even showing the status of an IC2 reactor! (provided you have CcSensors installed)

Recipe

stone

stone

stone

stone

glass_pane

stone

stone

stone

stone

Monitor


Redirecting Programs to a Monitor

A 2x2 Monitor, connected to a Computer, with a Disk Drive connected.

From the CraftOS shell, type monitor [top|bottom|left|right|front|back] [a-program-name]. For example, typing monitor top hello would show "Hello world." on the top Monitor.

Monitor as a Peripheral

To use a Monitor, you need to either call a method directly using peripheral.call(), or, wrap the monitor using the Peripheral API. Wrapped monitors provide all functions listed in the Term API.

For this example, we have a Monitor connected to the top of our Computer:

-- Immediately invoke a method without wrapping
peripheral.call("top", "write", "Hello World!")
-- You can also "wrap" the peripheral side to a variable:
local monitor = peripheral.wrap("top")
monitor.write("Hello World!")