Difference between revisions of "Rednet.lookup"
From ComputerCraft Wiki
Bomb Bloke (Talk | contribs) (Created page with "{{lowercase}} {{Function |name=rednet.lookup |args={{type|string}} protocol, [<nowiki></nowiki>{{type|string}} hostname] |returns={{type|number}} ID1, {{type|number}} ID2, ......") |
Bomb Bloke (Talk | contribs) m (Navigation template) |
||
Line 6: | Line 6: | ||
|api=rednet | |api=rednet | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc=Introduced by ComputerCraft 1.6, searches the local rednet network for systems "hosting" the desired protocol and returns any computer IDs that respond as "registered" against it. If a hostname is specified, only one ID will be returned (assuming an exact match is found).<br><br> | + | |desc=Introduced by ComputerCraft 1.6, searches the local rednet network for systems "hosting" the desired [[Rednet (API)#Protocols|protocol]] and returns any computer IDs that respond as "registered" against it. If a hostname is specified, only one ID will be returned (assuming an exact match is found).<br><br> |
+ | |||
+ | Lookups are [[rednet.broadcast|broadcasted]] with a specified protocol of "dns". Replies are sent back to the sender's [[os.getComputerID|ID]] number with the same protocol.<br><br> | ||
See also: [[rednet.host|rednet.host()]], [[rednet.unhost|rednet.unhost()]] | See also: [[rednet.host|rednet.host()]], [[rednet.unhost|rednet.unhost()]] | ||
Line 33: | Line 35: | ||
}} | }} | ||
}} | }} | ||
+ | |||
+ | {{RednetAPIFunctions}} | ||
[[Category:API_Functions]] | [[Category:API_Functions]] |
Latest revision as of 06:33, 6 June 2014
Function rednet.lookup | |
Introduced by ComputerCraft 1.6, searches the local rednet network for systems "hosting" the desired protocol and returns any computer IDs that respond as "registered" against it. If a hostname is specified, only one ID will be returned (assuming an exact match is found). Lookups are broadcasted with a specified protocol of "dns". Replies are sent back to the sender's ID number with the same protocol. | |
Syntax | rednet.lookup(string protocol, [string hostname]) |
Returns | number ID1, number ID2, ... |
Part of | ComputerCraft |
API | rednet |
Examples
Example | |
Attempts to determine the ID of a remote system that has registered itself as using the protocol "futonFolderComs" under the hostname "futonFolderServer". | |
Code |
rednet.open("top") local futonServerID = rednet.lookup("futonFolderComs","futonFolderServer") if futonServerID then print("Found the server on channel "..futonServerID.."!") else print("Failed to locate the futon server.") end |
Example | |
Attempts to determine the IDs of all remote systems that have registered themselves as using the protocol "futonFolderComs". | |
Code |
rednet.open("top") local futonServerID = {rednet.lookup("futonFolderComs")} for i=1,#futonServerID do print("Found a server on channel "..futonServerID[i].."!") end |
Rednet API Functions |
---|
rednet.open - rednet.close - rednet.send - rednet.broadcast - rednet.receive - rednet.isOpen - rednet.host - rednet.unhost - rednet.lookup |