Advertisement
Guest User

startup

a guest
Apr 11th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1. mon    = peripheral.wrap("monitor_10")
  2. power1 = peripheral.wrap("draconic_rf_storage_6")
  3. power2 = peripheral.wrap("draconic_rf_storage_7")
  4. power3 = peripheral.wrap("draconic_rf_storage_8")
  5. power4 = peripheral.wrap("draconic_rf_storage_9")
  6.  
  7. local maxpower1 = 0
  8. local maxpower2 = 0
  9. local maxpower3 = 0
  10. local maxpower4 = 0
  11. local maxpower  = 0
  12. local curpower1 = 0
  13. local curpower2 = 0
  14. local curpower3 = 0
  15. local curpower4 = 0
  16. local curpower  = 0
  17. local perpower = 0
  18. monX, monY = mon.getSize()
  19. local length = 0
  20.  
  21. function checkPower()
  22.   maxpower1 = power1.getMaxEnergyStored()
  23.   maxpower2 = power2.getMaxEnergyStored()
  24.   maxpower3 = power3.getMaxEnergyStored()
  25.   maxpower4 = power4.getMaxEnergyStored()
  26.   curpower1 = power1.getEnergyStored()
  27.   curpower2 = power2.getEnergyStored()
  28.   curpower3 = power3.getEnergyStored()
  29.   curpower4 = power4.getEnergyStored()
  30.   maxpower = maxpower1+maxpower2+maxpower3+maxpower4
  31.   curpower = curpower1+curpower2+curpower3+curpower4
  32.   perpower = math.floor((((curpower)/(maxpower))*100)+0.5)
  33. end
  34.  
  35. function writemon()
  36.   mon.setBackgroundColor(colors.black)
  37.   mon.clear()
  38.   mon.setCursorPos(1,1)
  39.   -- mon.write("power")
  40.   header ="  Draconic Evolution  "
  41.   centerT(header, 1, colors.lightGray, colors.blue)
  42.   title = "  Energie:  "..perpower.."%  Voll  "
  43.   centerT(title, 2, colors.lightGray, colors.blue)
  44.   mon.setCursorPos(2,1)
  45.   jetztE = "Jetzige Energie:  "..(curpower).."RF  "
  46.   centerT(jetztE, 3, colors.lightGray, colors.blue)
  47.   mon.setCursorPos(3,1)
  48.   maxE = "Maximale Energie:  "..(maxpower).."RF  "
  49.   centerT(maxE, 4, colors.lightGray, colors.blue)
  50.   end
  51.  
  52. function centerT(texty, liney, backColor, txtColor)
  53.   mon.setBackgroundColor(backColor)
  54.   mon.setTextColor(txtColor)
  55.   length = string.len(texty)
  56.   dif = math.floor(monX-length)
  57.   x = math.floor(dif/2)
  58.   mon.setCursorPos(x+1,liney)
  59.   mon.write(texty)
  60. end
  61.  
  62. function drawBar()
  63.   bar = math.floor(((curpower/maxpower)*(monX-2))+0.5)
  64.   mon.setCursorPos(2,monY-2)
  65.   mon.setBackgroundColor(colors.lightGray)
  66.   mon.write(string.rep(" ", monX-2))
  67.   mon.setCursorPos(2, monY-3)
  68.   mon.setBackgroundColor(colors.lightGray)
  69.   mon.write(string.rep(" ",monX-2))
  70.   mon.setCursorPos(2, monY-2)
  71.   mon.setBackgroundColor(colors.red)
  72.   mon.write(string.rep(" ", bar))
  73.   mon.setCursorPos(2, monY-3)
  74.   mon.setBackgroundColor(colors.red)
  75.   mon.write(string.rep(" ", bar))
  76. end
  77.  
  78. while true do
  79.   checkPower()
  80.   writemon()
  81.   drawBar()
  82.   print(curpower.."/"..maxpower)
  83.   sleep(1)
  84.  end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement