Advertisement
Guest User

DisplayControl

a guest
Jan 19th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.19 KB | None | 0 0
  1. local com = peripheral.wrap("back")
  2. local display = peripheral.wrap("right")
  3. local tanks = {
  4.   coolantA1 = "rcirontankvalvetile_2",
  5.   coolantB1 = "rcirontankvalvetile_3",
  6.   coolantS = "rcirontankvaluetile_4",
  7.   distilledA1 = "rcirontankvalvetile_5",
  8.   distilledB1 = "rcirontankvalvetile_1",
  9.   distilledS = "rcirontankvaluetile_6"
  10. }
  11. function tryTankLevel(tank)
  12.   return com.callRemote(tank, "getTankInfo")[1].contents.amount
  13. end
  14. function getTankLevel(tank)
  15.   local empty, level = pcall(tryTankLevel, tank)
  16.   if (not empty) then
  17.     return 0
  18.   else
  19.     return level
  20.   end
  21. end
  22. local colorValue = 0
  23. function toggleColor(color)
  24.   if (rs.testBundledInput("bottom", color)) then
  25.     rs.setBundledOutput("bottom", colorValue - color)
  26.     colorValue = colorValue - color
  27.   else
  28.     rs.setBundledOutput("bottom", colorValue + color)
  29.     colorValue = colorValue + color
  30.   end
  31. end
  32. function printAtMonitor(x, y, color, text)
  33.   display.setTextColor(color)
  34.   display.setCursorPos(x, y)
  35.   display.write(text)
  36. end
  37. function printAt(x,y,color,text)
  38.   term.setTextColor(color)
  39.   term.setCursorPos(x, y)
  40.   term.write(text)
  41. end
  42. function signalToColor(signal)
  43.   if (signal) then
  44.     return colors.lime
  45.   else
  46.     return colors.red
  47. end
  48. function reactorDisplay()
  49.   local run = true
  50.   while true do
  51.     local coolant = {
  52.       tankA1 = getTankLevel(tanks.coolantA1),
  53.       tankB1 = getTankLevel(tanks.coolantB1),
  54.       tankA2 = 0,
  55.       tankB2 = 0,
  56.       tankA3 = 0,
  57.       tankB3 = 0,
  58.       tankA4 = 0,
  59.       tankB4 = 0,
  60.       tankS = getTankLevel(tanks.coolantS),
  61.       SA1 = rs.testBundledInput("bottom", 1),
  62.       A1A2 = rs.testBundledInput("bottom", 2),
  63.       A2A3 = rs.testBundledInput("bottom", 4),
  64.       A3A4 = rs.testBundledInput("bottom", 8),
  65.       A4S = rs.testBundledInput("bottom", 16),
  66.       SB1 = rs.testBundledInput("bottom", 32),
  67.       B1B2 = rs.testBundledInput("bottom", 64),
  68.       B2B3 = rs.testBundledInput("bottom", 128),
  69.       B3B4 = rs.testBundledInput("bottom", 256),
  70.       B4S = rs.testBundledInput("bottom", 512)
  71.     }
  72.     local distilled = {
  73.       tankA1 = getTankLevel(tanks.distilledA1),
  74.       tankB1 = getTankLevel(tanks.distilledB1),
  75.       tankA2 = 0,
  76.       tankB2 = 0,
  77.       tankA3 = 0,
  78.       tankB3 = 0,
  79.       tankA4 = 0,
  80.       tankB4 = 0,
  81.       tankS = getTankLevel(tanks.distilledS),
  82.       SA1 = rs.testBundledInput("top", 1),
  83.       A1A2 = rs.testBundledInput("top", 2),
  84.       A2A3 = rs.testBundledInput("top", 4),
  85.       A3A4 = rs.testBundledInput("top", 8),
  86.       A4S = rs.testBundledInput("top", 16),
  87.       SB1 = rs.testBundledInput("top", 32),
  88.       B1B2 = rs.testBundledInput("top", 64),
  89.       B2B3 = rs.testBundledInput("top", 128),
  90.       B3B4 = rs.testBundledInput("top", 256),
  91.       B4S = rs.testBundledInput("top", 512)
  92.     }
  93.     display.clear()
  94.     printAtMonitor(1,1,colors.white,"Coolant:")
  95.     printAtMonitor(2,2,colors.cyan, "S: "..coolant.tankS)
  96.     printAtMonitor(2,4,colors.cyan, "1A: "..coolant.tankA1)
  97.     printAtMonitor(2,5,colors.cyan, "1B: "..coolant.tankB1)
  98.     printAtMonitor(2,6,colors.cyan, "2A: "..coolant.tankA2)
  99.     printAtMonitor(2,7,colors.cyan, "2B: "..coolant.tankB2)
  100.     printAtMonitor(2,8,colors.cyan, "3A: "..coolant.tankA3)
  101.     printAtMonitor(2,9,colors.cyan, "3B: "..coolant.tankB3)
  102.     printAtMonitor(2,10,colors.cyan, "4A: "..coolant.tankA4)
  103.     printAtMonitor(2,11,colors.cyan, "4B: "..coolant.tankB4)
  104.     printAtMonitor(1,2,signalToColor(coolant.SA1), "v")
  105.     printAtMonitor(1,3,signalToColor(coolant.SB1), "v")
  106.     printAtMonitor(1,4,signalToColor(coolant.A1A2), "v")
  107.     printAtMonitor(1,5,signalToColor(coolant.B1B2), "v")
  108.     printAtMonitor(1,6,signalToColor(coolant.A2A3), "v")
  109.     printAtMonitor(1,7,signalToColor(coolant.B2B3), "v")
  110.     printAtMonitor(1,8,signalToColor(coolant.A3A4), "v")
  111.     printAtMonitor(1,9,signalToColor(coolant.B3B4), "v")
  112.     printAtMonitor(1,10,signalToColor(coolant.A4S), "^")
  113.     printAtMonitor(1,11,signalToColor(coolant.B4S), "^")
  114.    
  115.     printAtMonitor(14,1,colors.white,"Distilled:")
  116.     printAtMonitor(15,2,colors.lightBlue, "S: "..distilled.tankS)
  117.     printAtMonitor(15,4,colors.lightBlue, "1A: "..distilled.tankA1)
  118.     printAtMonitor(15,5,colors.lightBlue, "1B: "..distilled.tankB1)
  119.     printAtMonitor(15,6,colors.lightBlue, "2A: "..distilled.tankA2)
  120.     printAtMonitor(15,7,colors.lightBlue, "2B: "..distilled.tankB2)
  121.     printAtMonitor(15,8,colors.lightBlue, "3A: "..distilled.tankA3)
  122.     printAtMonitor(15,9,colors.lightBlue, "3B: "..distilled.tankB3)
  123.     printAtMonitor(15,10,colors.lightBlue, "4A: "..distilled.tankA4)
  124.     printAtMonitor(15,11,colors.lightBlue, "4B: "..distilled.tankB4)
  125.     printAtMonitor(14,2,signalToColor(distilled.SA1), "v")
  126.     printAtMonitor(14,3,signalToColor(distilled.SB1), "v")
  127.     printAtMonitor(14,4,signalToColor(distilled.A1A2), "v")
  128.     printAtMonitor(14,5,signalToColor(distilled.B1B2), "v")
  129.     printAtMonitor(14,6,signalToColor(distilled.A2A3), "v")
  130.     printAtMonitor(14,7,signalToColor(distilled.B2B3), "v")
  131.     printAtMonitor(14,8,signalToColor(distilled.A3A4), "v")
  132.     printAtMonitor(14,9,signalToColor(distilled.B3B4), "v")
  133.     printAtMonitor(14,10,signalToColor(distilled.A4S), "^")
  134.     printAtMonitor(14,11,signalToColor(distilled.B4S), "^")
  135.    
  136.    
  137.     if (run) then
  138.       printAtMonitor(1,12, colors.white, "Running")
  139.     end
  140.     run = not run
  141.     sleep(1)
  142.   end
  143. end
  144.  
  145. reactorDisplay()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement