Advertisement
AnonGaming

Untitled

Mar 6th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. local eio = peripheral.find("tile_blockcapacitorbank_name")
  2. local m = peripheral.wrap("top")
  3.  
  4.  
  5. function drawBar(val,x,y)
  6.  
  7. local blockCols = {}
  8. blockCols[1] = colors.red
  9. blockCols[2] = colors.red
  10. blockCols[3] = colors.red
  11. blockCols[4] = colors.red
  12. blockCols[5] = colors.yellow
  13. blockCols[6] = colors.yellow
  14. blockCols[7] = colors.yellow
  15. blockCols[8] = colors.green
  16. blockCols[9] = colors.green
  17. blockCols[10] = colors.green
  18.  
  19. for i = 1,10 do
  20. if i <= val then
  21. m.setBackgroundColor(blockCols[i])
  22. m.setCursorPos(x,Y)
  23. m.write(" ")
  24. else
  25. m.setBackgroundColor(colors.black)
  26. m.setCursorPos(x,y)
  27. m.write(" ")
  28. end
  29.  
  30. y = y - 1
  31. end
  32.  
  33. end
  34.  
  35. function formatPlace(val,digits)
  36. local shift = 10 ^ digits
  37. result = math.floor(val * shift + 0.5) / shift
  38. return result
  39. end
  40.  
  41. function fromatVal(val)
  42.  
  43. local mil = val / 1000000
  44. local thous = val / 1000
  45.  
  46. if mil > 0 then
  47. return formatPlace(mil,1).."M"
  48. end
  49.  
  50. if thous > 0 then
  51. return formatPlace(thous,1).."M"
  52. end
  53. end
  54.  
  55.  
  56.  
  57. function draw()
  58.  
  59. local bankStored = eio.getEnergyStored()
  60. local bankMax - eio.getMaxEnergyStored()
  61.  
  62. local s = bankStored / bankMax
  63. local s = s * 10
  64.  
  65. local barNum = math.ceil(s)
  66.  
  67. drawBar(s,35,12)
  68.  
  69.  
  70.  
  71.  
  72. end
  73.  
  74.  
  75.  
  76.  
  77. while true do
  78. draw()
  79. sleep(1)
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement