Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- side = "right"
- wait = 30
- lowLiquidLevel = 100000
- tank = peripheral.wrap(side)
- --disable production by default
- rs.setOutput("back",true)
- refilling=false
- function tankAmount()
- tanksTable = tank.getTankInfo("unknown")
- maintank = tanksTable[1]
- return maintank.amount
- end
- function tankCapacity()
- tanksTable = tank.getTankInfo("unknown")
- maintank = tanksTable[1]
- return maintank.capacity
- end
- function tankIsLow()
- return tankAmount() < lowLiquidLevel
- end
- function tankIsFull()
- return tankAmount() > tankCapacity()-1000
- end
- function printStatus()
- status=""
- if refilling then status="refilling" else status="filled" end
- print("Tank Status : "..status.." ("..tankAmount().."mB / "..tankCapacity().."mB)")
- end
- while(true) do
- print("...Sleeping for "..wait.."s...")
- sleep(30)
- printStatus()
- if tankIsLow() then
- if refilling==false then
- --Resume production when level is low
- print("Tank level is low : production will be resume.")
- rs.setOutput("back",false)
- refilling=true
- end
- else
- if tankIsFull() and refilling then
- --Stop the production when the tank has been refilled
- print("Tank level is full : production will be paused.")
- rs.setOutput("back",true)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement