Find API
roger109z 05 Apr 2016
This API is intended to find peripherals!
Functions:
find.modem()
-finds any modem attached to your computer (returns the side string)
find.computer()
-finds any computer on the notwork or attacked to the computer (returns all computers table)
find.mon()
-finds any monitor connected to the network (returns all monitors table)
todo
-add filters for advanced monitors/computers
-add disks and printers
-add filters for checking if a modem is wireless
Edited by roger109z, 05 April 2016 - 01:28 AM.
Pastebin code: wpA73N2E
Functions:
find.modem()
-finds any modem attached to your computer (returns the side string)
find.computer()
-finds any computer on the notwork or attacked to the computer (returns all computers table)
find.mon()
-finds any monitor connected to the network (returns all monitors table)
todo
-add filters for advanced monitors/computers
-add disks and printers
-add filters for checking if a modem is wireless
Edited by roger109z, 05 April 2016 - 01:28 AM.
roger109z 06 Apr 2016
no peripheral.find wraps the first peripheral it finds this returns all of the peripherals and can be used for rednet.
Anavrins 06 Apr 2016
peripheral.find does returns all peripherals...
With modem1, modem2, modem3 = peripheral.find("modem") or modems = { peripheral.find("modem") }
Additionally, it takes a filter function, peripheral.find("modem", function(side, obj) return obj.isWireless() end) to only get wireless modems, (return not obj.isWireless()) for only wired ones.
Similar thing with monitors using obj.isColor().
Edited by Anavrins, 06 April 2016 - 02:57 AM.
With modem1, modem2, modem3 = peripheral.find("modem") or modems = { peripheral.find("modem") }
Additionally, it takes a filter function, peripheral.find("modem", function(side, obj) return obj.isWireless() end) to only get wireless modems, (return not obj.isWireless()) for only wired ones.
Similar thing with monitors using obj.isColor().
Edited by Anavrins, 06 April 2016 - 02:57 AM.
roger109z 11 Apr 2016
but peripheral.find WRAPS a modem
this returns the side so it can be used with rednet
this returns the side so it can be used with rednet
Anavrins 11 Apr 2016
peripheral.find("modem", function(side) rednet.open(side) end) would achieve the same thing.
Bomb Bloke 11 Apr 2016
Truth be told, peripheral.find("modem", rednet.open) would be more efficient again. Though I believe that one was pointed out to me in a similar fashion...
Suffice to say, while peripheral.find() is a great function with uses that aren't immediately obvious, this API may still be useful for a user who doesn't have it - there are a variety of CC builds in use out there, and 1.6 or later is required for peripheral.find().
Suffice to say, while peripheral.find() is a great function with uses that aren't immediately obvious, this API may still be useful for a user who doesn't have it - there are a variety of CC builds in use out there, and 1.6 or later is required for peripheral.find().