Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Monitor must be to the right
- -- Requires 1x2 Monitor for correct display
- local out = peripheral.wrap("right")
- local running = true
- local firstrun = true
- local isPumping = false
- while running do
- if not firstrun then
- os.pullEvent("redstone")
- else
- firstrun = false
- end
- if rs.getInput("right") then
- out.clear()
- out.setCursorPos(1,1)
- out.write("RESTARTING")
- sleep(2)
- os.reboot()
- end
- out.clear()
- out.setCursorPos(1,1)
- out.write("~~ Pump Status ~~")
- -- redstone "sensors" input to specific sides
- -- redstone signal indicating pump is turned of by user
- local pumpEnabled = rs.getInput("back")
- -- redstone signal indicating reserve tank is full (at ~95% capacity)
- local tankFull = rs.getInput("bottom")
- -- redstone signal indicating reserve tank is empty
- local tankEmpty = rs.getInput("front")
- -- ~~ Pump Shutoff System ~~
- -- pump shuts off when tank is full (~95%)
- -- pump starts when tank is empty
- if tankFull and isPumping then
- isPumping = false
- end
- if tankEmpty and not isPumping then
- if pumpEnabled then
- isPumping = true
- end
- end
- rs.setOutput("top", isPumping)
- out.setCursorPos(1,2)
- if pumpEnabled then
- out.setBackgroundColor(colors.lime)
- out.setTextColor(colors.black)
- out.write("Pump Online ")
- else
- out.setBackgroundColor(colors.red)
- out.setTextColor(colors.white)
- out.write("Pump Offline ")
- end
- out.setBackgroundColor(colors.black)
- out.setTextColor(colors.white)
- out.setCursorPos(1,3)
- if tankFull and not tankEmpty then
- out.setBackgroundColor(colors.lime)
- out.setTextColor(colors.black)
- out.write("Tank Full ")
- elseif not tankFull and not tankEmpty then
- out.setBackgroundColor(colors.yellow)
- out.setTextColor(colors.black)
- if isPumping then
- out.write("Tank Filling ")
- else
- out.write("Tank Draining ")
- end
- elseif not tankFull and tankEmpty then
- out.setBackgroundColor(colors.red)
- out.setTextColor(colors.white)
- out.write("Tank Empty ")
- end
- out.setCursorPos(1,4)
- if isPumping then
- out.setBackgroundColor(colors.lime)
- out.setTextColor(colors.black)
- out.write(" - PUMPING - ")
- else
- out.setBackgroundColor(colors.yellow)
- out.setTextColor(colors.black)
- out.write(" - PUMP IDLE - ")
- end
- out.setBackgroundColor(colors.black)
- out.setTextColor(colors.white)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement