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

Modem Ranges

Started by MrabEzreb, 28 December 2013 - 08:30 AM
MrabEzreb #1
Posted 28 December 2013 - 09:30 AM
I know about the basic range of wireless modems, but what about up and down? Could a max-alt computer still communicate with one on the ground in a thunderstorm and vice-versa?
Lyqyd #2
Posted 28 December 2013 - 03:53 PM
Moved to Ask a Pro.

If either computer is in range of the other, both can communicate.
MrabEzreb #3
Posted 30 December 2013 - 01:09 PM
okay, so if I have a pc at max alt. and a pc at ground level, they can talk if the top pc can reach the lower pc?
Lyqyd #4
Posted 30 December 2013 - 01:21 PM
That is what I said, yes.
MrabEzreb #5
Posted 04 January 2014 - 02:08 PM
okay, that's great. Another question related to modems (why start another thread?), is there a function that will return the open channels of a modem? That would be helpful.
Lyqyd #6
Posted 04 January 2014 - 02:17 PM
The isOpen peripheral method on a modem can be used to check if a specific channel is open. Other than that, you'd have to keep track of openings and closings yourself.
MrabEzreb #7
Posted 04 January 2014 - 02:46 PM
so you are saying:

function getChannels(side, startChan, endChan)
   openChannels = {}
   if startChan == nil and endChan == nil then
	  startChan = 1
	  endChan = 128
   elseif startChan ~= nil and endChan == nil then
	  endChan = startChan-127
   elseif endChan-startChan > 127 then
	  error("Not possible to have more than 128 channels open at once", 2)
   end
   elseif side == nil then
	  (find peripherals and check if they are modems)
   elseif type(side) == "string" then
	  modem = peripheral.wrap(side)
   elseif type(side) == "table" then
	  modem = side
   end
   for i = startChan, endChan do
	  chanOpen = modem.isOpen(i)
	  if chanOpen ~= nil then
		 openChannelCurNumber = #openChannels
		 openChannelSetNumber = openChannelCurNumber+1
		 openChannels[openChannelSetNumber] = i
		 chanOpen = nil
	  end
   end
end
I think this may solve my problem, but I am going to make sure…

EDIT:
is this how I would make it be like "modem1.getChannels(startChan, endChan)"?

function modem.getChannels(side, startChan, endChan)
side.isOpen()
or would I have to do this:

function modem.getChannels(self, startChan, endChan)
modem.isOpen()
or this:

function modem.getChannels(self, startChan, endChan)
self.isOpen()
or is it some other way?
Edited on 04 January 2014 - 01:57 PM