Advertisement
ExVee

SGCraft Gate Display

Sep 7th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mon = peripheral.find("monitor")
  2. sg = peripheral.find("stargate")
  3.  
  4. mon.setBackgroundColor(colors.black)
  5. mon.clear()
  6. maxEng = 90000
  7. dialling = {}
  8.  
  9. local function alarmSet(set)
  10.   rs.setOutput("left", set)
  11.   return
  12. end
  13.  
  14.  
  15.  
  16. function drawChevrons() --draws cheyvrons on the screen
  17.   x,y = mon.getSize()
  18.   chevX1 = x/3
  19.   chevX2 = x/3*2+1
  20.   chevY1 = y/3-2
  21.   chevY2 = y/3*2 +2
  22.   mon.setBackgroundColor(colors.black)
  23.   for yc = chevY1-2, chevY2-2 do
  24.     for xc = chevX1-2, chevX2-2 do
  25.       mon.setCursorPos(xc, yc)
  26.       mon.write(" ")
  27.     end
  28.   end
  29.   mon.setBackgroundColor(colors.lightGray)
  30.   for i = chevX1+2, chevX2-2 do
  31.     mon.setCursorPos(i,chevY1)
  32.     mon.write(" ")
  33.   end
  34.   for i = chevX1+2, chevX2-2 do
  35.     mon.setCursorPos(i,chevY2)
  36.     mon.write(" ")
  37.   end
  38.   for i = chevY1+2, chevY2-2 do
  39.     mon.setCursorPos(chevX1,i)
  40.     mon.write(" ")
  41.   end
  42.   for i = chevY1+2, chevY2-2 do
  43.     mon.setCursorPos(chevX2, i)
  44.     mon.write(" ")
  45.   end
  46.   chev1pos = {chevX1, chevY2 }
  47.   mon.setBackgroundColor(colors.gray)
  48.   mon.setTextColor(colors.black)
  49.   mon.setCursorPos(math.floor(chev1pos[1]), math.floor(chev1pos[2])-1)
  50.   mon.write(" > ")
  51.   chev2pos = {chevX1, chevY1 + ((chevY2 - chevY1) / 2) }
  52.   mon.setCursorPos(math.floor(chev2pos[1]-1), math.floor(chev2pos[2]))
  53.   mon.write(" > ")
  54.   chev3pos = {chevX1, chevY1 }
  55.   mon.setCursorPos(math.floor(chev3pos[1]), math.floor(chev3pos[2]+1))
  56.   mon.write(" > ")
  57.   chev4pos = {chevX1 + ((chevX2 - chevX1) / 2), chevY1 }
  58.   mon.setCursorPos(math.floor(chev4pos[1]-1), math.floor(chev4pos[2]))
  59.   mon.write(" V ")
  60.   chev5pos = {chevX2, chevY1 }
  61.   mon.setCursorPos(math.floor(chev5pos[1]-2), math.floor(chev5pos[2])+1)
  62.   mon.write(" < ")
  63.   chev6pos = {chevX2, chevY1 + ((chevY2 - chevY1) / 2) }
  64.   mon.setCursorPos(math.floor(chev6pos[1]-1), math.floor(chev6pos[2]))
  65.   mon.write(" < ")
  66.   chev7pos = {chevX2, chevY2 }
  67.   mon.setCursorPos(math.floor(chev7pos[1]-2), math.floor(chev7pos[2]-1))
  68.   mon.write(" < ")
  69.   chev8pos = {chevX1 + ((chevX2 - chevX1) /2), chevY2 }
  70.   mon.setCursorPos(math.floor(chev8pos[1]-1), math.floor(chev8pos[2]))
  71.   mon.write("   ")
  72. --  chev9pos = {chevX1 + ((chevX2 - chevX1) /2), chevY2 }
  73. --  mon.setCursorPos(math.floor(chev8pos[1]-1), chevY1 + ((chevY2 - chevY1) / 2))
  74. --  mon.write(" 9 ")
  75.   mon.setBackgroundColor(colors.black)
  76.   mon.setCursorPos(x/2 - 4, y/2 - 1)
  77.   mon.write("           ")
  78.   mon.setCursorPos(x/2-1, y/2+4)
  79.   mon.write("     ")
  80. end
  81.  
  82. function drawChev( chevInfo )
  83.   mon.setBackgroundColor(colors.gray)
  84.   x,y = mon.getSize()
  85.   chevX1 = x/3
  86.   chevX2 = x/3*2+1
  87.   chevY1 = y/3-2
  88.   chevY2 = y/3*2 +2
  89.   if chevInfo[1] == 1 then
  90.     chev1pos = {chevX1, chevY2 }
  91.     mon.setBackgroundColor(colors.gray)
  92.     mon.setCursorPos(math.floor(chev1pos[1]), math.floor(chev1pos[2])-1)
  93.     mon.write(" "..chevInfo[2].." ")
  94.   elseif chevInfo[1] == 2 then
  95.     chev2pos = {chevX1, chevY1 + ((chevY2 - chevY1) / 2) }
  96.     mon.setCursorPos(math.floor(chev2pos[1]-1), math.floor(chev2pos[2]))
  97.     mon.write(" "..chevInfo[2].." ")
  98.   elseif chevInfo[1] == 3 then
  99.     chev3pos = {chevX1, chevY1 }
  100.     mon.setCursorPos(math.floor(chev3pos[1]), math.floor(chev3pos[2]+1))
  101.     mon.write(" "..chevInfo[2].." ")
  102.   elseif chevInfo[1] == 4 then
  103.     chev4pos = {chevX1 + ((chevX2 - chevX1) / 2), chevY1 }
  104.     mon.setCursorPos(math.floor(chev4pos[1]-1), math.floor(chev4pos[2]))
  105.     mon.write(" "..chevInfo[2].." ")
  106.   elseif chevInfo[1] == 5 then
  107.     chev5pos = {chevX2, chevY1 }
  108.     mon.setCursorPos(math.floor(chev5pos[1]-2), math.floor(chev5pos[2])+1)
  109.     mon.write(" "..chevInfo[2].." ")
  110.   elseif chevInfo[1] == 6 then
  111.     chev6pos = {chevX2, chevY1 + ((chevY2 - chevY1) / 2) }
  112.     mon.setCursorPos(math.floor(chev6pos[1]-1), math.floor(chev6pos[2]))
  113.     mon.write(" "..chevInfo[2].." ")
  114.   elseif chevInfo[1] == 7 then
  115.     chev7pos = {chevX2, chevY2 }
  116.     mon.setCursorPos(math.floor(chev7pos[1]-2), math.floor(chev7pos[2]-1))
  117.     mon.write(" "..chevInfo[2].." ")
  118.   elseif chevInfo[1] == 8 then
  119.     chev8pos = {chevX1 + ((chevX2 - chevX1) /2), chevY2 }
  120.     mon.setCursorPos(math.floor(chev8pos[1]-1), math.floor(chev8pos[2]))
  121.     mon.write(" "..chevInfo[2].." ")
  122.   elseif chevInfo[1] == 9 then
  123.     chev9pos = {chevX1 + ((chevX2 - chevX1) /2), chevY2 }
  124.     mon.setCursorPos(math.floor(chev8pos[1]-1), chevY1 + ((chevY2 - chevY1) / 2))
  125.     mon.write(" "..chevInfo[2].." ")
  126.   mon.setBackgroundColor(colors.black)
  127. end
  128.  
  129. end
  130.  
  131.  
  132.  
  133. function drawHome() -- draws the home screen
  134.   mon.setBackgroundColor(colors.black)
  135.   x,y = mon.getSize()
  136.   mon.clear()
  137.   mon.setCursorPos(1,y)
  138.   mon.setTextColor(colors.gray)
  139.   mon.setBackgroundColor(colors.black)
  140.   mon.write("AbydOS")
  141.   drawPowerBar()
  142.   drawChevrons()
  143.  
  144. end
  145.  
  146.  
  147.  
  148. function drawRemoteAddress()
  149.   mon.setBackgroundColor(colors.black)
  150.   x,y = mon.getSize()
  151.   mon.setCursorPos((x/2+1) - string.len(sg.remoteAddress())/2, y/2-2)
  152.   mon.write(sg.remoteAddress())
  153. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement