Maxstripe

OC-StargateDialer

Jun 5th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require("component")
  2. local sg = component.stargate
  3. local gpu = component.gpu
  4. local keyboard = require("keyboard")
  5. local w, h = gpu.getResolution()
  6. local term = require("term")
  7. local event = require("event")
  8. local filesystem = require("filesystem")
  9.  
  10. local running = true
  11. local iris = false
  12.  
  13. --address tables
  14. characters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
  15. numbers = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
  16.  
  17. --Drawing functions
  18. function drawA(offset)
  19.   gpu.fill(43+offset, 42, 6, 1, " ")
  20.   gpu.fill(43+offset, 42, 2, 5, " ")
  21.   gpu.fill(43+offset, 44, 6, 1, " ")
  22.   gpu.fill(47+offset, 42, 2, 5, " ")
  23. end
  24.  
  25. function drawC(offset)
  26.   gpu.fill(43+offset, 42, 6, 1, " ")
  27.   gpu.fill(43+offset, 42, 2, 5, " ")
  28.   gpu.fill(43+offset, 46, 6, 1, " ")
  29. end
  30.  
  31. function drawD(offset)
  32.   gpu.fill(43+offset, 42, 4, 1, " ")
  33.   gpu.fill(43+offset, 42, 2, 5, " ")
  34.   gpu.fill(43+offset, 46, 4, 1, " ")
  35.   gpu.fill(47+offset, 43, 2, 3, " ")
  36. end
  37.  
  38. function drawE(offset)
  39.   gpu.fill(43+offset, 42, 6, 1, " ")
  40.   gpu.fill(43+offset, 42, 2, 5, " ")
  41.   gpu.fill(43+offset, 44, 4, 1, " ")
  42.   gpu.fill(43+offset, 46, 6, 1, " ")
  43. end
  44.  
  45. function drawF(offset)
  46.   gpu.fill(43+offset, 42, 6, 1, " ")
  47.   gpu.fill(43+offset, 42, 2, 5, " ")
  48.   gpu.fill(43+offset, 44, 4, 1, " ")
  49. end
  50.  
  51. function drawG(offset)
  52.   gpu.fill(43+offset, 42, 6, 1, " ")
  53.   gpu.fill(43+offset, 42, 2, 5, " ")
  54.   gpu.fill(43+offset, 46, 6, 1, " ")
  55.   gpu.fill(47+offset, 42, 2, 2, " ")
  56.   gpu.fill(46+offset, 45, 3, 2, " ")
  57. end
  58.  
  59. function drawI(offset)
  60.   gpu.fill(43+offset, 42, 6, 1, " ")
  61.   gpu.fill(45+offset, 42, 2, 5, " ")
  62.   gpu.fill(43+offset, 46, 6, 1, " ")
  63. end
  64.  
  65. function drawL(offset)
  66.   gpu.fill(43+offset, 42, 2, 5, " ")
  67.   gpu.fill(43+offset, 46, 6, 1, " ")
  68. end
  69.  
  70. function drawM(offset)
  71.   gpu.fill(43+offset, 42, 2, 1, " ")
  72.   gpu.fill(43+offset, 42, 1, 5, " ")
  73.   gpu.fill(47+offset, 42, 2, 1, " ")
  74.   gpu.fill(48+offset, 42, 1, 5, " ")
  75.   gpu.fill(45+offset, 43, 2, 1, " ")
  76. end
  77.  
  78. function drawN(offset)
  79.   gpu.fill(43+offset, 42, 2, 5, " ")
  80.   gpu.fill(47+offset, 42, 2, 5, " ")
  81.   gpu.fill(45+offset, 43, 1, 1, " ")
  82.   gpu.fill(45+offset, 44, 2, 1, " ")
  83.   gpu.fill(46+offset, 45, 1, 1, " ")
  84. end
  85.  
  86. function drawO(offset)
  87.   gpu.fill(43+offset, 42, 6, 1, " ")
  88.   gpu.fill(43+offset, 42, 2, 5, " ")
  89.   gpu.fill(43+offset, 46, 6, 1, " ")
  90.   gpu.fill(47+offset, 42, 2, 5, " ")
  91. end
  92.  
  93. function drawP(offset)
  94.   gpu.fill(43+offset, 42, 6, 1, " ")
  95.   gpu.fill(43+offset, 42, 2, 5, " ")
  96.   gpu.fill(43+offset, 44, 6, 1, " ")
  97.   gpu.fill(47+offset, 42, 2, 3, " ")
  98. end
  99.  
  100. function drawS(offset)
  101.   gpu.fill(43+offset, 42, 6, 1, " ")
  102.   gpu.fill(43+offset, 42, 2, 3, " ")
  103.   gpu.fill(43+offset, 44, 6, 1, " ")
  104.   gpu.fill(47+offset, 44, 2, 3, " ")
  105.   gpu.fill(43+offset, 46, 6, 1, " ")
  106. end
  107.  
  108. function drawT(offset)
  109.   gpu.fill(43+offset, 42, 6, 1, " ")
  110.   gpu.fill(45+offset, 42, 2, 5, " ")
  111. end
  112.  
  113. function drawGate()
  114. --outer ring
  115.   gpu.setBackground(0x65D1D4)
  116.   gpu.fill(74, 8, 14, 1, " ")
  117.   gpu.fill(88, 9, 6, 1, " ")
  118.   gpu.fill(94, 10, 4, 1, " ")
  119.   gpu.fill(98, 11, 2, 1, " ")
  120.   gpu.fill(100, 12, 2, 1, " ")
  121.   gpu.fill(102, 13, 2, 1, " ")
  122.   gpu.fill(104, 14, 2, 1, " ")
  123.   gpu.fill(106, 15, 2, 2, " ")
  124.   gpu.fill(108, 17, 2, 3, " ")
  125.  
  126.   gpu.fill(110, 20, 2, 7, " ")
  127.   gpu.fill(108, 27, 2, 3, " ")
  128.   gpu.fill(106, 30, 2, 2, " ")
  129.   gpu.fill(104, 32, 2, 1, " ")
  130.   gpu.fill(102, 33, 2, 1, " ")
  131.   gpu.fill(100, 34, 2, 1, " ")
  132.   gpu.fill(98, 35, 2, 1, " ")
  133.   gpu.fill(94, 36, 4, 1, " ")
  134.   gpu.fill(88, 37, 6, 1, " ")
  135.  
  136.   gpu.fill(74, 38, 14, 1, " ")
  137.   gpu.fill(68, 37, 6, 1, " ")
  138.   gpu.fill(64, 36, 4, 1, " ")
  139.   gpu.fill(62, 35, 2, 1, " ")
  140.   gpu.fill(60, 34, 2, 1, " ")
  141.   gpu.fill(58, 33, 2, 1, " ")
  142.   gpu.fill(56, 32, 2, 1, " ")
  143.   gpu.fill(54, 30, 2, 2, " ")
  144.   gpu.fill(52, 27, 2, 3, " ")
  145.  
  146.   gpu.fill(50, 20, 2, 7, " ")
  147.   gpu.fill(52, 17, 2, 3, " ")
  148.   gpu.fill(54, 15, 2, 2, " ")
  149.   gpu.fill(56, 14, 2, 1, " ")
  150.   gpu.fill(58, 13, 2, 1, " ")
  151.   gpu.fill(60, 12, 2, 1, " ")
  152.   gpu.fill(62, 11, 2, 1, " ")
  153.   gpu.fill(64, 10, 4, 1, " ")
  154.   gpu.fill(68, 9, 6, 1, " ")
  155.  
  156.   --inner ring
  157.   gpu.fill(74, 11, 14, 1, " ")
  158.   gpu.fill(88, 12, 4, 1, " ")
  159.   gpu.fill(92, 13, 4, 1, " ")
  160.   gpu.fill(96, 14, 2, 1, " ")
  161.   gpu.fill(98, 15, 2, 1, " ")
  162.   gpu.fill(100, 16, 2, 2, " ")
  163.   gpu.fill(102, 18, 2, 2, " ")
  164.  
  165.   gpu.fill(104, 20, 2, 7, " ")
  166.   gpu.fill(102, 27, 2, 2, " ")
  167.   gpu.fill(100, 29, 2, 2, " ")
  168.   gpu.fill(98, 31, 2, 1, " ")
  169.   gpu.fill(96, 32, 2, 1, " ")
  170.   gpu.fill(92, 33, 4, 1, " ")
  171.   gpu.fill(88, 34, 4, 1, " ")
  172.  
  173.   gpu.fill(74, 35, 14, 1, " ")
  174.   gpu.fill(70, 34, 4, 1, " ")
  175.   gpu.fill(66, 33, 4, 1, " ")
  176.   gpu.fill(64, 32, 2, 1, " ")
  177.   gpu.fill(62, 31, 2, 1, " ")
  178.   gpu.fill(60, 29, 2, 2, " ")
  179.   gpu.fill(58, 27, 2, 2, " ")
  180.  
  181.   gpu.fill(56, 20, 2, 7, " ")
  182.   gpu.fill(58, 18, 2, 2, " ")
  183.   gpu.fill(60, 16, 2, 2, " ")
  184.   gpu.fill(62, 15, 2, 1, " ")
  185.   gpu.fill(64, 14, 2, 1, " ")
  186.   gpu.fill(66, 13, 4, 1, " ")
  187.   gpu.fill(70, 12, 4, 1, " ")
  188.  
  189.   --middle ring
  190.   gpu.setBackground(0x569D95)
  191.   --gpu.fill(80, 9, 2, 2, " ")
  192.   gpu.fill(84, 9, 2, 2, " ")
  193.   gpu.fill(88, 10, 2, 2, " ")
  194.   gpu.fill(92, 11, 2, 2, " ")
  195.   gpu.fill(96, 12, 2, 1, " ")
  196.   --gpu.fill(100, 13, 2, 1, " ")
  197.   gpu.fill(98, 14, 2, 1, " ")
  198.   gpu.fill(102, 15, 2, 1, " ")
  199.   gpu.fill(102, 17, 4, 1, " ")
  200.   gpu.fill(104, 19, 4, 1, " ")
  201.   gpu.fill(106, 21, 4, 1, " ")
  202.  
  203.   --gpu.fill(106, 23, 4, 1, " ")
  204.   gpu.fill(106, 25, 4, 1, " ")
  205.   gpu.fill(104, 27, 4, 1, " ")
  206.   gpu.fill(102, 29, 4, 1, " ")
  207.   gpu.fill(102, 31, 2, 1, " ")
  208.   gpu.fill(98, 32, 2, 1, " ")
  209.   gpu.fill(100, 33, 2, 1, " ")
  210.   gpu.fill(96, 34, 2, 1, " ")
  211.   gpu.fill(92, 34, 2, 2, " ")
  212.   gpu.fill(88, 35, 2, 2, " ")
  213.   gpu.fill(84, 36, 2, 2, " ")
  214.  
  215.   gpu.fill(80, 36, 2, 2, " ")
  216.   gpu.fill(76, 36, 2, 2, " ")
  217.   gpu.fill(72, 35, 2, 2, " ")
  218.   gpu.fill(68, 34, 2, 2, " ")
  219.   gpu.fill(64, 34, 2, 1, " ")
  220.   gpu.fill(62, 32, 2, 1, " ")
  221.   gpu.fill(60, 33, 2, 1, " ")
  222.   gpu.fill(58, 31, 2, 1, " ")
  223.   gpu.fill(56, 29, 4, 1, " ")
  224.   gpu.fill(54, 27, 4, 1, " ")
  225.   gpu.fill(52, 25, 4, 1, " ")
  226.  
  227.   --gpu.fill(52, 23, 4, 1, " ")
  228.   gpu.fill(52, 21, 4, 1, " ")
  229.   gpu.fill(54, 19, 4, 1, " ")
  230.   gpu.fill(56, 17, 4, 1, " ")
  231.   gpu.fill(58, 15, 2, 1, " ")
  232.   --gpu.fill(60, 13, 2, 1, " ")
  233.   gpu.fill(62, 14, 2, 1, " ")
  234.   gpu.fill(64, 12, 2, 1, " ")
  235.   gpu.fill(68, 11, 2, 2, " ")
  236.   gpu.fill(72, 10, 2, 2, " ")
  237.   gpu.fill(76, 9, 2, 2, " ")
  238.  
  239.   --chevrons
  240.   gpu.setBackground(0x860007)
  241.  
  242.   gpu.fill(78, 8, 6, 1, " ")
  243.   gpu.fill(79, 9, 1, 1, " ")
  244.   gpu.fill(82, 9, 1, 1, " ")
  245.   gpu.fill(80, 10, 2, 1, " ")
  246.  
  247.   gpu.fill(100, 12, 2, 1, " ")
  248.   gpu.fill(102, 13, 2, 1, " ")
  249.   gpu.fill(98, 13, 2, 2, " ")
  250.   gpu.fill(100, 14, 2, 1, " ")
  251.  
  252.   gpu.fill(106, 23, 2, 1, " ")
  253.   gpu.fill(108, 22, 2, 1, " ")
  254.   gpu.fill(108, 24, 2, 1, " ")
  255.   gpu.fill(110, 22, 2, 3, " ")
  256.  
  257.   gpu.fill(102, 30, 4, 1, " ")
  258.   gpu.fill(102, 31, 2, 1, " ")
  259.   gpu.fill(106, 31, 2, 1, " ")
  260.   gpu.fill(104, 32, 2, 1, " ")
  261.  
  262.   gpu.fill(90, 35, 2, 1, " ")
  263.   gpu.fill(89, 36, 1, 1, " ")
  264.   gpu.fill(92, 36, 1, 1, " ")
  265.   gpu.fill(88, 37, 6, 1, " ")
  266.  
  267.   gpu.fill(70, 35, 2, 1, " ")
  268.   gpu.fill(69, 36, 1, 1, " ")
  269.   gpu.fill(72, 36, 1, 1, " ")
  270.   gpu.fill(68, 37, 6, 1, " ")
  271.  
  272.   gpu.fill(56, 30, 4, 1, " ")
  273.   gpu.fill(54, 31, 2, 1, " ")
  274.   gpu.fill(58, 31, 2, 1, " ")
  275.   gpu.fill(56, 32, 2, 1, " ")
  276.  
  277.   gpu.fill(50, 22, 4, 1, " ")
  278.   gpu.fill(50, 23, 2, 1, " ")
  279.   gpu.fill(54, 23, 2, 1, " ")
  280.   gpu.fill(50, 24, 4, 1, " ")
  281.  
  282.   gpu.fill(60, 12, 2, 1, " ")
  283.   gpu.fill(58, 13, 2, 1, " ")
  284.   gpu.fill(62, 13, 2, 1, " ")
  285.   gpu.fill(60, 14, 4, 1, " ")
  286. end
  287.  
  288. local color
  289. function drawWormhole(color)
  290.   gpu.setBackground(color)
  291.   gpu.fill(74, 12, 14, 1, " ")
  292.   gpu.fill(70, 13, 22, 1, " ")
  293.   gpu.fill(66, 14, 30, 1, " ")
  294.   gpu.fill(64, 15, 34, 1, " ")
  295.   gpu.fill(62, 16, 38, 2, " ")
  296.   gpu.fill(60, 18, 42, 2, " ")
  297.   gpu.fill(58, 20, 46, 7, " ")
  298.   gpu.fill(60, 27, 42, 2, " ")
  299.   gpu.fill(62, 29, 38, 2, " ")
  300.   gpu.fill(64, 31, 34, 1, " ")
  301.   gpu.fill(66, 32, 30, 1, " ")
  302.   gpu.fill(70, 33, 22, 1, " ")
  303.   gpu.fill(74, 34, 14, 1, " ")
  304.  
  305.   if color == 0x000000 then
  306.     gpu.setBackground(0x353535)
  307.     gpu.fill(80, 22, 2, 3, " ")
  308.     gpu.fill(78, 23, 6, 1, " ")
  309.   end
  310. end
  311.  
  312. function drawIris()
  313.   drawWormhole(0x2B586B)
  314.   gpu.setBackground(0x75BEC7)
  315.   gpu.fill(80, 12, 2, 23, " ")
  316.   gpu.fill(58, 23, 46, 1, " ")
  317.  
  318.   gpu.fill(82, 21, 2, 1, " ")
  319.   gpu.fill(84, 20, 2, 1, " ")
  320.   gpu.fill(86, 18, 2, 2, " ")
  321.   gpu.fill(88, 16, 2, 2, " ")
  322.   gpu.fill(90, 14, 2, 2, " ")
  323.  
  324.   gpu.fill(84, 22, 2, 1, " ")
  325.   gpu.fill(86, 21, 2, 1, " ")
  326.   gpu.fill(88, 20, 4, 1, " ")
  327.   gpu.fill(92, 19, 4, 1, " ")
  328.   gpu.fill(96, 18, 4, 1, " ")
  329.  
  330.   gpu.fill(84, 24, 2, 1, " ")
  331.   gpu.fill(86, 25, 2, 1, " ")
  332.   gpu.fill(88, 26, 4, 1, " ")
  333.   gpu.fill(92, 27, 4, 1, " ")
  334.   gpu.fill(96, 28, 4, 1, " ")
  335.  
  336.   gpu.fill(82, 25, 2, 1, " ")
  337.   gpu.fill(84, 26, 2, 1, " ")
  338.   gpu.fill(86, 27, 2, 2, " ")
  339.   gpu.fill(88, 29, 2, 2, " ")
  340.   gpu.fill(90, 31, 2, 2, " ")
  341.  
  342.   gpu.fill(78, 25, 2, 1, " ")
  343.   gpu.fill(76, 26, 2, 1, " ")
  344.   gpu.fill(74, 27, 2, 2, " ")
  345.   gpu.fill(72, 29, 2, 2, " ")
  346.   gpu.fill(70, 31, 2, 2, " ")
  347.  
  348.   gpu.fill(76, 24, 2, 1, " ")
  349.   gpu.fill(74, 25, 2, 1, " ")
  350.   gpu.fill(70, 26, 4, 1, " ")
  351.   gpu.fill(66, 27, 4, 1, " ")
  352.   gpu.fill(62, 28, 4, 1, " ")
  353.  
  354.   gpu.fill(76, 22, 2, 1, " ")
  355.   gpu.fill(74, 21, 2, 1, " ")
  356.   gpu.fill(70, 20, 4, 1, " ")
  357.   gpu.fill(66, 19, 4, 1, " ")
  358.   gpu.fill(62, 18, 4, 1, " ")
  359.  
  360.   gpu.fill(78, 21, 2, 1, " ")
  361.   gpu.fill(76, 20, 2, 1, " ")
  362.   gpu.fill(74, 18, 2, 2, " ")
  363.   gpu.fill(72, 16, 2, 2, " ")
  364.   gpu.fill(70, 14, 2, 2, " ")
  365. end
  366.  
  367. local colorControls
  368. function drawGateControls(colorControls)
  369.   --chevron lines
  370.   gpu.setBackground(colorControls)
  371.  
  372.   gpu.fill(102, 12, 18, 1, " ")
  373.   gpu.fill(119, 11, 1, 1, " ")
  374.   gpu.fill(119, 10, 17, 1, " ")
  375.  
  376.   gpu.fill(112, 23, 10, 1, " ")
  377.   gpu.fill(121, 17, 1, 6, " ")
  378.   gpu.fill(121, 16, 18, 1, " ")
  379.  
  380.   gpu.fill(106, 32, 17, 1, " ")
  381.   gpu.fill(123, 23, 1, 10, " ")
  382.   gpu.fill(123, 22, 19, 1, " ")
  383.  
  384.   gpu.fill(144, 46, 3, 1, " ")
  385.   gpu.fill(146, 6, 1, 40, " ")
  386.   gpu.fill(80, 6, 67, 1, " ")
  387.   gpu.fill(80, 6, 2, 2, " ")
  388.  
  389.   gpu.fill(144, 40, 5, 1, " ")
  390.   gpu.fill(148, 5, 1, 35, " ")
  391.   gpu.fill(54, 5, 95, 1, " ")
  392.   gpu.fill(54, 5, 1, 8, " ")
  393.   gpu.fill(54, 12, 6, 1, " ")
  394.  
  395.   gpu.fill(144, 34, 7, 1, " ")
  396.   gpu.fill(150, 4, 1, 30, " ")
  397.   gpu.fill(44, 23, 6, 1, " ")
  398.   gpu.fill(44, 4, 1, 20, " ")
  399.   gpu.fill(44, 4, 107, 1, " ")
  400.  
  401.   gpu.fill(144, 28, 9, 1, " ")
  402.   gpu.fill(152, 3, 1, 25, " ")
  403.   gpu.fill(40, 32, 16, 1, " ")
  404.   gpu.fill(40, 3, 1, 29, " ")
  405.   gpu.fill(40, 3, 112, 1, " ")
  406.  
  407.   --address windows
  408.   gpu.setBackground(colorControls)
  409.   gpu.setForeground(0xFFFFFF)
  410.   gpu.fill(130, 8, 14, 5, " ")
  411.   gpu.fill(130, 14, 14, 5, " ")
  412.   gpu.fill(130, 20, 14, 5, " ")
  413.   gpu.fill(130, 26, 14, 5, " ")
  414.   gpu.fill(130, 32, 14, 5, " ")
  415.   gpu.fill(130, 38, 14, 5, " ")
  416.   gpu.fill(130, 44, 14, 5, " ")
  417.  
  418.   gpu.setBackground(0x000000)
  419.   gpu.fill(131, 9, 12, 3, " ")
  420.   gpu.fill(131, 15, 12, 3, " ")
  421.   gpu.fill(131, 21, 12, 3, " ")
  422.   gpu.fill(131, 27, 12, 3, " ")
  423.   gpu.fill(131, 33, 12, 3, " ")
  424.   gpu.fill(131, 39, 12, 3, " ")
  425.   gpu.fill(131, 45, 12, 3, " ")
  426.  
  427.   gpu.set(129, 11, "1")
  428.   gpu.set(129, 17, "2")
  429.   gpu.set(129, 23, "3")
  430.   gpu.set(129, 29, "4")
  431.   gpu.set(129, 35, "5")
  432.   gpu.set(129, 41, "6")
  433.   gpu.set(129, 47, "7")
  434. end
  435.  
  436. function drawButtons()
  437.   --iris
  438.   gpu.setBackground(0x339D8F)
  439.   gpu.setForeground(0x444444)
  440.   gpu.fill(4, 3, 8, 3, " ")
  441.   gpu.fill(12, 3, 20, 3, " ")
  442.   gpu.setBackground(0x000000)
  443.   gpu.fill(5, 4, 6, 1, " ")
  444.   gpu.fill(13, 4, 18, 1, " ")
  445.   gpu.set(6, 4, "IRIS")
  446.  
  447.   --dialling
  448.   gpu.setBackground(0x339D8F)
  449.   gpu.fill(4, 7, 28, 5, " ")
  450.   gpu.setBackground(0x000000)
  451.   gpu.setForeground(0xFFFFFF)
  452.   gpu.fill(5, 8, 26, 1, " ")
  453.   gpu.fill(5, 10, 26, 1, " ")
  454.   gpu.set(11, 8, "DIAL DIRECTLY")
  455.   --terminating
  456.   gpu.setBackground(0xCC0000)
  457.   gpu.fill(4, 13, 28, 3, " ")
  458.   gpu.setBackground(0x000000)
  459.   gpu.setForeground(0x444444)
  460.   gpu.fill(5, 14, 26, 1, " ")
  461.   gpu.set(8, 14, "TERMINATE CONNECTION")
  462.   --energy
  463.   gpu.setBackground(0x339D8F)
  464.   gpu.fill(4, 17, 28, 9, " ")
  465.   gpu.setBackground(0x000000)
  466.   gpu.setForeground(0xFFFFFF)
  467.   gpu.fill(5, 18, 26, 1, " ")
  468.   gpu.fill(5, 20, 26, 1, " ")
  469.   gpu.fill(5, 22, 26, 3, " ")
  470.   gpu.set(8, 18, "ENERGY AVAILABLE:")
  471.   --address book
  472.   gpu.setBackground(0x339D8F)
  473.   gpu.fill(4, 27, 28, 3, " ")
  474.   gpu.setBackground(0x000000)
  475.   gpu.setForeground(0xFFFFFF)
  476.   gpu.fill(5, 28, 26, 1, " ")
  477.   gpu.set(11, 28, "ADDRESS BOOK")
  478.   --settings
  479.   gpu.setBackground(0x339D8F)
  480.   gpu.fill(4, 31, 28, 3, " ")
  481.   gpu.setBackground(0x000000)
  482.   gpu.setForeground(0x444444)
  483.   gpu.fill(5, 32, 26, 1, " ")
  484.   gpu.set(13, 32, "SETTINGS")
  485.   --msg window
  486.   gpu.setBackground(0x339D8F)
  487.   gpu.fill(4, 35, 28, 14, " ")
  488.   gpu.setBackground(0x000000)
  489.   gpu.fill(5, 36, 26, 12, " ")
  490. end
  491.  
  492. function drawBorders()
  493.   gpu.setBackground(0x339D8F)
  494.   gpu.fill(1, 1, w, 1, " ")
  495.   gpu.fill(1, 1, 1, h-2, " ")
  496.   gpu.fill(1, h, w, h, " ")
  497.   gpu.fill(w, 3, w-1, h, " ")
  498. end
  499.  
  500. function drawAddressBookBorders()
  501.   gpu.setBackground(0x339D8F)
  502.   gpu.fill(1, 1, w, 1, " ")
  503.   gpu.fill(1, 1, 1, h-2, " ")
  504.   gpu.fill(1, h, w, h, " ")
  505.   gpu.fill(w, 3, w-1, h, " ")
  506.  
  507.   gpu.setBackground(0xCC0000)
  508.   gpu.setForeground(0xFFFFFF)
  509.   gpu.fill(w-5, 1, 5, 1, " ")
  510.   gpu.set(w-3, 1, "X")
  511. end
  512.  
  513. function resetGUI()
  514.   gpu.setBackground(0x000000)
  515.   gpu.fill(1, 1, w, h, " ")
  516.   drawGate()
  517.   drawGateControls(0x569D95)
  518.   drawButtons()
  519.   drawBorders()
  520.  
  521.   --state window
  522.   gpu.setBackground(0x339D8F)
  523.   gpu.fill(40, 40, 80, 9, " ")
  524.   gpu.setBackground(0x000000)
  525.   gpu.fill(40, 42, 80, 5, " ")
  526.   gpu.fill(41, 41, 78, 1, " ")
  527.   gpu.fill(41, 47, 78, 1, " ")
  528. end
  529. --[[
  530. function textField(x, y, lenx, leny)
  531.    local typing = true
  532.    local type = true
  533.    local character
  534.    local text = ""
  535.    local index = 0
  536.    while typing and index<=(lenx-1) do
  537.       gpu.set(x+index+1, y, "_")
  538.     local _,_,key,p1 = event.pull("key_down")
  539.     local char = keyboard.keys[p1]
  540.       index = index + 1
  541.   if (index==lenx) or (key==13) then
  542.       gpu.set(x+index, y, " ")
  543.       type = false
  544.     typing = false
  545.       gpu.set(x+index+1, y, " ")
  546.       for i=1,index-1 do
  547.         character = gpu.get(x+i, y)
  548.         text = text..character
  549.       end
  550.     end
  551.     if (key == 8) and (index > 1) then --backspace
  552.       index = index - 1
  553.       --text = string.sub(text, 1, index+1)
  554.       gpu.set(x+index+1, y, " ")
  555.       gpu.set(x+index, y, "_")
  556.       index=index-1
  557.     elseif (index >= 1) and (key ~= 13) then
  558.       if char == "lshift" or char == "rshift" or char == "back" or char == "enter" then
  559.       index=index-1
  560.     else
  561.       if keyboard.isShiftDown() then
  562.           character = string.upper(char)
  563.         else
  564.       character = char
  565.     end
  566.     if char == "space" then
  567.       character = " "
  568.     elseif char == "numpad0" then
  569.         character = "0"
  570.       elseif char == "numpad1" then
  571.         character = "1"
  572.       elseif char == "numpad2" then
  573.         character = "2"
  574.       elseif char == "numpad3" then
  575.         character = "3"
  576.       elseif char == "numpad4" then
  577.         character = "4"
  578.       elseif char == "numpad5" then
  579.         character = "5"
  580.       elseif char == "numpad6" then
  581.         character = "6"
  582.       elseif char == "numpad7" then
  583.         character = "7"
  584.       elseif char == "numpad8" then
  585.         character = "8"
  586.       elseif char == "numpad9" then
  587.         character = "9"
  588.     elseif char == "numpadsub" or char == "minus" then
  589.         character = "-"
  590.     elseif char == "period" then
  591.         character = "."
  592.    
  593.     end
  594.     if type then
  595.           gpu.set(x+index, y, character)
  596.         end
  597.       end
  598.     end
  599.   end
  600.   return text
  601. end
  602. ]]
  603. function removeLines(filename, startingLine, numLines)
  604.     local fp = io.open(filename, "r")
  605.     if fp == nil then return nil end
  606.  
  607.     content = {}
  608.     i = 1;
  609.     for line in fp:lines() do
  610.       if i < startingLine or i >= startingLine + numLines then
  611.       content[#content+1] = line
  612.     end
  613.     i = i + 1
  614.     end
  615.  
  616.     if i > startingLine and i < startingLine + numLines then return nil end
  617.  
  618.     fp:close()
  619.     fp = io.open(filename, "w")
  620.  
  621.     for i = 1, #content do
  622.     fp:write(string.format("%s\n", content[i]))
  623.     end
  624.  
  625.     fp:close()
  626. end
  627.  
  628. function wrap(str, limit)
  629.   if (str == nil) or (str == " ") then return nil end
  630.   local Lines, here, limit = {}, 1, limit or 72
  631.   Lines[1] = string.sub(str,1,str:find("(%s+)()(%S+)()")-1)
  632.  
  633.   str:gsub("(%s+)()(%S+)()",
  634.         function(sp, st, word, fi)
  635.           if fi-here > limit then
  636.                 here = st
  637.                 Lines[#Lines+1] = word
  638.           else Lines[#Lines] = Lines[#Lines].." "..word end
  639.         end)
  640.  
  641.   return Lines
  642. end
  643.  
  644. function tablelength(T)
  645.   local count = 0
  646.   for _ in pairs(T) do count = count + 1 end
  647.   return count
  648. end
  649.  
  650. function addressBook(override)
  651.   gpu.fill(1, 1, w, h, " ")
  652.   drawAddressBookBorders()
  653.  
  654.   gpu.setForeground(0x339D8F)
  655.   gpu.setBackground(0x000000)
  656.   gpu.set(5, 3, "SYSTEM GLYPHS / FILE ARCHIVE / DISPLAY COMPLETE")
  657.   gpu.set(10, 7, "1")
  658.   gpu.set(10+1*15, 7, "2")
  659.   gpu.set(10+2*15, 7, "3")
  660.   gpu.set(10+3*15, 7, "4")
  661.   gpu.set(10+4*15, 7, "5")
  662.   gpu.set(10+5*15, 7, "6")
  663.   gpu.set(10+6*15, 7, "7")
  664.   gpu.set(10+7*15, 7, "PROFILE")
  665.   gpu.setBackground(0x339D8F)
  666.   gpu.fill(5, 4, w-7, 1, " ")
  667.   gpu.fill(10, 8, w-12, 1, " ")
  668.  
  669.   gpu.fill(64, h-4, 5, 3, " ")
  670.   gpu.fill(149, h-4, 5, 3, " ")
  671.   --gpu.fill(4, h-4, 13, 3, " ")
  672.   gpu.fill(70, h-2, 2, 1, " ")
  673.  
  674.   gpu.setForeground(0xFFFFFF)
  675.   gpu.setBackground(0x000000)
  676.   gpu.set(65, h-3, "<<<")
  677.   gpu.set(150, h-3, ">>>")
  678.   --gpu.set(114, h-3, "01  02  03  04  05  06  07  08  09")
  679.   gpu.set(70, h-3, "01  02  03  04  05  06  07  08  09  10  11  12  14  13  15  16  17  18  19  20")
  680.  
  681.    
  682.  
  683.   local currentPage = 1
  684.   local index = 0
  685.   local locations = {}
  686.   local addresses = {}
  687.   --local numLines = 0
  688.  
  689.   for location in string.gmatch(sg.getLocations(), '([^,]+)') do
  690.       table.insert(locations, location)
  691.   end
  692.  
  693.   local addressBookRunning = true
  694.   while addressBookRunning do
  695.    
  696.     --print(tablelength(locations))
  697.    
  698.     for iter = 1+((currentPage-1)*5), tablelength(locations) do
  699.       --numLines = numLines + 1
  700.       --print(iter..tablelength(locations))
  701.      
  702.       if (sg.getAddressForLocation(locations[iter]) ~= "None") then
  703.         index = index + 1
  704.         gpu.setBackground(0x339D8F)
  705.         gpu.fill(4, 3+index*7, w-10, 1, " ")
  706.      
  707.         gpu.fill(4, 3+index*7, 13, 5, " ")
  708.         gpu.fill(19, 3+index*7, 13, 5, " ")
  709.         gpu.fill(34, 3+index*7, 13, 5, " ")
  710.         gpu.fill(49, 3+index*7, 13, 5, " ")
  711.         gpu.fill(64, 3+index*7, 13, 5, " ")
  712.         gpu.fill(79, 3+index*7, 13, 5, " ")
  713.         gpu.fill(94, 3+index*7, 13, 5, " ")
  714.        
  715.         gpu.fill(143, 5+index*7, 10, 3, " ")
  716.      
  717.         gpu.setBackground(0x000000)
  718.         gpu.fill(5, 4+index*7, 11, 3, " ")
  719.         gpu.fill(20, 4+index*7, 11, 3, " ")
  720.         gpu.fill(35, 4+index*7, 11, 3, " ")
  721.         gpu.fill(50, 4+index*7, 11, 3, " ")
  722.         gpu.fill(65, 4+index*7, 11, 3, " ")
  723.         gpu.fill(80, 4+index*7, 11, 3, " ")
  724.         gpu.fill(95, 4+index*7, 11, 3, " ")
  725.        
  726.         gpu.fill(144, 6+index*7, 8, 1, " ")
  727.      
  728.         gpu.setForeground(0xFFFFFF)
  729.         gpu.set(145, 6+index*7, " DIAL ")
  730.      
  731.         local coords = sg.getCoordinatesForLocation(locations[iter])
  732.         local atmosphere = sg.getAtmosphereForLocation(locations[iter])
  733.         local galaxy = sg.getGalaxyNameForLocation(locations[iter])
  734.         local address = sg.getAddressForLocation(locations[iter])
  735.        
  736.         gpu.set(110, 4+index*7, "# "..index+((currentPage-1)*5))
  737.         gpu.set(120, 4+index*7, locations[iter])
  738.         gpu.set(110, 5+index*7, "Additional symbols: ")
  739.         gpu.set(110, 6+index*7, "Atmosphere: "..atmosphere)
  740.         gpu.set(110, 7+index*7, "Galaxy: "..galaxy)
  741.        
  742.         table.insert(addresses, address)
  743.        
  744.         local j = 0
  745.         for i = 1,10 do
  746.           local symbol = address:sub(i,i)
  747.           if i<8 then
  748.             j = j + 1
  749.             gpu.set(10+(j-1)*15, 5+index*7, symbol)
  750.           elseif i==8 then
  751.             gpu.set(130, 5+index*7, symbol)
  752.           elseif i==9 then
  753.             gpu.set(132, 5+index*7, symbol)
  754.           end
  755.         end
  756.        
  757.         if index > 4 then
  758.           --currentPage = currentPage + 1
  759.           break
  760.         end
  761.        
  762.       end
  763.     end
  764.  
  765.     if override then return nil end
  766.  
  767.   --click handling
  768.     local clicking = true
  769.     while clicking do
  770.       local _,_,x,y = event.pull(1, "touch")
  771.       if x then
  772.         --exit
  773.         if ((x<w) and (x>w-5)) and ((y<2) and (y>0)) then
  774.           addressBookRunning = false
  775.           clicking = false
  776.           break
  777.         end
  778.       --next page
  779.         if ((x<153) and (x>149)) and ((y<h-2) and (y>h-4)) and (currentPage < 20) then
  780.           gpu.setBackground(0x000000)
  781.           gpu.fill(4, 10, w-10, 35, " ")
  782.           gpu.fill(70, h-2, 74, 1, " ")
  783.           gpu.setBackground(0x339D8F)
  784.           gpu.fill(70+(currentPage*4), h-2, 2, 1, " ")
  785.           currentPage = currentPage+1
  786.           index = 0
  787.           clicking = false
  788.         end
  789.       --prev. page
  790.         if ((x<68) and (x>64)) and ((y<h-2) and (y>h-4)) and (currentPage > 1) then
  791.           gpu.setBackground(0x000000)
  792.           gpu.fill(4, 10, w-10, 35, " ")
  793.           gpu.fill(70, h-2, 74, 1, " ")
  794.           currentPage = currentPage-1
  795.           gpu.setBackground(0x339D8F)
  796.           gpu.fill(70+((currentPage-1)*4), h-2, 2, 1, " ")
  797.           index = 0
  798.           clicking = false
  799.         end
  800.         for i=0,4 do
  801.           --dial
  802.           if ((x<153) and (x>143)) and ((y<(14+i*7)) and (y>(12+i*7))) then
  803.             addressBookRunning = false
  804.             clicking = false
  805.             ok, result = pcall(sg.dial, addresses[(i+1)+((currentPage-1)*5)])
  806.           end
  807.         end
  808.       end
  809.     end
  810.   end
  811.    
  812.  
  813.   resetGUI()
  814. end
  815.  
  816.  
  817. resetGUI()
  818.  
  819. --Main loop
  820. while running do
  821.   --Information
  822.   local state, engaged, direction = sg.stargateState()
  823.   local iris = sg.irisState()
  824.  
  825.   if state == "Idle"  then
  826.     gpu.setBackground(0x000000)
  827.   gpu.fill(40, 42, 80, 5, " ")
  828.   gpu.fill(41, 41, 78, 1, " ")
  829.   gpu.fill(41, 47, 78, 1, " ")
  830.  
  831.     gpu.setForeground(0xCC0001)
  832.     gpu.setBackground(0xCC0001)
  833.     drawI(23)
  834.     drawD(23+8)
  835.     drawL(23+16)
  836.     drawE(23+24)
  837.  
  838.     if iris == "Closed" then
  839.       drawIris()
  840.     else
  841.       drawWormhole(0x000000)
  842.     end
  843.   end
  844.  
  845.   if state == "Dialling" then
  846.     gpu.setBackground(0x000000)
  847.   gpu.fill(40, 42, 80, 5, " ")
  848.   gpu.fill(41, 41, 78, 1, " ")
  849.   gpu.fill(41, 47, 78, 1, " ")
  850.  
  851.     gpu.setForeground(0xCC0001)
  852.     gpu.setBackground(0xCC0001)
  853.     drawD(10)
  854.     drawI(10+8)
  855.     drawA(10+16)
  856.     drawL(10+24)
  857.     drawI(10+32)
  858.     drawN(10+40)
  859.     drawG(10+48)
  860.    
  861.     if iris == "Closed" then
  862.       drawIris()
  863.     else
  864.       drawWormhole(0x000000)
  865.     end
  866.    
  867.     local _,_,chevronNumber,chevronSymbol = event.pull("sgChevronEngaged")
  868.     gpu.setBackground(0xFF0000)
  869.     gpu.setForeground(0xFFFFFF)
  870.     if chevronNumber == 1 then
  871.       gpu.fill(100, 13, 2, 1, " ")
  872.       gpu.setBackground(0x000000)
  873.       gpu.set(136, 10, chevronSymbol)
  874.     elseif chevronNumber == 2 then
  875.       gpu.fill(108, 23, 2, 1, " ")
  876.       gpu.setBackground(0x000000)
  877.       gpu.set(136, 16, chevronSymbol)
  878.     elseif chevronNumber == 3 then
  879.       gpu.fill(104, 31, 2, 1, " ")
  880.       gpu.setBackground(0x000000)
  881.       gpu.set(136, 22, chevronSymbol)
  882.     elseif chevronNumber == 4 then
  883.       gpu.fill(56, 31, 2, 1, " ")
  884.       gpu.setBackground(0x000000)
  885.       gpu.set(136, 28, chevronSymbol)
  886.     elseif chevronNumber == 5 then
  887.       gpu.fill(52, 23, 2, 1, " ")
  888.       gpu.setBackground(0x000000)
  889.       gpu.set(136, 34, chevronSymbol)
  890.     elseif chevronNumber == 6 then
  891.       gpu.fill(60, 13, 2, 1, " ")
  892.       gpu.setBackground(0x000000)
  893.       gpu.set(136, 40, chevronSymbol)
  894.     elseif chevronNumber == 7 then
  895.       gpu.fill(80, 9, 2, 1, " ")
  896.       gpu.setBackground(0x000000)
  897.       gpu.set(136, 46, chevronSymbol)
  898.     elseif chevronNumber == 8 then
  899.       gpu.fill(90, 36, 2, 1, " ")
  900.       gpu.setBackground(0x000000)
  901.       gpu.set(136, 52, chevronSymbol)
  902.     elseif chevronNumber == 9 then
  903.       gpu.fill(70, 36, 2, 1, " ")
  904.       gpu.setBackground(0x000000)
  905.       gpu.set(136, 58, chevronSymbol)
  906.     end
  907.   end
  908.  
  909.   if state == "Opening" then
  910.     gpu.setBackground(0x000000)
  911.   gpu.fill(40, 42, 80, 5, " ")
  912.   gpu.fill(41, 41, 78, 1, " ")
  913.   gpu.fill(41, 47, 78, 1, " ")
  914.  
  915.     gpu.setForeground(0xCC0001)
  916.     gpu.setBackground(0xCC0001)
  917.     drawO(10)
  918.     drawP(10+8)
  919.     drawE(10+16)
  920.     drawN(10+24)
  921.     drawI(10+32)
  922.     drawN(10+40)
  923.     drawG(10+48)
  924.    
  925.     if iris == "Closed" then
  926.       drawIris()
  927.     else
  928.       drawWormhole(0x000000)
  929.     end
  930.   end
  931.  
  932.   if (state == "Connected") and (direction == "Incoming") then
  933.     gpu.setBackground(0x000000)
  934.   gpu.fill(40, 42, 80, 5, " ")
  935.   gpu.fill(41, 41, 78, 1, " ")
  936.   gpu.fill(41, 47, 78, 1, " ")
  937.  
  938.     gpu.setForeground(0xCC0001)
  939.     gpu.setBackground(0xCC0001)
  940.     drawI(5)
  941.     drawN(5+8)
  942.     drawC(5+16)
  943.     drawO(5+24)
  944.     drawM(5+32)
  945.     drawI(5+40)
  946.     drawN(5+48)
  947.     drawG(5+56)
  948.    
  949.     if iris == "Closed" then
  950.       drawIris()
  951.     else
  952.       drawWormhole(0x2866A6)
  953.     end
  954.   end
  955.  
  956.   if (state == "Connected") and (direction == "Outgoing") then
  957.     gpu.setBackground(0x000000)
  958.   gpu.fill(40, 42, 80, 5, " ")
  959.   gpu.fill(41, 41, 78, 1, " ")
  960.   gpu.fill(41, 47, 78, 1, " ")
  961.  
  962.     gpu.setForeground(0xCC0001)
  963.     gpu.setBackground(0xCC0001)
  964.     drawC(2)
  965.     drawO(2+8)
  966.     drawN(2+16)
  967.     drawN(2+24)
  968.     drawE(2+32)
  969.     drawC(2+40)
  970.     drawT(2+48)
  971.     drawE(2+56)
  972.     drawD(2+64)
  973.    
  974.     if iris == "Closed" then
  975.       drawIris()
  976.     else
  977.       drawWormhole(0x2866A6)
  978.     end
  979.   end
  980.  
  981.   if state == "Closing" then
  982.     gpu.setBackground(0x000000)
  983.   gpu.fill(40, 42, 80, 5, " ")
  984.   gpu.fill(41, 41, 78, 1, " ")
  985.   gpu.fill(41, 47, 78, 1, " ")
  986.  
  987.     gpu.setForeground(0xCC0001)
  988.     gpu.setBackground(0xCC0001)
  989.     drawC(10)
  990.     drawL(10+8)
  991.     drawO(10+16)
  992.     drawS(10+24)
  993.     drawI(10+32)
  994.     drawN(10+40)
  995.     drawG(10+48)
  996.    
  997.     gpu.setBackground(0x000000)
  998.     gpu.fill(5, 10, 26, 1, " ")
  999.    
  1000.     if iris == "Closed" then
  1001.       drawIris()
  1002.     else
  1003.       drawWormhole(0x000000)
  1004.     end
  1005.     gpu.setBackground(0x000000)
  1006.     gpu.setForeground(0x000000)
  1007.     gpu.fill(100, 13, 2, 1, " ")
  1008.     gpu.set(136, 10, " ")
  1009.     gpu.fill(108, 23, 2, 1, " ")
  1010.     gpu.set(136, 16, " ")
  1011.     gpu.fill(104, 31, 2, 1, " ")
  1012.     gpu.set(136, 22, " ")
  1013.     gpu.fill(56, 31, 2, 1, " ")
  1014.     gpu.set(136, 28, " ")
  1015.     gpu.fill(52, 23, 2, 1, " ")
  1016.     gpu.set(136, 34, " ")
  1017.     gpu.fill(60, 13, 2, 1, " ")
  1018.     gpu.set(136, 40, " ")
  1019.     gpu.fill(80, 9, 2, 1, " ")
  1020.     gpu.set(136, 46, " ")
  1021.     gpu.fill(90, 36, 2, 1, " ")
  1022.     gpu.set(136, 52, " ")
  1023.     gpu.fill(70, 36, 2, 1, " ")
  1024.     gpu.set(136, 58, " ")
  1025.   end
  1026.  
  1027.   if state == "Offline" then
  1028.     gpu.setBackground(0x000000)
  1029.   gpu.fill(40, 42, 80, 5, " ")
  1030.   gpu.fill(41, 41, 78, 1, " ")
  1031.   gpu.fill(41, 47, 78, 1, " ")
  1032.  
  1033.     gpu.setForeground(0xCC0001)
  1034.     gpu.setBackground(0xCC0001)
  1035.     drawO(10)
  1036.     drawF(10+8)
  1037.     drawF(10+16)
  1038.     drawL(10+24)
  1039.     drawI(10+32)
  1040.     drawN(10+40)
  1041.     drawE(10+48)
  1042.    
  1043.     if iris == "Closed" then
  1044.       drawIris()
  1045.     else
  1046.       drawWormhole(0x000000)
  1047.     end
  1048.   end
  1049.  
  1050.   --buttons
  1051.   --drawButtons()
  1052.   gpu.setBackground(0x000000)
  1053.   gpu.setForeground(0xFFFFFF)
  1054.   --iris
  1055.   gpu.set(14, 4, iris.."   ")
  1056.   --energy available
  1057.   local energy = sg.energyAvailable()
  1058.   --if energy > 5000000 then
  1059.   --  energy = 5000000
  1060.   --end
  1061.   energy = string.format("%d", energy/1000)
  1062.   --gpu.set(8, 20, energy.."/5000 kSU   ")
  1063.   gpu.set(8, 20, energy.." kSU        ")
  1064.   --energy required
  1065.   if (not (address == nil)) and (string.len(address) > 6) then
  1066.     --gpu.set(8, 24, sg.energyToDial(address))
  1067.   end
  1068.  
  1069.   --click handling
  1070.   local _,_,x,y = event.pull(1, "touch")
  1071.   if x then
  1072.    
  1073.     --address book
  1074.     if ((x<30) and (x>4)) and ((y<29) and (y>27)) then
  1075.       addressBook()
  1076.     end
  1077.  
  1078.     --dialing
  1079.   if ((x<30) and (x>4)) and ((y<11) and (y>9)) then
  1080.       gpu.fill(5, 10, 26, 1, " ")
  1081.       local typing = true
  1082.       local type = true
  1083.       local symbol
  1084.     address = ""
  1085.       local index = 0
  1086.       while typing and index<=11 do
  1087.         gpu.set(11+index+1, 10, "_")
  1088.         local _,_,key = event.pull("key_down")
  1089.         index = index + 1
  1090.         if (key == 8) and (index > 1) then --backspace
  1091.           index = index - 1
  1092.           address = string.sub(address, 1, index+1)
  1093.           gpu.set(11+index+1, 10, " ")
  1094.           gpu.set(11+index, 10, "_")
  1095.           index=index-1
  1096.         elseif index >= 1 then
  1097.           if ((key>47) and (key<58)) then
  1098.             symbol = numbers[key-47]
  1099.           end
  1100.             if ((key>96) and (key<123)) then
  1101.               symbol = characters[key-96]
  1102.             end
  1103.             if type then
  1104.               if symbol ~= null then
  1105.                 gpu.set(11+index, 10, symbol)
  1106.               end
  1107.             end
  1108.             if index==4 then
  1109.               index = index + 1
  1110.               gpu.set(11+index, 10, "-")
  1111.             end
  1112.             if index==8 then
  1113.               index = index + 1
  1114.               gpu.set(11+index, 10, "-")
  1115.             end
  1116.             if index==11 then
  1117.               type = false
  1118.               gpu.set(11+index+1, 10, "_")
  1119.               for i=1,11 do
  1120.                 symbol = gpu.get(11+i, 10)
  1121.                 if symbol == "-" then
  1122.           address = address.."-"
  1123.                 else
  1124.                   address = address..symbol
  1125.                 end
  1126.               end
  1127.               while true do
  1128.                 local _,_,key = event.pull("key_down")
  1129.                 if key == 13 then
  1130.                   gpu.set(11+index+1, 10, " ")
  1131.                   typing = false
  1132.                   break
  1133.                 end
  1134.               end
  1135.             end
  1136.           end
  1137.         end
  1138.       ok, result = pcall(sg.dial, address)
  1139.       if ok then
  1140.         gpu.fill(5, 36, 26, 12, " ")
  1141.         resultTable = wrap("Dialling gate at: "..address, 26)
  1142.         for k,v in pairs(resultTable) do
  1143.           gpu.set(5, 35+k, v)
  1144.         end
  1145.         local energyReq = string.format("%d", energy/1000)
  1146.         resultTable = wrap("Required energy: "..energyReq.." kSU", 26)
  1147.         for k,v in pairs(resultTable) do
  1148.           gpu.set(5, 22+k, v)
  1149.         end
  1150.       else
  1151.         gpu.fill(5, 36, 26, 12, " ")
  1152.         resultTable = wrap(result, 26)
  1153.         for k,v in pairs(resultTable) do
  1154.           gpu.set(5, 35+k, v)
  1155.         end
  1156.       end
  1157.     end
  1158.   end
  1159.  
  1160.   gpu.setForeground(0xFFFFFF)
  1161.   gpu.setBackground(0x000000)
  1162. end
  1163.  
  1164. term.clear()
Add Comment
Please, Sign In to add comment