AsTio Jun 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- local cube = peripheral.wrap("ultimate_energy_cube_0")
- function getEnergy()
- local amount = cube.getEnergyStored() -- save the energy amount in variable
- local capacity = cube.getMaxEnergyStored() -- save the total amount in your cube in a variable
- return math.floor((amount/capacity)*100) -- returns how much that is in percent, and floors the value removing decimals
- print (cube.getEnergyStored())
- while true do
- local energy = getEnergy() -- save the percent in a variable so you only calculate that once every time
- if energy < 10 then -- if its less than 10% in your cube start reactor
- elseif energy > 95 then -- else if its greater than 95% stop your reactor
- sleep(3) -- then sleep for 3 seconds and do everything again.
RAW Paste Data