Advertisement
BigSHinyToys

CC network test sender

Apr 28th, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. --[[
  2.         Network packet protection
  3.         by BigSHinyToys
  4. ]]--
  5.  
  6. local function findDevice(sType)
  7.     for _,sSide in pairs(rs.getSides()) do
  8.         if peripheral.isPresent(sSide) and peripheral.getType(sSide) == sType then
  9.             return sSide,peripheral.wrap(sSide)
  10.         end
  11.     end
  12. end
  13.  
  14. local function dec2hex(nInput)
  15.     return string.format("%X",tonumber(nInput))
  16. end
  17.  
  18. local function hex2dec(sInput)
  19.     return tonumber(sInput,10)
  20. end
  21.  
  22. local sOut = {}
  23.  
  24. for a = 0,15 do
  25.     term.setCursorPos(1,a + 1)
  26.     term.write(dec2hex(a).." ")
  27.     for b = 0,15 do
  28.         local char = string.char((a*16) + b)
  29.         term.setBackgroundColor(colors.white)
  30.         term.setTextColor(colors.lime)
  31.         term.write(char)
  32.         term.setBackgroundColor(colors.black)
  33.         term.setTextColor(colors.lightBlue)
  34.         term.write(dec2hex(a)..dec2hex(b))
  35.         table.insert(sOut,char)
  36.     end
  37.     -- table.insert(sOut,"/n")
  38. end
  39. --[[
  40. local file = fs.open("data","w")
  41. file.write(table.concat(sOut))
  42. file.close()
  43. ]]--
  44. term.setBackgroundColor(colors.black)
  45. term.setTextColor(colors.white)
  46.  
  47. local sSide,modem = findDevice("modem")
  48. modem.open(255)
  49. modem.transmit(255,255,table.concat(sOut))
  50.  
  51. os.pullEvent()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement