Difference between revisions of "Peripheral.find"
From ComputerCraft Wiki
MKlegoman357 (Talk | contribs) m (Expanded) |
|||
Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=peripheral.find | |name=peripheral.find | ||
− | |args={{type|string}} type | + | |args={{type|string}} type [, {{type|function}} fnFilter( name, object )] |
|returns={{Type|table}} handle1, {{Type|table}} handle2, ... handles to peripherals of the given type | |returns={{Type|table}} handle1, {{Type|table}} handle2, ... handles to peripherals of the given type | ||
|api=peripheral | |api=peripheral |
Revision as of 02:32, 20 April 2014
![]() | |
Returns a handle to a peripheral of the supplied type that can then be used to call methods, as if using peripheral.call(side, method). The same handle is returned using peripheral.wrap(). Requires ComputerCraft 1.6 or later. | |
Syntax | peripheral.find(string type [, function fnFilter( name, object )]) |
Returns | table handle1, table handle2, ... handles to peripherals of the given type |
Part of | ComputerCraft |
API | peripheral |
Examples
![]() | |
Finds a monitor and writes 'Hello' on it. | |
Code |
local monitor = peripheral.find("monitor") if monitor then monitor.write("Hello") end |
Output | If there is a monitor connected 'Hello' will be written on it. |