54 posts
Location
Cali beetch
Posted 05 April 2016 - 02:24 AM
This API is intended to find peripherals!
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 on 05 April 2016 - 12:28 AM
756 posts
Posted 05 April 2016 - 03:09 AM
So, is this the same as peripheral.find?
54 posts
Location
Cali beetch
Posted 06 April 2016 - 03:35 AM
no peripheral.find wraps the first peripheral it finds this returns all of the peripherals and can be used for rednet.
756 posts
Posted 06 April 2016 - 03:38 AM
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 on 06 April 2016 - 01:57 AM
54 posts
Location
Cali beetch
Posted 11 April 2016 - 04:12 AM
but peripheral.find WRAPS a modem
this returns the side so it can be used with rednet :P/>
756 posts
Posted 11 April 2016 - 05:21 AM
peripheral.find("modem", function(side) rednet.open(side) end) would achieve the same thing.
7083 posts
Location
Tasmania (AU)
Posted 11 April 2016 - 11:07 AM
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().
1847 posts
Location
/home/dannysmc95
Posted 28 May 2016 - 11:24 PM
I swear this is the code I gave you on slack… -__-