trainworld_computercraft/computer/5/customlookup.lua
2025-05-26 02:36:15 +02:00

35 lines
998 B
Lua

results = {}
rednet.broadcast({
sType = "lookup",
sProtocol = "tomfoolery",
sHostname = "pocket"
})
local timer = os.startTimer(1)
while true do
local event,p1,p2,p3 = os.pullEvent()
if event == "rednet_message" then
local sender, message, message_protocol = p1,p2,p3
print(sender, message, message_protocol)
if
message_protocol == "dns" and
type(message) == "table" and
message.sType == "lookup response"
then
if message.sProtocol == "tomfoolery" then
if hostname == nil then
print(sender)
table.insert(results,{sender,message.sHostname})
elseif message.sHostname == hostname then
os.cancelTimer(timer)
print(sender)
return sender
end
end
end
elseif event == "timer" and p1 == timer then
break
end
end
return results