Advertisement
defyuse

Energy Core Computercraft

Aug 23rd, 2019
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. modem = peripheral.wrap("left")
  2. modem.open(1)
  3.  
  4. mon = peripheral.wrap("right")
  5. monX, monY = mon.getSize()
  6.  
  7. local prevEnergyStored = 0
  8. local diff = 0
  9.  
  10. max = modem.callRemote("draconic_rf_storage_3", "getMaxEnergyStored")
  11. current = modem.callRemote("draconic_rf_storage_3", "getEnergyStored")
  12.  
  13. print(current)
  14. print(max)
  15.  
  16.  
  17.  
  18. function drawLine(x, y, length, size, color_bar)
  19. for yPos = y, y+size-1 do
  20. mon.setBackgroundColor(color_bar)
  21. mon.setCursorPos(x, yPos)
  22. mon.write(string.rep(" ", length))
  23. end
  24. end
  25.  
  26. function drawProg(x, y, length, size, minVal, maxVal)
  27. drawLine(x, y, length, size, colors.gray)
  28. local barSize = math.floor((minVal/maxVal)*length)
  29. drawLine(x, y, barSize, size, colors.green)
  30. end
  31.  
  32. while true do
  33.  
  34. mon.clear()
  35. drawProg(25, monY-5, monX-27, 4, current, max)
  36.  
  37. max = modem.callRemote("draconic_rf_storage_3", "getMaxEnergyStored")
  38. current = modem.callRemote("draconic_rf_storage_3", "getEnergyStored")
  39. percent = current/max*100
  40. diff = (current - prevEnergyStored)/20
  41.  
  42. mon.setCursorPos(25, monY-7)
  43. mon.setBackgroundColor(colors.black)
  44. mon.write("["..math.floor(percent).."%]")
  45. if (diff > 0) then
  46. mon.setCursorPos(2, monY-5)
  47. mon.setBackgroundColor(colors.black)
  48. mon.write("Avg. RF/t: +"..math.floor(diff))
  49. else
  50. mon.setCursorPos(2, monY-5)
  51. mon.setBackgroundColor(colors.black)
  52. mon.write("Avg. RF/t: "..math.floor(diff))
  53. end
  54. prevEnergyStored = current
  55. os.sleep(1)
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement