Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tank = peripheral.wrap("front")
- local amount
- local warning = 0.5
- local sleepTime = 5
- function getTank(tank)
- local tableInfo = tank.getTankInfo("unknown")
- fluidAmount = nil
- fluidCapacity = tableInfo[1].capacity
- local contents = tableInfo[1].contents
- if contents then
- fluidAmount = contents.amount
- end
- return fluidAmount, fluidCapacity
- end
- while true do
- rs.setOutput("back", false)
- local fluidAmount, fluidCapacity = getTank(tank)
- amount = fluidAmount
- if fluidCapacity == nil then
- print("FluidCapacity in tank is nil. Mabye no tank is found")
- elseif fluidAmount == nil or fluidAmount == 0 then
- rs.setOutput("back", true)
- else
- if fluidAmount / fluidCapacity <= warning then
- rs.setOutput("back", true)
- end
- end
- sleep(sleepTime)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement