Advertisement
Guest User

Monitor-Program

a guest
Mar 7th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.71 KB | None | 0 0
  1. local mon = peripheral.wrap("right")
  2. local net = peripheral.wrap("left")
  3. local cube = peripheral.wrap("mekanism_machine_1")
  4. local monx, mony = mon.getSize()
  5. os.loadAPI("bundleAPI")
  6. net.open(11)
  7. mon.clear()
  8. --%%%%%%%%config%%%%%%%%%--
  9. --Bar Position
  10. local barx = 1
  11. local bary = 19
  12. --%%%%%%%%%%%%%%%%%%%%%%%--
  13.   mon.setCursorPos(1,1)
  14.   mon.setTextColor(colors.blue)
  15.   mon.write("Quarry:  ")
  16.   mon.setCursorPos(1,3)
  17.   mon.write("Reaktor: ")
  18.   mon.setCursorPos(1,5)
  19.   mon.write("AutoReaktor: ")
  20.   mon.setCursorPos(1,7)
  21.   mon.write("Farm: ")
  22.   mon.setCursorPos(1,9)
  23.   mon.write("XP-Farm: ")
  24.   mon.setCursorPos(1,17)
  25.   mon.write("Energy-Status: ")
  26.  
  27.  
  28.   mon.setBackgroundColor(8)
  29.   mon.setTextColor(colors.white)
  30.   mon.setCursorPos(1,2)
  31.   mon.write("        <>        ")
  32.   mon.setCursorPos(1,4)
  33.   mon.write("        <>        ")
  34.   mon.setCursorPos(1,6)
  35.   mon.write("        <>        ")  
  36.   mon.setCursorPos(1,8)
  37.   mon.write("        <>        ")  
  38.   mon.setCursorPos(1,10)
  39.   mon.write("        <>        ")  
  40.   mon.setBackgroundColor(colors.black)
  41.  function round(num, idp)
  42.   local mult = 10^(idp or 0)
  43.   return math.floor(num * mult + 0.5) / mult
  44.   end
  45. while true do
  46. Reaktor = peripheral.wrap("BigReactors-Reactor_1").getActive()
  47.  if bundleAPI.getInput("bottom", "white") == true then --Quarry
  48.     mon.setTextColor(colors.green)
  49.     mon.setBackgroundColor(colors.green)
  50.     mon.setCursorPos(17,1)
  51.     mon.write("---")
  52.     mon.setBackgroundColor(colors.black)
  53.     mon.setCursorPos(14,1)
  54.     mon.write(" AN")
  55.     net.transmit(11,12, "Quarryan")
  56.   elseif bundleAPI.getInput("bottom", "white") == false then
  57.     mon.setTextColor(colors.red)
  58.     mon.setBackgroundColor(colors.red)
  59.     mon.setCursorPos(17,1)
  60.     mon.write("---")
  61.     mon.setBackgroundColor(colors.black)
  62.     mon.setCursorPos(14,1)
  63.     mon.write("AUS")
  64.     net.transmit(11,13, "Quarryaus")
  65.   end
  66.  
  67. if Reaktor == true then
  68.     mon.setTextColor(colors.green)
  69.     mon.setBackgroundColor(colors.green)
  70.     mon.setCursorPos(17,3)
  71.     mon.write("---")
  72.     mon.setBackgroundColor(colors.black)
  73.     mon.setCursorPos(14,3)
  74.     mon.write(" AN")
  75.     net.transmit(11,14, "Reaktoran")
  76. elseif Reaktor == false then
  77.     mon.setTextColor(colors.red)
  78.     mon.setBackgroundColor(colors.red)
  79.     mon.setCursorPos(17,3)
  80.     mon.write("---")
  81.     mon.setBackgroundColor(colors.black)
  82.     mon.setCursorPos(14,3)
  83.     mon.write("AUS")
  84.     net.transmit(11,15, "Reaktoraus")
  85. end
  86.  
  87.  
  88.  
  89.  
  90.   if bundleAPI.getInput("bottom", "green") == true then --ReaktorPC
  91.     mon.setTextColor(colors.green)
  92.     mon.setBackgroundColor(colors.green)
  93.     mon.setCursorPos(17,5)
  94.     mon.write("---")
  95.     mon.setBackgroundColor(colors.black)
  96.    
  97.     mon.setBackgroundColor(colors.gray)
  98.     mon.setTextColor(colors.white)
  99.     mon.setCursorPos(1,4)
  100.     mon.write("        <>        ")  
  101.     mon.setBackgroundColor(colors.black)
  102.     mon.setTextColor(colors.green)
  103.     mon.setCursorPos(14,5)
  104.     mon.write(" AN")
  105.     net.transmit(11,16, "Reaktorpcan")
  106.   elseif bundleAPI.getInput("bottom", "green") == false then
  107.     mon.setTextColor(colors.red)
  108.     mon.setBackgroundColor(colors.red)
  109.     mon.setCursorPos(17,5)
  110.     mon.write("---")
  111.     mon.setBackgroundColor(colors.black)
  112.     mon.setBackgroundColor(8)
  113.     mon.setTextColor(colors.white)
  114.     mon.setCursorPos(1,4)
  115.     mon.write("        <>        ")  
  116.     mon.setBackgroundColor(colors.black)
  117.     mon.setTextColor(colors.red)
  118.     mon.setCursorPos(14,5)
  119.     mon.write("AUS")
  120.     net.transmit(11,17, "Reaktorpcaus")
  121.   end
  122.  
  123. if bundleAPI.getInput("bottom", "blue") == true then --Quarry
  124.     mon.setTextColor(colors.green)
  125.     mon.setBackgroundColor(colors.green)
  126.     mon.setCursorPos(17,7)
  127.     mon.write("---")
  128.     mon.setBackgroundColor(colors.black)
  129.     mon.setCursorPos(14,7)
  130.     mon.write(" AN")
  131.     net.transmit(11,18, "Farman")
  132.   elseif bundleAPI.getInput("bottom", "blue") == false then
  133.     mon.setTextColor(colors.red)
  134.     mon.setBackgroundColor(colors.red)
  135.     mon.setCursorPos(17,7)
  136.     mon.write("---")
  137.     mon.setBackgroundColor(colors.black)
  138.     mon.setCursorPos(14,7)
  139.     mon.write("AUS")
  140.     net.transmit(11,19, "Farmaus")
  141. end
  142.  
  143. if bundleAPI.getInput("bottom", "red") == true then --Quarry
  144.     mon.setTextColor(colors.green)
  145.     mon.setBackgroundColor(colors.green)
  146.     mon.setCursorPos(17,9)
  147.     mon.write("---")
  148.     mon.setBackgroundColor(colors.black)
  149.     mon.setCursorPos(14,9)
  150.     mon.write(" AN")
  151.     net.transmit(11,20, "Xpfarman")
  152.   elseif bundleAPI.getInput("bottom", "red") == false then
  153.     mon.setTextColor(colors.red)
  154.     mon.setBackgroundColor(colors.red)
  155.     mon.setCursorPos(17,9)
  156.     mon.write("---")
  157.     mon.setBackgroundColor(colors.black)
  158.     mon.setCursorPos(14,9)
  159.     mon.write("AUS")
  160.     net.transmit(11,21, "Xpfarmaus")
  161. end
  162.  
  163.  
  164.  
  165.  
  166. --%%%%%%%%%%%%%%%%%%%%%%%%--
  167.     a = cube.getEnergyStored()
  168.     b = cube.getMaxEnergy()
  169.     c = a/b*100
  170.    
  171.     monx, mony = mon.getSize()
  172.     length = monx/10
  173.    
  174.    
  175.     if c > 0 and c <= 10 then
  176.         mon.setCursorPos(1,bary)
  177.         mon.setBackgroundColor(colors.red)
  178.         mon.write(string.rep(" ", 1*length))
  179.         mon.setCursorPos(length,bary)
  180.         mon.setBackgroundColor(colors.black)
  181.         mon.write(string.rep(" ", monx-1*length))
  182.     end
  183.     if c > 10 and c <= 20 then
  184.         mon.setCursorPos(1,bary)
  185.         mon.setBackgroundColor(colors.red)
  186.         mon.write(string.rep(" ", 2*length))
  187.         mon.setCursorPos(2*length,bary)
  188.         mon.setBackgroundColor(colors.black)
  189.         mon.write(string.rep(" ", monx-2*length))
  190.     end
  191.     if c > 20 and c <= 30 then
  192.         mon.setCursorPos(1,bary)
  193.         mon.setBackgroundColor(colors.orange)
  194.         mon.write(string.rep(" ", 3*length))
  195.         mon.setCursorPos(3*length,bary)
  196.         mon.setBackgroundColor(colors.black)
  197.         mon.write(string.rep(" ", monx-3*length))
  198.     end
  199.     if c > 30 and c <= 40 then
  200.         mon.setCursorPos(1,bary)
  201.         mon.setBackgroundColor(colors.orange)
  202.         mon.write(string.rep(" ", 4*length))
  203.         mon.setCursorPos(4*length,bary)
  204.         mon.setBackgroundColor(colors.black)
  205.         mon.write(string.rep(" ", monx-4*length))
  206.     end
  207.     if c > 40 and c <= 50 then
  208.         mon.setCursorPos(1,bary)
  209.         mon.setBackgroundColor(colors.orange)
  210.         mon.write(string.rep(" ", 5*length))
  211.         mon.setCursorPos(5*length,bary)
  212.         mon.setBackgroundColor(colors.black)
  213.         mon.write(string.rep(" ", monx-5*length))
  214.     end
  215.     if c > 50 and c <= 60 then
  216.         mon.setCursorPos(1,bary)
  217.         mon.setBackgroundColor(colors.lime)
  218.         mon.write(string.rep(" ", 6*length))
  219.         mon.setCursorPos(6*length,bary)
  220.         mon.setBackgroundColor(colors.black)
  221.         mon.write(string.rep(" ", monx-6*length))
  222.     end
  223.     if c > 60 and c <= 70 then
  224.         mon.setCursorPos(1,bary)
  225.         mon.setBackgroundColor(colors.lime)
  226.         mon.write(string.rep(" ", 7*length))
  227.         mon.setCursorPos(7*length,bary)
  228.         mon.setBackgroundColor(colors.black)
  229.         mon.write(string.rep(" ", monx-7*length))
  230.     end
  231.     if c > 70 and c <= 80 then
  232.         mon.setCursorPos(1,bary)
  233.         mon.setBackgroundColor(colors.lime)
  234.         mon.write(string.rep(" ", 8*length))
  235.         mon.setCursorPos(8*length,bary)
  236.         mon.setBackgroundColor(colors.black)
  237.         mon.write(string.rep(" ", monx-8*length))
  238.     end
  239.     if c > 80 and c <= 90 then
  240.         mon.setCursorPos(1,bary)
  241.         mon.setBackgroundColor(colors.lime)
  242.         mon.write(string.rep(" ", 9*length))
  243.         mon.setCursorPos(9*length,bary)
  244.         mon.setBackgroundColor(colors.black)
  245.         mon.write(string.rep(" ", monx-9*length))
  246.     end
  247.     if c > 90 and c <= 100 then
  248.         mon.setCursorPos(1,bary)
  249.         mon.setBackgroundColor(colors.lime)
  250.         mon.write(string.rep(" ", 10*length))
  251.         mon.setBackgroundColor(colors.black)
  252.        
  253.     end
  254.     if c >= 0 and c <=33.99 then
  255.         mon.setTextColor(colors.red)
  256.         elseif c>=34 and c<= 66.99 then
  257.             mon.setTextColor(colors.orange)
  258.             elseif c>= 67 and c<= 100 then
  259.                 mon.setTextColor(colors.lime)
  260.     end
  261.     mon.setCursorPos(7,bary-1)
  262.     mon.write(round(c, 2))
  263.     mon.setCursorPos(13,bary-1)
  264.     mon.write("%")
  265.     net.transmit(11,22,c)
  266. mon.setBackgroundColor(colors.black)
  267.  
  268. sleep(0.5)
  269. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement