Cavious

TankMonitor

Jun 11th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.86 KB | None | 0 0
  1. --[[
  2. GENERAL INFORMATION
  3. ===================
  4. FILE NAME: thermalMonitor.lua
  5. CREATED BY: Cavious(Donald R. Valverde)
  6. LICENSE: Open-Source(MIT) License
  7. VERSION: 0.1-ALPHA
  8. ====================
  9. Requirements
  10. ------------
  11. (1)Minecraft(1.64+)
  12. (2)ComputerCraft Mod(1.6+)
  13. (3)IndustrialCraft(2+)
  14. (4)Advanced Computer Terminal
  15. (5)Advanced Monitor
  16. (6)Wired RedNet Connection
  17. (7)Thermal Generator
  18. --]]
  19.  
  20. --User Variables
  21. firstMonitorPos = "" --ENTER THE DIRECTION OF THE MONITOR
  22. secondMonitorPos = "" --ENTER THE DIRECTION OF THE MONITOR
  23. thirdMonitorPos = "" --ENTER THE DIRECTION OF THE MONITOR
  24. ----------------
  25.  
  26. monOne = peripheral.wrap(firstMonitorPos)
  27. monTwo = peripheral.wrap(secondMonitorPos)
  28. monThree = peripheral.wrap(thirdMonitorPos)
  29.  
  30. function initializeBackgrounds()
  31.     --Initialize monOne
  32.     term.redirect(monOne)
  33.     barGraph = paintutils.loadImage(".backgroundTop")
  34.     paintutils.drawImage(barGraph, 1, 1)
  35.     term.native()
  36.    
  37.     --Initialize monTwo
  38.     term.redirect(monTwo)
  39.     controls = paintutils.loadImage(".backgroundLeft")
  40.     paintutils.drawImage(controls, 1, 1)
  41.     term.native()
  42. end
  43.  
  44. function initializeText()
  45.  
  46.    
  47.     --monOne Formatting
  48.    
  49.     --monOne Titles Formats
  50.     monOne.setBackgroundColor(colors.gray)
  51.     monOne.setTextColor(colors.white)
  52.    
  53.     --monOne Title Text
  54.     monOne.setCursorPos(18,2)
  55.     monOne.write("Thermal Monitoring")
  56.     monOne.setBackgroundColor(colors.lightGray)
  57.     monOne.setCursorPos(3,3)
  58.     monOne.write("CURRENT AMOUNT(mB)")
  59.     monOne.setCursorPos(28,3)
  60.     monOne.write("MAXIMUM(mB)")
  61.    
  62.    
  63.     --monOne
  64.    
  65.     --Process Data
  66.     while(true) do
  67.         local amount, maximum = getValues()
  68.        
  69.         monOne.setCursorPos(3, 4)
  70.         monOne.setBackgroundColor(colors.black)
  71.         monOne.setTextColor(colors.white)
  72.         monOne.write(amount)
  73.        
  74.         monOne.setCursorPos(28, 4)
  75.         monOne.setBackgroundColor(colors.black)
  76.         monOne.setTextColor(colors.white)
  77.         monOne.write(maximum)
  78.        
  79.         term.redirect(monOne)
  80.         paintutils.drawLine(2, 8, (amount/maximum) * 40, 8, colors.orange)
  81.         paintutils.drawLine(2, 9, (amount/maximum) * 40, 9, colors.orange)
  82.         term.native()
  83.        
  84.         os.sleep(1)
  85.     end
  86. end
  87.  
  88. function getValues()
  89.     local valve = peripheral.wrap("rcirontankvalvetile_3")
  90.     local tableInfo = valve.getTankInfo("down")
  91.    
  92.     local curAmount = 0
  93.     local maximum = 0
  94.  
  95.     for k, v in pairs(tableInfo) do
  96.         for x, y in pairs(v) do
  97.             if x == "amount" then
  98.                 term.redirect(monThree)
  99.                 print(x..": "..y)
  100.                 term.native()
  101.                 curAmount = y
  102.             end
  103.             if x == "capacity" then
  104.                 term.redirect(monThree)
  105.                 print(x..": "..y)
  106.                 term.native()
  107.                 maximum = y
  108.             end
  109.         end
  110.     end
  111.    
  112.     return curAmount, maximum
  113. end
  114.  
  115. function run()
  116.     monOne.clear()
  117.     monTwo.clear()
  118.    
  119.     monOne.setTextScale(0.5)
  120.     monTwo.setTextScale(0.5)
  121.     monThree.setTextScale(0.5)
  122.    
  123.     monThree.setBackgroundColor(colors.lightGray)
  124.    
  125.     initializeBackgrounds()
  126.    
  127.     initializeText()
  128. end
  129.  
  130. run()
Advertisement
Add Comment
Please, Sign In to add comment