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

Problem finding Modems

Started by lebuildman, 20 September 2014 - 12:03 AM
lebuildman #1
Posted 20 September 2014 - 02:03 AM
Hello. I'm making a App Suite called "Todt Networks". It Works around Rednet, Rednet Programs created by me, and Some rewritten apps (Actually I'm Rewriting NitroFingers' Mail Client)

The AppSuite have na API, called tn. My problem if This Particular Function:
function findModem()
local sides = {"left", "right", "front", "back", "top", "bottom"}
local i = 0
repeat
  local i = i + 1
  local type = peripheral.getType(sides[i])
  if i == 6 then
   local modem = nil
  end
  if type == "modem" then
   local modem = sides[i]
   local i = 6
  end
until i == 6
return modem
end
I need a Better way to find a Advanced Modem. I use CCLite, and when I try to find the Virtual Peripheral it Crashes. I know that ComputerCraft have a Better Way to Find Modems, but I don't remember the code. I need Help! I don't want to make (Maybe I'll need to put) a First-Run Start to Setup Where's the Modem…
KingofGamesYami #2
Posted 20 September 2014 - 02:13 AM
Are you looking for something like this? Or do you want to use peripheral.find (added in 1.6+)?

local function findModem()
for k, v in ipairs( peripheral.getNames() ) do
  if peripheral.getType( v ) == "modem" and peripheral.call( v, "isWireless" ) then
   return v
  end
end
lebuildman #3
Posted 20 September 2014 - 02:20 AM
I think that is exactly what I need… Tested, Worked Exactly as I needed. Thx!