Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A very simple program, Not sure if it's what you wanted. You do require the newest version of openPeripheral for this to work.
- redstoneSide = "right" -- Where to output redstone signal
- redstoneState = true -- What state to put the redstone in when the chosen limit hits
- energyPercent = 90 -- 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
- rs.setOutput(redstoneSide, redstoneState)
- else
- rs.setOutput(redstoneSide, not redstoneState)
- end
- sleep(reCheckTimer)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement