ReIative

Blunet

May 1st, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.        blunet
  3.  a new api for rednet
  4. --]]
  5. shell.run("pastebin", "get", "QWBSrHDd", "relenc")
  6. os.loadAPI("relenc")
  7. blunet = blunet or {}
  8. blunet.open = function(side)
  9.   rednet.open(side)
  10. end
  11. blunet.openAll = function()
  12.   for n,m in ipairs(rs.getSides()) do
  13.     if peripheral.getType(m) == "modem" then
  14.       blunet.open(m)
  15.     end
  16.   end
  17. end
  18.  
  19. blunet.isOpen = function()
  20.   for n,m in ipairs(rs.getSides()) do
  21.     if rednet.isOpen(m) then
  22.       return true
  23.     end
  24.   end
  25.   return false
  26. end
  27. blunet.broadcast = function(msg)
  28.   if blunet.isOpen() == false then error("No modem open") end
  29.   rednet.broadcast(relenc.encode(msg))
  30. end
Add Comment
Please, Sign In to add comment