Advertisement
crunchymetal

batteryTender

Apr 29th, 2025
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. -- Ensure the peripheral API is enabled
  2. local energyCube = peripheral.wrap("bottom") -- Wrap the Mekanism Energy Cube on the bottom side
  3.  
  4. if not energyCube then
  5.     error("No Mekanism Energy Cube found below the computer!")
  6. end
  7.  
  8. while true do
  9.     -- Get the current energy level and the maximum energy capacity
  10.     local energy = energyCube.getEnergy()
  11.     local maxEnergy = energyCube.getMaxEnergy()
  12.  
  13.     -- Calculate the energy percentage
  14.     local energyPercentage = (energy / maxEnergy) * 100
  15.  
  16.     if energyPercentage < 10 then
  17.         -- Turn on the redstone signal to the side
  18.         redstone.setOutput("left", true)
  19.     elseif energyPercentage > 95 then
  20.         -- Turn off the redstone signal to the side
  21.         redstone.setOutput("left", false)
  22.     end
  23.  
  24.     -- Wait for a short period before checking again
  25.     sleep(5)
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement