Difference between revisions of "Peripheral (API)"
(→Monitor) |
|||
Line 79: | Line 79: | ||
|Sets the size of the text on the Monitor. Textscale can be between 1.0 and 5.0, with increments of 0.5 | |Sets the size of the text on the Monitor. Textscale can be between 1.0 and 5.0, with increments of 0.5 | ||
|} | |} | ||
+ | ==Printer== | ||
+ | List of methods: | ||
+ | '''''printer'' stands for the variable you wrapped the printer to.''' | ||
+ | ''Example:'' printer = peripheral.wrap( "right" ) | ||
+ | |||
+ | {| border="1" cellpadding="2" cellspacing="0" | ||
+ | !style="background:#EEE" width="200px"|Method name | ||
+ | !style="background:#EEE" width="*"|Description | ||
+ | |- | ||
+ | |printer.[[printer.getPaperLevel|getPaperLevel]]() | ||
+ | |Returns the amount of paper available in the paper tray. | ||
+ | |- | ||
+ | |printer.[[printer.getCursorPos|getCursorPos]]() | ||
+ | |Returns the coordinates of the cursor on the paper, works the same way as [[term.getCursorPos()]] | ||
+ | |- | ||
+ | |printer.[[printer.getPageSize|getPageSize]]() | ||
+ | |Returns the size of the paper, works the same way as [[term.getSize()]] | ||
+ | |- | ||
+ | |printer.[[printer.getInkLevel|getInkLevel]]() | ||
+ | |Returns the amount of ink in the ink slot. | ||
+ | |- | ||
+ | |printer.[[printer.setCursorPos|setCursorPos]]( x, y ) | ||
+ | |Sets the cursor pos. | ||
+ | |- | ||
+ | |printer.[[printer.newPage|newPage]]() | ||
+ | |Starts a new page. Returns true if page got started, false if not. | ||
+ | |- | ||
+ | |printer.[[printer.write|write]]( text ) | ||
+ | |Writes text to the paper, works the same way as [[term.write()]] | ||
+ | |- | ||
+ | |printer.[[printer.setPageTitle|setPageTitle]]( text ) | ||
+ | |Sets the title of the page. | ||
+ | |- | ||
+ | |printer.[[printer.endPage|endPage]]() | ||
+ | |Ends the page and prints the page to the output tray. Returns true if page was ended, false if not. | ||
+ | |} | ||
==Computers== | ==Computers== | ||
List of methods: | List of methods: |
Revision as of 21:22, 22 September 2012
The peripheral API is for interacting with external peripherals, such as the disk drive and monitor.
Consoles and Turtles are also considered peripherals and you can interface two adjacent computers, although in a more limited fashion compared to rednet. Both Computers and Turtles provide the same methods: turnOn, shutdown, reboot, getID.
Contents
Methods
Method name | Description |
---|---|
peripheral.isPresent( side ) | Returns true if a peripheral is present on side. |
peripheral.getType( side ) | Returns the type or peripheral present on side, nothing returned if side is empty. |
peripheral.getMethods( side ) | Returns a table containing all methods for peripheral on side. |
peripheral.call( side, methodName, param1, param2, ... ) | Sends a function call to peripheral located on side. Return values match those of called method. Note: methodName is a string. |
peripheral.wrap( side ) | Returns a handle to the peripheral located on side. If assigned to a variable, it can be used to call all methods available from that peripheral, as if calling peripheral.call(), e.g.: m = peripheral.wrap("left") |
Events
Event name | Description | Parameters |
---|---|---|
peripheral | Fired when peripheral is attached | side |
peripheral_detach | Fired when peripheral is removed | side |
Monitor
List of methods:
mon stands for the variable you wrapped the monitor to. Example: mon = peripheral.wrap( "top" )
Method name | Description |
---|---|
mon.write() | Write to the Monitor's screen. |
mon.scroll( n ) | Scrolls the monitor screen. |
mon.setCursorPos( x, y ) | Sets the cursor position on the Monitor. |
mon.setCursorBlink( b ) | Enables or disables cursor blinking. |
mon.getCursorPos() | Returns two arguments containing the x and the y position of the cursor on the Monitor. |
mon.getSize() | Returns two arguments containing the x and the y values stating the size of the Monitor. |
mon.clear() | Clears the Monitor. |
mon.clearLine() | Clears the line the cursor is on. |
mon.setTextScale( scale ) | Sets the size of the text on the Monitor. Textscale can be between 1.0 and 5.0, with increments of 0.5 |
Printer
List of methods:
printer stands for the variable you wrapped the printer to. Example: printer = peripheral.wrap( "right" )
Method name | Description |
---|---|
printer.getPaperLevel() | Returns the amount of paper available in the paper tray. |
printer.getCursorPos() | Returns the coordinates of the cursor on the paper, works the same way as term.getCursorPos() |
printer.getPageSize() | Returns the size of the paper, works the same way as term.getSize() |
printer.getInkLevel() | Returns the amount of ink in the ink slot. |
printer.setCursorPos( x, y ) | Sets the cursor pos. |
printer.newPage() | Starts a new page. Returns true if page got started, false if not. |
printer.write( text ) | Writes text to the paper, works the same way as term.write() |
printer.setPageTitle( text ) | Sets the title of the page. |
printer.endPage() | Ends the page and prints the page to the output tray. Returns true if page was ended, false if not. |
Computers
List of methods:
computer stands for the variable you wrapped the computer to. Example: computer = peripheral.wrap( "top" )
Method name | Description |
---|---|
computer.turnOn() | Turns on the Computer or Turtle. |
computer.shutdown() | Shuts off the Computer or Turtle. |
computer.reboot() | Reboots the Computer or Turtle. |
computer.getID() | Gets the ID of the Computer or Turtle. |