rednet.lookup
From ComputerCraft Wiki
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 |