Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Functions
- function forwardloop()
- local event, modemSide, senderChannel,
- replyChannel, message, senderDistance = os.pullEvent("modem_message")
- print("I just received a message from: "..senderChannel)
- print("I should apparently reply on: "..replyChannel)
- print("The modem receiving this is located on the "..modemSide.." side")
- print("The message was: "..message)
- print("The sender is: "..senderDistance.." blocks away from me.")
- peripheral.call(side, "transmit", replyChannel, senderChannel, message)
- forwardloop()
- end
- print("--ComputerCraft Local Forwarder--")
- print("What do you want to do?")
- print("1. Send a message to Forwarder")
- print("2. Be a Forwarder")
- query = io.read()
- --Send to Forwarder
- if query == "1" then
- print("What side is the modem on?")
- side = io.read()
- print("What is the forwarder's channel?")
- forwardchan = io.read()
- print("What is the recipient's channel?")
- receivechan = io.read()
- print("Type the message you want to send:")
- message = io.read()
- forwardchan = tonumber(forwardchan)
- receivechan = tonumber(receivechan)
- print("Sending message on channel "..forwardchan)
- peripheral.call(side, "transmit", forwardchan, receivechan, message)
- print("Sending complete!")
- end
- --Forward Send/Receive
- if query == "2" then
- print("What side is the modem on?")
- side = io.read()
- print("What channel do you want to use for forwarding?")
- forwardchan = io.read()
- forwardchan = tonumber(forwardchan)
- print("Receiving and forwarding messages...")
- peripheral.call(side, "open", forwardchan)
- forwardloop()
- end
Advertisement
Add Comment
Please, Sign In to add comment