Advertisement
Guest User

startup

a guest
May 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.62 KB | None | 0 0
  1. mon = peripheral.wrap("back")
  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["maxMin"] = {30}
  139.  
  140.  
  141. Draw["maxTxtColor"] = {colors.lime}
  142. Draw["maxEnergyColor"] = {colors.red}
  143. Draw["maxTxt"] = {"Total Power"}
  144.  
  145. Draw["maxSide"] = {"right"}
  146. Draw["MOC"] = {colors.white}
  147. Draw["MaxState"] = {false}
  148.  
  149.  
  150.  
  151.  
  152.  
  153. --Peripherals
  154. Cell = {
  155.   peripheral.wrap("cofh_thermalexpansion_energycell_26"),
  156.   peripheral.wrap("cofh_thermalexpansion_energycell_22"),
  157.   peripheral.wrap("cofh_thermalexpansion_energycell_25"),
  158.   peripheral.wrap("cofh_thermalexpansion_energycell_23"),
  159.   peripheral.wrap("cofh_thermalexpansion_energycell_29"),
  160.   peripheral.wrap("cofh_thermalexpansion_energycell_24"),
  161.   peripheral.wrap("cofh_thermalexpansion_energycell_30"),
  162.   peripheral.wrap("cofh_thermalexpansion_energycell_27"),
  163.   peripheral.wrap("cofh_thermalexpansion_energycell_31"),
  164.   peripheral.wrap("cofh_thermalexpansion_energycell_28")
  165. }
  166.  
  167.  
  168.  
  169. function EnergyStored(number)
  170.   Energy = Cell[number].getEnergyStored("unknown")
  171.     return Energy
  172. end
  173.  
  174. function MaxEnergyStored(number)
  175.   Energy = Cell[number].getMaxEnergyStored("unknown")
  176.     return Energy
  177. end
  178.  
  179. function clear()
  180.   mon.setBackgroundColor(colors.black)
  181.     mon.clear()
  182. end
  183.  
  184. clear()
  185.  
  186. function Set()
  187.  
  188. local x = 1
  189.    for i = x, #Draw["x"] do
  190.      
  191.      mon.setCursorPos(Draw["x"][i],Draw["y"][i])
  192.         mon.setTextColor(Draw["energyColor"][i])
  193.          mon.setBackgroundColor(Draw["bgc"][i])
  194.          
  195.   MaxEnergy = MaxEnergyStored(i)
  196.     StoredEnergy = EnergyStored(i)
  197.      
  198.        --MaxEnergy = 0
  199.          --StoredEnergy = 0
  200.      
  201.      Percent = math.floor((StoredEnergy / MaxEnergy) * 100)
  202.      
  203.  
  204.       mon.setTextColor(Draw["txtColor"][i])
  205.        mon.write(Draw["txt"][i].."   ")
  206.        
  207.      mon.setCursorPos(Draw["x"][i], Draw["y"][i] + 1)  
  208.         mon.setTextColor(Draw["energyColor"][i])
  209.           mon.write(StoredEnergy.." / "..MaxEnergy.."   ")
  210.    
  211.    
  212.       if Percent >= Draw["max"][i] then
  213.         mon.setTextColor(colors.green)
  214.            Draw["state"][i] = false
  215.       elseif Percent <= Draw["min"][i] then
  216.         mon.setTextColor(colors.red)
  217.             Draw["state"][i] = true
  218.       else
  219.         mon.setTextColor(colors.orange)  
  220.       end
  221.    
  222.           --mon.setCursorPos(Draw[1][i],Draw[2][i] + 1)
  223.           mon.write(Percent.."%    ")
  224.    
  225.    
  226.    
  227.     end
  228. end
  229.  
  230.  
  231.  
  232.  
  233. -----------------------Totals-----------------------
  234. function TotalEnergyStored()
  235.   local x = 1    
  236.      local Total = 0
  237.     for i = x,#Cell do      
  238.       Total = Total + Cell[i].getEnergyStored("unknown")  
  239.     end
  240.     return Total
  241. end
  242.  
  243.  
  244. function TotalStorage()
  245.   local x = 1
  246.     local Total = 0
  247.       for i = x,#Cell do
  248.         Total = Total + Cell[i].getMaxEnergyStored("unknown")
  249.       end      
  250.       return Total
  251. end      
  252.  
  253.  
  254. function Max()
  255.   local x = 0
  256.      mon.setCursorPos(Draw["maxX"][1], Draw["maxY"][1])
  257.        mon.setBackgroundColor(colors.black)
  258.          mon.setTextColor(Draw["maxTxtColor"][1])
  259.      
  260.        mon.write(Draw["maxTxt"][1])
  261.       mon.setCursorPos(Draw["maxX"][1], Draw["maxY"][1] + 1)
  262.    mon.setTextColor(Draw["maxEnergyColor"][1])
  263.  
  264.  
  265.    Energy = TotalEnergyStored()
  266.     Storage = TotalStorage()
  267.      
  268.  
  269.      
  270.       Percentage = math.floor((Energy / Storage) * 100)
  271.  
  272.     mon.write(Energy.." / "..Storage.."   ")
  273.      
  274.       if Percentage >= Draw["maxMax"][1] then
  275.         mon.setTextColor(colors.green)
  276.           Draw["MaxState"][1] = false
  277.       elseif Percentage <= Draw["maxMin"][1] then
  278.         mon.setTextColor(colors.red)
  279.           Draw["MaxState"][1] = true
  280.       else
  281.         mon.setTextColor(colors.orange)
  282.       end
  283.    
  284.     mon.write(Percentage.."%      ")
  285.  
  286.   if Draw["MaxState"][1] == true then
  287.     mon.setCursorPos(Draw["maxX"][1],Draw["maxY"][1] + 2)
  288.       mon.setTextColor(colors.gray)
  289.         mon.write("Reactor: ")
  290.          
  291.           mon.setTextColor(colors.lime)
  292.             mon.write("Active  ")
  293.   elseif Draw["MaxState"][1] == false then
  294.       mon.setCursorPos(Draw["maxX"][1],Draw["maxY"][1] + 2)
  295.         mon.setTextColor(colors.gray)
  296.           mon.write("Reactor: ")
  297.            
  298.             mon.setTextColor(colors.red)
  299.               mon.write("InActive")
  300.   end
  301.  
  302.  
  303. end
  304.  
  305.  
  306.  
  307.  
  308. function MaxRedstone()
  309.   if Draw["MaxState"][1] == true then
  310.     rs.setBundledOutput(Draw["maxSide"][1],colors.combine(rs.getBundledOutput(Draw["maxSide"][1]),Draw["MOC"][1]))
  311.    elseif Draw["MaxState"][1] == false then
  312.      rs.setBundledOutput(Draw["maxSide"][1],colors.subtract(rs.getBundledOutput(Draw["maxSide"][1]),Draw["MOC"][1]))
  313.   end
  314. end
  315.  
  316.  
  317.  
  318. function Redstone()
  319.  local x = 1
  320.    
  321.    for i = x, #Draw["state"] do
  322.      if Draw["state"][i] == true then
  323.        rs.setBundledOutput(Draw["side"][i],colors.combine(rs.getBundledOutput(Draw["side"][i]),Draw["OC"][i]))
  324.       elseif Draw["state"][i] == false then
  325.         rs.setBundledOutput(Draw["side"][i],colors.subtract(rs.getBundledOutput(Draw["side"][i]),Draw["OC"][i]))
  326.      end
  327.    end
  328. end
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. while true do
  337. Set()
  338. Max()
  339. MaxRedstone()
  340. sleep(1)
  341. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement