Peripheral API

From ComputerCraft
Jump to: navigation, search

Peripheral.call Peripheral.find Peripheral.getMethods Peripheral.getNames

FunctionFunctionperipheral.getType
Returns the type of peripheral attached at the specified side or network name. Returns nil when no peripheral is attached at the specified side or network name.
Syntax peripheral.getType(
  • side or network name : string
)
Returns boolean result
Part of Lua (source)
API peripheral
ExampleExampleGet peripheral type
Gets and prints the type of peripheral attached to the top side.
Code
print(peripheral.getType("top"))
Output If a wireless modem was attached, the output would be 'modem'.


FunctionFunctionperipheral.isPresent
Returns if there's a peripheral attached at the specified side or network name.
Syntax peripheral.isPresent(
  • side or network name : string
)
Returns boolean result
Part of Lua (source)
API peripheral
ExampleExampleCheck if there is a peripheral attached on top.
Checks and prints if there is a peripheral attached to the top side.
Code
print(peripheral.isPresent("top"))
Output true

Peripheral.wrap