Difference between revisions of "Peripheral.isPresent"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with very basic example)
 
(Semicolons are not needed, change single quotes to double)
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=peripheral.isPresent
 
|name=peripheral.isPresent
|args= [[string (type)|string]] side
+
|args= [[string (type)|(string)]] side
|returns=[[boolean]] Whether a peripheral is present on ''side''.
+
|returns=[[boolean|(boolean)]] whether a peripheral is present on ''side''.
 
|api=peripheral
 
|api=peripheral
 
|addon=ComputerCraft
 
|addon=ComputerCraft
Line 10: Line 10:
 
{{Example
 
{{Example
 
|desc=Prints true if a peripheral is detected on the computer's right side.
 
|desc=Prints true if a peripheral is detected on the computer's right side.
|code=print(peripheral.isPresent('right'));
+
|code=print(peripheral.isPresent("right"))
 
|output=true if a peripheral is attached to the computer's right side, false if nothing was detected on the computer's right side.
 
|output=true if a peripheral is attached to the computer's right side, false if nothing was detected on the computer's right side.
 
}}
 
}}
 
}}
 
}}

Revision as of 18:56, 16 September 2012


Grid Redstone.png  Function peripheral.isPresent
Tells you whether a peripheral is present on a side of the computer or the turtle.
Syntax peripheral.isPresent((string) side)
Returns (boolean) whether a peripheral is present on side.
Part of ComputerCraft
API peripheral

Examples

Grid paper.png  Example
Prints true if a peripheral is detected on the computer's right side.
Code
print(peripheral.isPresent("right"))
Output true if a peripheral is attached to the computer's right side, false if nothing was detected on the computer's right side.