Advertisement
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
- end
- 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
- print("1")
- elseif energy > 95 then -- else if its greater than 95% stop your reactor
- print("2)
- end
- sleep(3) -- then sleep for 3 seconds and do everything again.
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement