Advertisement
Guest User

power1

a guest
Jul 23rd, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1.  
  2. --Energy Monitor
  3.  
  4. --Energy Cells
  5. cells = {
  6.     peripheral.wrap("cofh_thermalexpansion_energycell_19"),
  7.     peripheral.wrap("cofh_thermalexpansion_energycell_20")
  8. }
  9.  
  10. --Max Energy
  11. function getMaxEnergy(Str)
  12.     return cells[Str].getMaxEnergyStored("unknown")
  13. end
  14.  
  15. --Stored Energy
  16. function getStoredEnergy(Str)
  17.     return cells[Str].getEnergyStored("unknown")
  18. end
  19.  
  20. --Percentage
  21. function percent(minVal,maxVal)
  22.     return math.floor((minVal/maxVal)*100)
  23. end
  24.  
  25. --Monitor
  26. monitor= peripheral.wrap("top")
  27. monitor.setTextScale(0.5)
  28. monitor.setBackgroundColor(colors.white)
  29. monitor.clear()
  30. monitor.setBackgroundColor(colors.white)
  31. monitor.setTextColor(colors.black)
  32.  
  33. --Cursor
  34.  
  35. function Cursor()
  36.   local oldX, oldY = monitor.getCursorPos()
  37.   return oldY
  38.   monitor.setCursorPos(1, oldY+1)
  39. end
  40.  
  41. --Redstone Operator
  42. full1 = false
  43. full2 = false
  44.  
  45. --Loop Body
  46. while true do
  47.     for i=1, 2 do
  48.   monitor.write("Cell# "..i)
  49.   Cursor()
  50.         monitor.write("     > Capacity:"..getMaxEnergy(i))
  51.   Cursor()
  52.   monitor.write("     > Stored:  "..getStoredEnergy(i))
  53.   Cursor()
  54.   monitor.write("     > Percent: "..percent(getStoredEnergy(i),getMaxEnergy(i)).."%")
  55.   Cursor()
  56.   monitor.write("------")
  57.   Cursor()
  58.   sleep(1)
  59.   if getStoredEnergy(i) == getMaxEnergy(i) and i==1 then
  60.     full1=true
  61.   elseif getStoredEnergy(i) == getMaxEnergy(i) and i==2 then
  62.     full2=true
  63.   end
  64.   if full1==true and full2==true then
  65.     peripheral.wrap("right")
  66.     rs.setBundledOutput("right", 1)
  67.   else
  68.     rs.setBundledOutput("right", 4)
  69.   end
  70.  end
  71. sleep(10)
  72. term.clear()
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement