Jump to content




How to only send a rednet message on a certain modem


  • You cannot reply to this topic
4 replies to this topic

#1 houseofkraft

  • Members
  • 170 posts
  • LocationUSA

Posted 27 September 2016 - 11:26 PM

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!

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 27 September 2016 - 11:34 PM

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.

#3 houseofkraft

  • Members
  • 170 posts
  • LocationUSA

Posted 27 September 2016 - 11:48 PM

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 by houseofkraft, 27 September 2016 - 11:49 PM.


#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 27 September 2016 - 11:52 PM

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)


#5 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 28 September 2016 - 02:52 PM

You can also use the native modem API, but rednet already handles the IDs.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users