Difference between revisions of "Peripheral (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Updated to API overview v2)
m ({{NeedsWork|Remote peripheral wrapping via Cables isn't listed on this page.}})
Line 1: Line 1:
 +
{{NeedsWork|Remote peripheral wrapping via Cables isn't listed on this page.}}
 
The Peripheral API is for interacting with external [http://en.wikipedia.org/wiki/Peripheral peripherals], such as the [[Disk Drive]], the [[Advanced Monitor]] and [[Monitor]].<br />
 
The Peripheral API is for interacting with external [http://en.wikipedia.org/wiki/Peripheral peripherals], such as the [[Disk Drive]], the [[Advanced Monitor]] and [[Monitor]].<br />
 
[[Computer|Computers]] and [[Turtle|Turtles]] are also considered peripherals and you can interface two adjacent computers, although in a more limited fashion compared to [[Rednet (API)|rednet]]. Both Computers and Turtles provide the same methods: ''turnOn'', ''shutdown'', ''reboot'', ''getID''.
 
[[Computer|Computers]] and [[Turtle|Turtles]] are also considered peripherals and you can interface two adjacent computers, although in a more limited fashion compared to [[Rednet (API)|rednet]]. Both Computers and Turtles provide the same methods: ''turnOn'', ''shutdown'', ''reboot'', ''getID''.

Revision as of 12:25, 17 March 2013

This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: Remote peripheral wrapping via Cables isn't listed on this page.)

The Peripheral API is for interacting with external peripherals, such as the Disk Drive, the Advanced Monitor and Monitor.
Computers 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.

Grid disk.png   Peripheral (API)

Method NameDescription
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")
m.someMethod()
- is the same as -
peripheral.call("left","someMethod")

Monitor

Monitor Peripheral functions have been moved to the Monitor page. In addition, the Advanced Monitor Peripheral functions have been moved to the Advanced Monitor page.

Printer

Printer Peripheral functions have been moved to the Printerpage.

Computers

Computer Peripheral functions have been moved to the Computer page. In addition, the Advanced Computer Peripheral functions have been moved to the Advanced Computer page.