Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local WHEREIS_CHANNEL = 420
- local WHEREIS_REPLY_CHANNEL = 421
- local modem = peripheral.find("modem")
- print("Finding turtles...")
- modem.open(WHEREIS_CHANNEL)
- modem.open(WHEREIS_REPLY_CHANNEL)
- modem.transmit(WHEREIS_CHANNEL, WHEREIS_REPLY_CHANNEL, "WHEREIS")
- local found = {}
- parallel.waitForAny(function()
- while true do
- local event, side, channel, replyChannel, message = os.pullEvent("modem_message")
- if channel == WHEREIS_REPLY_CHANNEL then
- table.insert(found, message)
- print("Found '" .. message[2] .. "' (" .. message[1] .. ") at " .. tostring(message[3]) .. ", " .. tostring(message[4]) .. ", " .. tostring(message[5]))
- end
- end
- end, function()
- sleep(2.3)
- end)
- local h = fs.open("log", "w")
- h.write(textutils.serialise(found))
- h.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement