Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pos = {5275, 69, 2162}
- local operatingChannel = 26743
- local messageList = {}
- local modem = nil
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType(v) == "modem" then
- modem = peripheral.wrap(v)
- break
- end
- end
- if not modem then
- print("No modem found!")
- return
- end
- modem.open(operatingChannel)
- modem.open(rednet.CHANNEL_REPEAT)
- modem.open(gps.CHANNEL_GPS)
- local getDistance = function(id)
- for k,v in pairs(messageList) do
- if v.id == id then
- return v.dist
- end
- end
- return false
- end
- print("Running Rednet Spam Locator Node")
- print("At position: "..pos[1]..", "..pos[2]..", "..pos[3])
- while true do
- local event, side, channel, reply, message, dist = os.pullEvent()
- if event == "modem_message" and channel == rednet.CHANNEL_REPEAT and type(message) == "table" then
- if message.nMessageID and message.nRecipient and not getDistance(message.nMessageID) then
- table.insert(messageList, {dist = dist, id = message.nMessageID})
- if #messageList > 200 then
- table.remove(messageList, 1)
- end
- end
- elseif event == "modem_message" and type(message) == "table" and message.ddosMonitor then
- if message.ddosMonitor == "request" and message.messageID then
- local dist = getDistance(message.messageID)
- if dist then
- modem.transmit(operatingChannel, operatingChannel, {x = pos[1], y = pos[2], z = pos[3], dist = dist,
- id = message.messageID, ddosMonitor = "response"})
- end
- end
- elseif event == "modem_message" and channel == gps.CHANNEL_GPS and message == "PING" then
- modem.transmit(reply, gps.CHANNEL_GPS, {pos[1], pos[2], pos[3]})
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement