Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tank = peripheral.wrap('back')
- mon = peripheral.wrap('front')
- warning = 40
- warnPause = 1
- pauseTime = 2
- local function centerText(text)
- x,y = mon.getSize()
- x1,y1 = mon.getCursorPos()
- mon.setCursorPos((math.floor(x/2) - (math.floor(#text/2))), y1)
- mon.write(text)
- end
- while true do
- mon.clear()
- amount = tank.getTankInfo('back')[1].amount
- capacity = tank.getTankInfo('back')[1].capacity
- if amount == nil then
- amount = 0
- percent = 0
- else
- percent = math.floor(((100 * amount / capacity) * 100) / 100)
- end
- if amount < percent then
- mon.setBackgroundColor(colors.red)
- mon.clear()
- mon.setCursorPos(1,3)
- centerText("Alert")
- pauseTime = warnPause
- sleep(pauseTime)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- end
- mon.setCursorPos(1,1)
- mon.write("Capacity: "..capacity.." mB")
- mon.setCursorPos(1,2)
- mon.write("Current: "..amount.." mB")
- mon.setCursorPos(1,3)
- mon.write(" "..percent.."%")
- sleep(pauseTime)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement