Difference between revisions of "Peripheral.wrap"
From ComputerCraft Wiki
(Fixed incorrect type displaying) |
Bomb Bloke (Talk | contribs) (Returns nil if handed an invalid side.) |
||
Line 3: | Line 3: | ||
|name=peripheral.wrap | |name=peripheral.wrap | ||
|args= {{type|string}} side | |args= {{type|string}} side | ||
− | |returns= | + | |returns={{type|table}} handle |
|api=peripheral | |api=peripheral | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc=Returns a | + | |desc=Returns a table containing functions pointing to the peripheral's methods, which can then be called as if using peripheral.call(side, method). If no peripheral is found at the specified "side", returns {{type|nil}} instead. |
|examples= | |examples= | ||
{{Example | {{Example | ||
|desc=Shuts down the computer or turtle on the right side of the calling machine. | |desc=Shuts down the computer or turtle on the right side of the calling machine. | ||
− | |code=local handle = peripheral.wrap("right") handle.shutdown() | + | |code= local handle = peripheral.wrap("right") |
+ | handle.shutdown() | ||
|output=Shuts down any computer to the right of the computer/turtle. | |output=Shuts down any computer to the right of the computer/turtle. | ||
}} | }} |
Revision as of 13:02, 1 April 2014
Function peripheral.wrap | |
Returns a table containing functions pointing to the peripheral's methods, which can then be called as if using peripheral.call(side, method). If no peripheral is found at the specified "side", returns nil instead. | |
Syntax | peripheral.wrap(string side) |
Returns | table handle |
Part of | ComputerCraft |
API | peripheral |