This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
houseofkraft's profile picture

How to only send a rednet message on a certain modem

Started by houseofkraft, 27 September 2016 - 10:26 PM
houseofkraft #1
Posted 28 September 2016 - 12:26 AM
Hi Guys!

I am currently programming a router program for ComputerCraft and i have a wired modem and a wireless modem. How do i only receive messages with the wireless modem and send the received message across the wired modem network.

Thanks!
Bomb Bloke #2
Posted 28 September 2016 - 12:34 AM
When you call rednet.send() or rednet.receive(), all open modems are used. So it's simply a case of rednet.open()ing the wired modem and rednet.close()ing the wireless before sending, and vice versa before receiving.
houseofkraft #3
Posted 28 September 2016 - 12:48 AM
Well if i close off the wired modem and only keep the wireless modem on then how will i be able to upload data because only the download portion will be active if i do that

Is there a way i can make a custom rednet API or something to only use the selected modem side or something
Edited on 27 September 2016 - 10:49 PM
Bomb Bloke #4
Posted 28 September 2016 - 12:52 AM
As mentioned, invert the modem states.

rednet.open("yourWirelessModem")
rednet.close("yourWiredModem")
local sender, message, protocal = rednet.receive()

rednet.open("yourWiredModem")
rednet.close("yourWirelessModem")
rednet.send(target, message)
Sewbacca #5
Posted 28 September 2016 - 03:52 PM
You can also use the native modem API, but rednet already handles the IDs.