Bubba, on 11 August 2013 - 08:03 AM, said:
immibis, on 11 August 2013 - 07:15 AM, said:
Use peripheral.getNames() if you want it to work with wired modems.
I believe wired modems use peripheral.getNamesRemote(), though I could be wrong
That's the modem method called internally. The peripheral api has the getNames function which checks all sides for peripherals, and if one is a wired modem it calls getNamesRemote to get attached peripherals.
CometWolf, on 11 August 2013 - 08:23 AM, said:
When you're using wired modems you would also have to change up the if statment a little bit
if string.match(peripheral.getType(tSides[i]),"monitor") then
This is because when using a wired modem each connected peripheral gets assigned an id(id_peripheralType). Usually this id is 0, unless you have multiple of the same peirpheral conneted.
That's for the name/side of the peripheral, not for the type. So no need for any extra checks.
OP: This should work for you:
for _,name in ipairs(peripheral.getNames()) do
--# tell the user there's a peripheral
print("There's a ", peripheral.getType(name), " on ", name)
--# if you need to use a certain peripheral, like a monitor:
if peripheral.getType(name) == "monitor" then
--# here you can store the monitor side
monitorSide = name
--# or directly wrap the monitor
monitor = peripheral.wrap(name)
--# or whatever you need to do
break
end
end