Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- if low energy buffer, output a redstone signal
- -- settings
- local outputSide = "left" -- output restone signal to this side
- local tankSide = "front" -- the tank must be on this side of the computer
- local maxEn = 14000
- local buffer = maxEn/2
- local defaultRsState = true
- -- setup
- local gen = peripheral.wrap(tankSide)
- while true do
- sleep(1)
- local energy = 0
- local tankDetected = pcall(
- function()
- energy = gen.tanks()[1].amount
- end
- )
- local enStr = tostring(energy).." / "..maxEn
- if not tankDetected then
- print(enStr..": no tank fluid detected (This can mean there is an empty tank, or no tank there)")
- else
- term.clear()
- term.setCursorPos(1,1)
- if energy > buffer then
- -- buffer is full enough
- print(enStr..": over threshold")
- rs.setOutput(outputSide,defaultRsState)
- else
- --buffer is low
- print(enStr..": under threshold")
- rs.setOutput(outputSide, not defaultRsState)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement