Saereth

GateDDOS

Jan 12th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- locals
  2. local logs = {}
  3. local openTime = 30
  4. local textSize = 1
  5. local minimumNameLength = 4
  6. local buttonPadding = 1 --Min 1, Space before/after
  7. local centerPadding = 0 --Min 0, Space before/after
  8.  
  9. local buttonColor = colors.lightGray
  10. local buttonActiveColor = colors.orange
  11. local pageBack = "Prev Page"
  12. local pageFore = "Next Page"
  13. local resetButton = "Refresh"
  14. -- Hub Portals
  15.  
  16. --internal
  17. local monitor, touch
  18. local gate
  19. local monitorLocation
  20. local monX = 0
  21. local monY = 0
  22. local monMidL = 0
  23. local monMidR = 0
  24. local maxNameLength = 0
  25. local problem = false
  26. local names = {}
  27. local curPage = 1
  28. local lastPage = 1
  29. local namesPerPage = 1
  30. local pages = {}
  31. local gateType = 'Abstract Bus Adapter'
  32.  
  33.  
  34. function writeLog(text)
  35.   print(text)
  36. end
  37.  
  38.   if not fs.exists('apis/json') then
  39.     writeLog("You don't have the JSON API. Grabboring it.")
  40.     shell.run("pastebin get 4nRg9CHU apis/json")
  41.   end
  42.   os.loadAPI('apis/json')
  43.  
  44.   monitorLocation = findSideFor('monitor')
  45.   monitor = peripheral.wrap(monitorLocation)
  46.   gate    = peripheral.find(gateType)
  47.  
  48. end
  49.  
  50.  
  51.  
  52. function dialGate(address)
  53.   writeLog('----')
  54.   writeLog("Dialing "..address)  
  55.   result = gate.sendPacket("FFFF", "action: dial", "timeout: "..openTime, "address: "..address)
  56.   writeLog("Gate told to dial. Result: "..result)
  57.   return result
  58. end
  59.  
  60. function closeGate()
  61.   writeLog("Force closing the gate.")
  62.   result = gate.sendPacket("FFFF", "action: disconnect")
  63.   writeLog("Gate told to close. Result: "..result)
  64. end
  65.  
  66.  
  67. function findSideFor(typeToFind)
  68.   local sides = peripheral.getNames()
  69.   for i, side in ipairs(sides) do
  70.     local type = peripheral.getType(side)
  71.     if type == typeToFind then
  72.       return(side)
  73.     end
  74.   end
  75. end
  76.  
  77.  
  78. init()
  79.  
  80. if not problem then
  81.   refresh()
  82.   while true do
  83.   dialGate("Coronat Protaac Ormet")
  84. -- dialGate("Dehsetcro Migomcor Ormpra")
  85.     end
  86.   end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment