Advertisement
Guest User

bar

a guest
May 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.44 KB | None | 0 0
  1. mon = peripheral.wrap("top")
  2.  
  3. mon.setTextScale(.5)
  4.  
  5. Draw={}
  6.  
  7. Draw["x"] = {
  8.   2,
  9.   2,
  10.   2,
  11.   2,
  12.   2,
  13.   2,
  14.   2,
  15.   2,
  16.   2,
  17.   2
  18. }
  19. Draw["y"] = {
  20.   2,
  21.   4,
  22.   6,
  23.   8,
  24.   10,
  25.   12,
  26.   14,
  27.   16,
  28.   18,
  29.   20
  30. }
  31.  
  32. Draw["bgc"] = {
  33.  colors.black, --1
  34.  colors.black, --2
  35.  colors.black, --3
  36.  colors.black, --4
  37.  colors.black, --5
  38.  colors.black, --6
  39.  colors.black, --7
  40.  colors.black, --8
  41.  colors.black, --9
  42.  colors.black
  43. }
  44.  
  45. Draw["energyColor"] = {
  46.   colors.red,
  47.   colors.red,
  48.   colors.red,
  49.   colors.red,
  50.   colors.red,
  51.   colors.red,
  52.   colors.red,
  53.   colors.red,
  54.   colors.red,
  55.   colors.red
  56. }
  57.  
  58. Draw["txt"] = {
  59.   "EnergyCell: 1",
  60.   "EnergyCell: 2",
  61.   "EnergyCell: 3",
  62.   "EnergyCell: 4",
  63.   "EnergyCell: 5",
  64.   "EnergyCell: 6",
  65.   "EnergyCell: 7",
  66.   "EnergyCell: 8",
  67.   "EnergyCell: 9",
  68.   "EnergyCell: 10"
  69. }
  70.  
  71. Draw["txtColor"] = {
  72.   colors.lime,
  73.   colors.lime,
  74.   colors.lime,
  75.   colors.lime,
  76.   colors.lime,
  77.   colors.lime,
  78.   colors.lime,
  79.   colors.lime,
  80.   colors.lime,
  81.   colors.lime
  82. }
  83.  
  84. Draw["state"] = {
  85.   true,
  86.   true,
  87.   true,
  88.   true,
  89.   true,
  90.   true,
  91.   true,
  92.   true,
  93.   true,
  94.   true
  95. }
  96.  
  97. Draw["OC"] = {
  98.   colors.white,
  99.   colors.orange,
  100.   colors.magenta,
  101.   colors.lightBlue,
  102.   colors.yellow,
  103.   colors.lime,
  104.   colors.pink,
  105.   colors.gray,
  106.   colors.lightGray,
  107.   colors.cyan
  108. }
  109.  
  110. Draw["side"] = {
  111.   "right",
  112.   "right",
  113.   "right",
  114.   "right",
  115.   "right",
  116.   "right",
  117.   "right",
  118.   "right",
  119.   "right",
  120.   "right"
  121. }
  122.  
  123.  
  124. --percentages
  125. Draw["max"] = {99,99,99,99,99,99,99,99,99,99}
  126. Draw["min"] = {10,10,10,10,10,10,10,10,10,10}
  127.  
  128.  
  129.  
  130.  
  131.  
  132. --Totals
  133. Draw["maxX"] = {2}
  134. Draw["maxY"] = {24}
  135.  
  136.  
  137. Draw["maxMax"] = {95}
  138. Draw["maxMid"] = {50}
  139. Draw["maxMin"] = {30}
  140.  
  141.  
  142. Draw["maxTxtColor"] = {colors.lime}
  143. Draw["maxEnergyColor"] = {colors.red}
  144. Draw["maxTxt"] = {"Total Power"}
  145.  
  146. Draw["maxSide"] = {"right","right"}
  147. Draw["MOC"] = {colors.white,colors.orange}
  148. Draw["MaxState"] = {false,false}
  149.  
  150.  
  151.  
  152.  
  153.  
  154. --Peripherals
  155. Cell = {
  156.   peripheral.wrap("cofh_thermalexpansion_energycell_33"),
  157.   peripheral.wrap("cofh_thermalexpansion_energycell_34"),
  158.   peripheral.wrap("cofh_thermalexpansion_energycell_35"),
  159.   peripheral.wrap("cofh_thermalexpansion_energycell_36"),
  160.   peripheral.wrap("cofh_thermalexpansion_energycell_37"),
  161.   peripheral.wrap("cofh_thermalexpansion_energycell_38"),
  162.   peripheral.wrap("cofh_thermalexpansion_energycell_39"),
  163.   peripheral.wrap("cofh_thermalexpansion_energycell_40"),
  164.   peripheral.wrap("cofh_thermalexpansion_energycell_41"),
  165.   peripheral.wrap("cofh_thermalexpansion_energycell_42")
  166. }
  167.  
  168.  
  169.  
  170. function EnergyStored(number)
  171.   Energy = Cell[number].getEnergyStored("unknown")
  172.     return Energy
  173. end
  174.  
  175. function MaxEnergyStored(number)
  176.   Energy = Cell[number].getMaxEnergyStored("unknown")
  177.     return Energy
  178. end
  179.  
  180. function clear()
  181.   mon.setBackgroundColor(colors.black)
  182.     mon.clear()
  183. end
  184.  
  185. clear()
  186.  
  187. function Set()
  188.  
  189. local x = 1
  190.    for i = x, #Draw["x"] do
  191.      
  192.      mon.setCursorPos(Draw["x"][i],Draw["y"][i])
  193.         mon.setTextColor(Draw["energyColor"][i])
  194.          mon.setBackgroundColor(Draw["bgc"][i])
  195.          
  196.   MaxEnergy = MaxEnergyStored(i)
  197.     StoredEnergy = EnergyStored(i)
  198.      
  199.        --MaxEnergy = 0
  200.          --StoredEnergy = 0
  201.      
  202.      Percent = math.floor((StoredEnergy / MaxEnergy) * 100)
  203.      
  204.  
  205.       mon.setTextColor(Draw["txtColor"][i])
  206.        mon.write(Draw["txt"][i].."   ")
  207.        
  208.      mon.setCursorPos(Draw["x"][i], Draw["y"][i] + 1)  
  209.         mon.setTextColor(Draw["energyColor"][i])
  210.           mon.write(StoredEnergy.." / "..MaxEnergy.."   ")
  211.    
  212.    
  213.       if Percent >= Draw["max"][i] then
  214.         mon.setTextColor(colors.green)
  215.            Draw["state"][i] = false
  216.       elseif Percent <= Draw["min"][i] then
  217.         mon.setTextColor(colors.red)
  218.             Draw["state"][i] = true
  219.       else
  220.         mon.setTextColor(colors.orange)  
  221.       end
  222.    
  223.           --mon.setCursorPos(Draw[1][i],Draw[2][i] + 1)
  224.           mon.write(Percent.."%    ")
  225.    
  226.    
  227.    
  228.     end
  229. end
  230.  
  231.  
  232.  
  233.  
  234. -----------------------Totals-----------------------
  235. function TotalEnergyStored()
  236.   local x = 1    
  237.      local Total = 0
  238.     for i = x,#Cell do      
  239.       Total = Total + Cell[i].getEnergyStored("unknown")  
  240.     end
  241.     return Total
  242. end
  243.  
  244.  
  245. function TotalStorage()
  246.   local x = 1
  247.     local Total = 0
  248.       for i = x,#Cell do
  249.         Total = Total + Cell[i].getMaxEnergyStored("unknown")
  250.       end      
  251.       return Total
  252. end      
  253.  
  254.  
  255. function Max()
  256.   local x = 0
  257.      mon.setCursorPos(Draw["maxX"][1], Draw["maxY"][1])
  258.        mon.setBackgroundColor(colors.black)
  259.          mon.setTextColor(Draw["maxTxtColor"][1])
  260.      
  261.        mon.write(Draw["maxTxt"][1])
  262.       mon.setCursorPos(Draw["maxX"][1], Draw["maxY"][1] + 1)
  263.    mon.setTextColor(Draw["maxEnergyColor"][1])
  264.  
  265.  
  266.    Energy = TotalEnergyStored()
  267.     Storage = TotalStorage()
  268.      
  269.  
  270.      
  271.       Percentage = math.floor((Energy / Storage) * 100)
  272.  
  273.     mon.write(Energy.." / "..Storage.."   ")
  274.      
  275.       if Percentage >= Draw["maxMax"][1] then
  276.         mon.setTextColor(colors.green)
  277.           Draw["MaxState"][1] = false
  278.             Draw["MaxState"][2] = false
  279.      
  280.       elseif Percentage <= Draw["maxMin"][1] then
  281.         mon.setTextColor(colors.red)
  282.           Draw["MaxState"][1] = true
  283.             Draw["MaxState"][2] = true
  284.      
  285.       elseif Percentage <= Draw["maxMid"][1] then
  286.         mon.setTextColor(colors.yellow)
  287.           Draw["MaxState"][2] = true
  288.       else  
  289.         mon.setTextColor(colors.orange)
  290.       end
  291.    
  292.    
  293.    
  294.    
  295.     mon.write(Percentage.."%      ")
  296.  
  297.   if Draw["MaxState"][2] == true then
  298.     mon.setCursorPos(Draw["maxX"][1],Draw["maxY"][1] + 3)
  299.       mon.setTextColor(colors.gray)
  300.         mon.write("Magmatic Dynamo: ")
  301.  
  302.       mon.setTextColor(colors.lime)
  303.         mon.write("Active  ")
  304.  
  305.   elseif Draw["MaxState"][2] == false then
  306.       mon.setCursorPos(Draw["maxX"][1],Draw["maxY"][1] + 3)
  307.         mon.setTextColor(colors.gray)
  308.           mon.write("Magmatic Dynamo: ")
  309.          
  310.             mon.setTextColor(colors.red)
  311.               mon.write("InActive")
  312.   end
  313.  
  314.  
  315.  
  316.   if Draw["MaxState"][1] == true then
  317.     mon.setCursorPos(Draw["maxX"][1],Draw["maxY"][1] + 4)
  318.       mon.setTextColor(colors.gray)
  319.         mon.write("Reactor: ")
  320.          
  321.           mon.setTextColor(colors.lime)
  322.             mon.write("Active  ")
  323.   elseif Draw["MaxState"][1] == false then
  324.       mon.setCursorPos(Draw["maxX"][1],Draw["maxY"][1] + 4)
  325.         mon.setTextColor(colors.gray)
  326.           mon.write("Reactor: ")
  327.            
  328.             mon.setTextColor(colors.red)
  329.               mon.write("InActive")
  330.   end
  331.  
  332.  
  333. end
  334.  
  335.  
  336.  
  337.  
  338. function MaxRedstone()
  339.   if Draw["MaxState"][1] == true then
  340.     rs.setBundledOutput(Draw["maxSide"][1],colors.combine(rs.getBundledOutput(Draw["maxSide"][1]),Draw["MOC"][1]))
  341.    elseif Draw["MaxState"][1] == false then
  342.      rs.setBundledOutput(Draw["maxSide"][1],colors.subtract(rs.getBundledOutput(Draw["maxSide"][1]),Draw["MOC"][1]))
  343.   end
  344. end
  345.  
  346.  
  347.  
  348. function Redstone()
  349.  local x = 1
  350.    
  351.    for i = x, #Draw["state"] do
  352.      if Draw["state"][i] == true then
  353.        rs.setBundledOutput(Draw["side"][i],colors.combine(rs.getBundledOutput(Draw["side"][i]),Draw["OC"][i]))
  354.       elseif Draw["state"][i] == false then
  355.         rs.setBundledOutput(Draw["side"][i],colors.subtract(rs.getBundledOutput(Draw["side"][i]),Draw["OC"][i]))
  356.      end
  357.    end
  358. end
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366. while true do
  367. Set()
  368. Max()
  369. MaxRedstone()
  370. sleep(1)
  371. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement