Guest User

startup

a guest
Mar 3rd, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.00 KB | None | 0 0
  1. HUD = peripheral.wrap("left")
  2. monitor = peripheral.wrap("top")
  3. --sfBoiler = peripheral.wrap("solid_fueled_boiler_firebox_0")
  4. lfBoiler = peripheral.wrap("liquid_fueled_boiler_firebox_3")
  5. lfBoiler2 = peripheral.wrap("liquid_fueled_boiler_firebox_4")
  6. lavaTank = peripheral.wrap("steel_tank_valve_1")
  7. ethanolTank = peripheral.wrap("steel_tank_valve_3")
  8. steamTank = peripheral.wrap("steel_tank_valve_2")
  9. steamTurbine = peripheral.wrap("steam_turbine_housing_0")
  10. steamComputer = peripheral.wrap("computer_2")
  11. mfe = peripheral.wrap("batbox_2")
  12. mfsu = peripheral.wrap("batbox_1")
  13. craftingMonitor = peripheral.wrap("me_crafting_monitor_0")
  14.  
  15. steamOn = false
  16.  
  17. rednet.open("bottom")
  18.  
  19. function roundNum(val, decimal)
  20.     if (decimal) then
  21.         return math.floor(((val * 10^decimal) + 0.5) / (10^decimal))
  22.     else
  23.         return math.floor(val+0.5)
  24.     end
  25. end
  26.  
  27.  function drawPixel(x, y, color)
  28.     monitor.setCursorPos(x, y)
  29.     monitor.setBackgroundColor(color)
  30.     monitor.write(" ")
  31.  end
  32.  
  33.  function drawTank(x, y, color, maxLiq, currentLiq, tankName)
  34.        
  35.        if currentLiq == nil then
  36.          currentLiq = 0
  37.        end
  38.        
  39.        if maxLiq == nil then
  40.          maxLiq = 0
  41.        end
  42.        
  43.     percentage = roundNum(((currentLiq / maxLiq) * 100), 0)
  44.        
  45.     for i = 0, 11 do
  46.         drawPixel(x, y + i, colors.white)
  47.         drawPixel(x + 19, y + i, colors.white)
  48.     end
  49.        
  50.     for i = 1, 18 do
  51.         drawPixel(x + i, y + 11, colors.white)
  52.     end
  53.        
  54.     rows =  roundNum((percentage / 10), 0)
  55.        
  56.     for i = 10 - rows, 10 do
  57.         for j = 1, 18 do
  58.                         if tankName == "Lava Tank" then
  59.                                 if math.random(1, 20 - i) == 1 then
  60.                                         if math.random(1, 4) == 1 then
  61.                                                 drawPixel(x + j, y + i, colors.black)
  62.                                         else
  63.                                                 drawPixel(x + j, y + i, colors.orange)
  64.                                         end
  65.                                 else
  66.                                         drawPixel(x + j, y + i, color)
  67.                                 end
  68.                         elseif tankName == "Steam Tank" then
  69.                                 if math.random(1, 20 - i) == 1 then
  70.                                         drawPixel(x + j, y + i, colors.lightGray)
  71.                                 else
  72.                                         drawPixel(x + j, y + i, color)
  73.                                 end
  74.                         else
  75.                                 drawPixel(x + j, y + i, color)
  76.                         end
  77.                 end
  78.         end
  79.    
  80.     monitor.setCursorPos(x, y + 13)
  81.     monitor.setBackgroundColor(colors.black)
  82.     monitor.setTextColor(colors.white)
  83.     monitor.write(tankName .. "  " .. tostring(percentage) .. "%")
  84.     monitor.setCursorPos(x, y + 14)
  85.         monitor.write(tostring(currentLiq) .. "mB / " .. tostring(maxLiq) .. "mB")
  86. end
  87.  
  88. function drawLiqBoiler(x, y, waterCap, waterCur, temp, fuelMax, fuelCurrent, steamMax, steamCurrent, name)
  89.  
  90.  if waterCur == nil then
  91.    waterCur = 0
  92.  end
  93.  
  94.  if waterCap == nil then
  95.    waterCap = 0
  96.  end
  97.  
  98.  if fuelCurrent == nil then
  99.    fuelCurrent = 0
  100.  end
  101.  
  102.  if fuelMax == nil then
  103.    fuelMax = 0
  104.  end
  105.  
  106.  if steamCurrent == nil then
  107.    steamCurrent = 0
  108.  end
  109.  
  110.  if steamMax == nil then
  111.    steamMax = 0
  112.  end
  113.        
  114.         waterPercentage = roundNum(((waterCur / waterCap) * 100), 0)
  115.         fuelPercentage = roundNum(((fuelCurrent / fuelMax) * 100), 0)
  116.         steamPercentage = roundNum(((steamCurrent / steamMax) * 100), 0)
  117.        
  118.         waterRows = roundNum((waterPercentage / 10), 0)
  119.         fuelRows = roundNum((fuelPercentage / 10), 0)
  120.         steamRows = roundNum((steamPercentage / 10), 0)
  121.        
  122.         for i = 2, 13 do
  123.                 drawPixel(x, y + i, colors.white)
  124.         drawPixel(x + 2, y + i, colors.white)
  125.                 drawPixel(x + 5, y + i, colors.white)
  126.         drawPixel(x + 7, y + i, colors.white)
  127.                 drawPixel(x + 10, y + i, colors.white)
  128.         drawPixel(x + 12, y + i, colors.white)
  129.         end
  130.        
  131.         drawPixel(x + 1, y + 13, colors.white)
  132.         drawPixel(x + 6, y + 13, colors.white)
  133.         drawPixel(x + 11, y + 13, colors.white)
  134.        
  135.         for i = 10 - waterRows, 10 do
  136.                 drawPixel(x + 1, y + i + 2, colors.blue)
  137.         end
  138.        
  139.         for i = 10 - fuelRows, 10 do
  140.                 drawPixel(x + 6, y + i + 2, colors.purple)
  141.         end
  142.        
  143.         for i = 10 - steamRows, 10 do
  144.                 drawPixel(x + 11, y + i + 2, colors.gray)
  145.         end
  146.        
  147.        
  148.         monitor.setCursorPos(x, y + 15)
  149.         monitor.setBackgroundColor(colors.black)
  150.         monitor.setTextColor(colors.white)     
  151.         monitor.write("Temp = " .. roundNum(temp, 2))
  152.         monitor.setCursorPos(x, y)
  153.         monitor.write(name)
  154.         monitor.setCursorPos(x + 1, y + 1)
  155.         monitor.setTextColor(colors.blue)
  156.         monitor.write("W")
  157.         monitor.setCursorPos(x + 6, y + 1)
  158.         monitor.setTextColor(colors.purple)
  159.         monitor.write("F")
  160.         monitor.setCursorPos(x + 11, y + 1)
  161.         monitor.setTextColor(colors.gray)
  162.         monitor.write("S")
  163. end
  164.  
  165. function drawMFSU(x, y, mfsuMax, mfsuCurrent)
  166.        
  167.         mfsuPercent = roundNum(((mfsuCurrent / mfsuMax) * 100), 0)
  168.     mfsuCols = roundNum((mfsuPercent / (10 / 3)), 0)
  169.        
  170.        
  171.         drawPixel(x, y + 2, colors.white)
  172.         drawPixel(x + 32, y + 2, colors.white)
  173.        
  174.         for i = 0, 32 do
  175.                 drawPixel(x + i, y + 1, colors.white)
  176.                 drawPixel(x + i, y + 3, colors.white)
  177.         end
  178.        
  179.         for i = 0, mfsuCols do
  180.                 drawPixel(x + 1 + i, y + 2, colors.red)
  181.         end
  182.  
  183.   monitor.setCursorPos(x, y)
  184.   monitor.setBackgroundColor(colors.black)
  185.   monitor.setTextColor(colors.white)
  186.   monitor.write("MFSU - " .. mfsuPercent .. "% (" .. mfsuCurrent .. "EU / " .. mfsuMax .. "EU)")
  187. end
  188.  
  189. function drawMFE(x, y, mfeMax, mfeCurrent)
  190.        
  191.         mfePercent = roundNum(((mfeCurrent / mfeMax) * 100), 0)
  192.     mfeCols = roundNum((mfePercent / (10/3)), 0)
  193.        
  194.        
  195.         drawPixel(x, y + 2, colors.white)
  196.         drawPixel(x + 32, y + 2, colors.white)
  197.        
  198.         for i = 0, 32 do
  199.                 drawPixel(x + i, y + 1, colors.white)
  200.                 drawPixel(x + i, y + 3, colors.white)
  201.         end
  202.        
  203.         for i = 0, mfeCols do
  204.                 drawPixel(x + 1 + i, y + 2, colors.red)
  205.         end
  206.  
  207.   monitor.setCursorPos(x, y)
  208.   monitor.setBackgroundColor(colors.black)
  209.   monitor.setTextColor(colors.white)
  210.   monitor.write("MFE - " .. mfePercent .. "% (" .. mfeCurrent .. "EU / " .. mfeMax .. "EU)")
  211.  
  212. end
  213.  
  214. while true do
  215.         monitor.clear()
  216.         HUD.clear()
  217.  
  218.         drawTank(2, 2, colors.red, lavaTank.getTanks("unknown")[1].capacity, lavaTank.getTanks("unknown")[1].amount, "Lava Tank")
  219.         drawTank(26, 2, colors.purple, ethanolTank.getTanks("unknown")[1].capacity, ethanolTank.getTanks("unknown")[1].amount, "BioFuel Tank")
  220.         drawTank(50, 2, colors.gray, steamTank.getTanks("unknown")[1].capacity, steamTank.getTanks("unknown")[1].amount, "Steam Tank")
  221.        
  222.         drawLiqBoiler(2, 20, lfBoiler.getTanks("unknown")[1].capacity, lfBoiler.getTanks("unknown")[1].amount, lfBoiler.getTemperature(), lfBoiler.getTanks("unknown")[3].capacity, lfBoiler.getTanks("unknown")[3].amount, lfBoiler.getTanks("unknown")[2].capacity, lfBoiler.getTanks("unknown")[2].amount, "Boiler 1")
  223.         drawLiqBoiler(19, 20, lfBoiler2.getTanks("unknown")[1].capacity, lfBoiler2.getTanks("unknown")[1].amount, lfBoiler2.getTemperature(), lfBoiler2.getTanks("unknown")[3].capacity, lfBoiler2.getTanks("unknown")[3].amount, lfBoiler2.getTanks("unknown")[2].capacity, lfBoiler2.getTanks("unknown")[2].amount, "Boiler 2")
  224.        
  225.         drawMFSU(36, 20, mfsu.getCapacity(), mfsu.getStored())
  226.         drawMFE(36, 26, mfe.getCapacity(), mfe.getStored())
  227.                
  228.         sleep(1)
  229. end
Add Comment
Please, Sign In to add comment