Modem.getNamesRemote

From ComputerCraft Wiki
Jump to: navigation, search
Grid Redstone.png  Function modem.getNamesRemote
Essentially the same as peripheral.getNames(), which returns a numerically-indexed table containing the names of all peripherals attached to the system; however, this function only returns peripherals which are specifically connected to the Wired Modem you called it through.
Syntax modem.getNamesRemote()
Returns table peripheralNames
Part of ComputerCraft
API Modem

Examples

Grid paper.png  Example
Prints a list of all peripherals attached to a modem, along with their type.
Code
local modem = peripheral.wrap("top")  -- Or whatever side the modem is attached to.

local periList = modem.getNamesRemote()

for i = 1, #periList do
	print("I have a "..peripheral.getType(periList[i]).." attached as \""..periList[i].."\".")
end
Output Depending on the peripherals available, along the lines of:

I have a monitor attached as "monitor_0".
I have a printer attached as "printer_0".

etc...