Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- redstoneSide = "right" -- Where to output redstone signal
- redstoneState = true -- What state to put the redstone in when the chosen limit hits
- energyPercent = 10 -- 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)
- mon = peripheral.wrap("top")
- function getEnergy()
- return enCell.getEnergyStored("unknown")
- end
- function getMaxEnergy()
- return enCell.getMaxEnergyStored("unknown")
- end
- function getEnergyPercent()
- return math.floor(getEnergy()/getMaxEnergy()*100)
- end
- while true do
- power = getEnergyPercent()
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write(power)
- if power < energyPercent then
- rs.setOutput(redstoneSide, redstoneState)
- mon.setCursorPos(1,2)
- mon.write("ON")
- else
- rs.setOutput(redstoneSide, not redstoneState)
- mon.setCursorPos(1,2)
- mon.write("OFF")
- end
- sleep(reCheckTimer)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement