function getmodems(mode) mode = mode or "default" if mode == "default" then allp = peripheral.getNames() d = {} x = 0 for i,value in ipairs(allp) do c = peripheral.getType(value) if c == "modem" then c = peripheral.wrap(value) x = x + 1 d[x] = c end end d["a"] = x d["amount"] = x return d elseif mode == "sides" or mode =="s" then allp = peripheral.getNames() d = {} x = 0 for i,value in ipairs(allp) do c = peripheral.getType(value) if c == "modem" then x = x + 1 d[x] = value end end d["a"] = x d["amount"] = x return d end end function getmsg() while true do d = {} event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message") d["e"] = event d["s"] = side d["f"] = frequency d["rf"] = evreplyFrequencyent d["m"] = message d["d"] = distance return d end end function transmitall(p,rp,message) modems = getmodems() print(modems["a"]) if modems["a"] == 0 then else for modem = 1,modems["a"] do cm = modems[modem] cm.transmit(p,rp,message) end end end function relay(p,rp,message,exclude) sides = getmodems("s") if modems["a"] == 0 then else for side = 1,modems["a"] do cs = sides[side] if cs == exclude then else cm.transmit(p,rp,message) end end end end modems = getmodems() modem[1].open(313) msg = getmsg() print(msg["distance"])