Advertisement
colhaydutu

ENERGYCUBE

Oct 14th, 2023 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. print ("By colhaydutu /ps colhaydutu")
  2. print("Setup")
  3.  
  4. print("Place wired modem back side of the computer")
  5.  
  6. print("Place wired modem any side of the ic2 battery (like pesu, mfe, msfu, batbox) but it must be block modem")
  7.  
  8. print("Right click all modems for connect")
  9.  
  10. print("Place monitors 2x4 like this and place modem back side of any monitor (yellows are monitors , red is computer)")
  11.  
  12.  
  13. paintutils.drawPixel(10, 16, colors.yellow)
  14. paintutils.drawPixel(12, 16, colors.yellow)
  15. paintutils.drawPixel(14, 16, colors.yellow)
  16. paintutils.drawPixel(16, 16, colors.yellow)
  17.  
  18. paintutils.drawPixel(8, 18, colors.red)
  19. paintutils.drawPixel(10 , 18, colors.yellow)
  20. paintutils.drawPixel(12 , 18, colors.yellow)
  21. paintutils.drawPixel(14 , 18, colors.yellow)
  22. paintutils.drawPixel(16 , 18, colors.yellow)
  23.  
  24. local function findMonitors()
  25. local monitors = {}
  26. for _, name in pairs(peripheral.getNames()) do
  27. if string.match(name, "^monitor_") then
  28. local monitor = peripheral.wrap(name)
  29. table.insert(monitors, monitor)
  30. end
  31. end
  32. return monitors
  33. end
  34.  
  35. local monitors = findMonitors()
  36.  
  37. local monitor = monitors[1] -- İlk bulunan monitörü kullan
  38. local modem = peripheral.wrap("back")
  39. modem.open(11)
  40.  
  41. local function drawBar(monitor, x, y, width, fillPercentage)
  42. local w, h = monitor.getSize()
  43. term.redirect(monitor)
  44. paintutils.drawLine(3, 3, 4, 3, colors.orange)
  45. paintutils.drawLine(13, 3, w - 2, 3, colors.orange)
  46. paintutils.drawLine(3, 3, 3, h - 1, colors.orange)
  47. paintutils.drawLine(w - 2, 3, w - 2, h - 1, colors.orange)
  48. paintutils.drawLine(w - 2, h - 1, 3, h - 1, colors.orange)
  49.  
  50. monitor.setBackgroundColor(colors.gray)
  51. monitor.setTextColor(colors.black)
  52. monitor.setCursorPos(6, 3)
  53. monitor.write("[INFO]")
  54.  
  55. local fillWidth = math.floor(width * fillPercentage)
  56.  
  57. monitor.setBackgroundColor(colors.gray)
  58. monitor.setTextColor(colors.black)
  59.  
  60. monitor.setCursorPos(x, y)
  61. monitor.write("[ ")
  62.  
  63. for i = 1, width do
  64. if i <= fillWidth then
  65. monitor.setBackgroundColor(colors.green)
  66. monitor.write(" ")
  67. else
  68. monitor.setBackgroundColor(colors.red)
  69. monitor.write(" ")
  70. end
  71. end
  72.  
  73. monitor.setBackgroundColor(colors.gray)
  74. monitor.write(" ] " .. math.floor(fillPercentage * 100) .. "%")
  75. end
  76.  
  77. local battery
  78. for _, name in pairs(peripheral.getNames()) do
  79. if string.match(name, "^Elite") then
  80. battery = peripheral.wrap(name)
  81. break
  82. end
  83. end
  84.  
  85. if not battery then
  86. print("IC2 battery not found. Please use modem and right-click on it to connect.")
  87. return
  88. end
  89.  
  90. local previousEnergy = battery.getEnergyStored()
  91. local enerji = battery.getEnergyStored()
  92. while true do
  93. local totalEnergy = battery.getEnergyStored()
  94. local totalCapacity = battery.getEnergyCapacity()
  95. local capPercentage = totalCapacity > 0 and totalEnergy / totalCapacity or 0
  96.  
  97. local energyUsed = previousEnergy - totalEnergy
  98. previousEnergy = totalEnergy
  99.  
  100. local enerjigiris = totalEnergy - enerji
  101. enerji = totalEnergy
  102.  
  103. monitor.clear()
  104. drawBar(monitor, 5, 7, 20, capPercentage)
  105.  
  106. monitor.setCursorPos(5, 5)
  107. monitor.setBackgroundColor(colors.gray)
  108. monitor.setTextColor(colors.black)
  109. monitor.write("Energy: " .. (totalEnergy / 1000) .. " K RF")
  110.  
  111. monitor.setCursorPos(5, 9)
  112. monitor.write("Energy Used: " .. (energyUsed / 1000) .. " K RF")
  113.  
  114. monitor.setCursorPos(5, 10)
  115. monitor.write("Energy Production: " .. (enerjigiris / 1000) .. " K RF")
  116.  
  117. os.sleep(1)
  118.  
  119. end
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement