Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("top")
- local tank = peripheral.wrap("right")
- local modem = peripheral.wrap("back")
- modem.open(100)
- local amount
- local cap
- local percentfull
- local warning = 10
- local sleepTime = 10
- 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
- mon.clear()
- mon.setCursorPos(3,3)
- rs.setOutput("left", false)
- local fluidAmount, fluidCapacity = getTank(tank)
- cap = fluidCapacity / 1000
- amount = fluidAmount
- mon.setTextColor(colours.white)
- if fluidCapacity == nil then
- return
- end
- if amount == nil then
- amount = 0
- percentfull = 0
- else
- amount = math.floor(amount / 1000)
- percentfull = math.floor(100 * amount / cap)
- end
- if percentfull < warning then
- rs.setOutput("left", true)
- mon.setTextColour(colours.red)
- elseif percentfull > 90 then
- mon.setTextColour(colours.green)
- end
- mon.write(percentfull.."%")
- modem.transmit(100, 100, percentfull)
- print(percentfull.."%")
- sleep(sleepTime)
- end
- --ref: http://pastebin.com/XeHKVry4
- --RabaGhast
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement