peripheral.getMethods

From ComputerCraft
Jump to navigation Jump to search

peripheral.getMethods
Function
Syntax
peripheral.getMethods()
Returns table
API peripheral
Source CC:Tweaked (source)

Returns a table listing the names of all the methods (roughly, operations it is capable of doing) supported by a given peripheral. Any of the methods it lists can be called using the peripheral object returned by peripheral.wrap and peripheral.find, or using peripheral.call, for the given peripheral.

ExampleExampleList methods of the peripheral on the left
This prints all the methods of whatever peripheral is on the left of the computer this is run on. You can replace "left" with another side or a peripheral's network name to list its methods instead
Code
for _, method in pairs(peripheral.getMethods "left") do
    print(method)
end
Output Depends on the peripheral on the left. If there is none it will error. As an example, for a modem, the methods it lists will include transmit, isOpen, isWireless, open, close, and closeAll.