peripheral.find

From ComputerCraft Wiki
Revision as of 19:52, 17 April 2014 by MKlegoman357 (Talk | contribs) (Expanded)

Jump to: navigation, search


Grid Redstone.png  Function peripheral.find
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)
Returns table handle1, table handle2, ... handles to peripherals of the given type
Part of ComputerCraft
API peripheral

Examples

Grid paper.png  Example
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.