Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- energyPercent = 50 -- what percentage to react on
- reCheckTimer = 5 -- How many seconds to wait before it checks again
- EnergyCellSide = "left" -- Which side of the computer the energy cell is on
- enCell = peripheral.wrap(EnergyCellSide)
- function getEnergy()
- return enCell.getEnergyStored("unknown")
- end
- function getMaxEnergy()
- return enCell.getMaxEnergyStored("unkown")
- end
- function getEnergyPercent()
- return math.floor(getEnergy()/getMaxEnergy()*100)
- end
- while true do
- if getEnergyPercent() >= energyPercent then
- print ("yes")
- else
- print ("no")
- end
- sleep(reCheckTimer)
- end
Advertisement
Add Comment
Please, Sign In to add comment