Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local portsPath = "ports.cfg"
- local portsFile = fs.open(portsPath, "r")
- local portsCount = 0
- local modem1 = peripheral.wrap("left")
- local modem2 = peripheral.wrap("right")
- local openingPorts = true
- while openingPorts do
- local port = portsFile.readLine()
- if (port == nil) or (portsCount > 128) then
- openingPorts = false
- elseif tonumber(port) ~= nil then
- print("opening port: "..port)
- modem1.open(tonumber(port))
- modem2.open(tonumber(port))
- portsCount = portsCount + 1
- end
- end
- portsFile.close()
- while true do
- local event, side, channel, reply, message, distance = os.pullEvent()
- if event == "modem_message" then
- print(side.." "..channel.." "..reply.." "..message.." "..distance)
- local sendSide
- if side == "left" then
- modem2.transmit(channel, reply, message)
- else
- modem1.transmit(channel, reply, message)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment