Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Author: Richard Worring --
- --Date: 17.06.2019
- --Modified Last: 24.01.2021 --
- --
- --URL: pastebin get SLthTL2V TankStats.lua -f --
- ----------------------------------------------------------
- local term = require"term"
- local component = require"component"
- local sides = require"sides"
- local gpu = component.gpu
- local tank = component.tank_controller
- gpu.setResolution(120, 40)
- local w, h = gpu.getResolution()
- gpu.is_palette = true
- local ARRoldAmount = {}
- for i = 0,5 do
- ARRoldAmount[i] = 0
- end
- gpu.setBackground(1, true)
- term.clear()
- --Get stats of tanks
- while true do
- i = 5
- for sides = 0,5 do
- if type(tank.getFluidInTank(sides)) == "table" then
- tanks = {}
- for a,b in ipairs(tank.getFluidInTank(sides))
- do
- tanks[a] = {}
- tanks[a].name = b.name
- tanks[a].label = b.label
- tanks[a].unit = b.unit
- tanks[a].level = b.amount
- tanks[a].capacity = b.capacity
- vTLvl = b.amount / b.capacity
- vDeltaTLvl = (b.amount - ARRoldAmount[sides])*10 -- *10 because the os sleeps for 0.1 seconds
- gpu.fill(6, i, w, h/18, " ")
- gpu.fill(6, i+1, w, h/18, " ")
- if b.label == nil then
- gpu.set(6, i+1, "Tank on side "..sides.." empty.")
- elseif b.amount <= (b.capacity * 0.05) then
- gpu.set(6, i+1, ""..b.label.." tank on side "..sides.." below 5%.")
- else
- if b.label == "Lubricant" then
- gpu.setBackground(0xFFDB40)
- gpu.setForeground(1, true)
- elseif b.label == "Jet Fuel" then
- gpu.setBackground(0xFF2480)
- gpu.setForeground(15, true)
- elseif b.label == "Water" then
- gpu.setBackground(0x0000FF)
- gpu.setForeground(15, true)
- else
- gpu.setBackground(15, true)
- gpu.setForeground(1, true)
- end
- --Display the bar
- gpu.fill(5, i+1, ((w - 5) * vTLvl), h/18, " ")
- --Display the delta of the fuel
- if b.amount <= (b.capacity * 0.3) then
- gpu.setBackground(1, true)
- gpu.setForeground(15, true)
- gpu.set(((w * vTLvl) + 5), i+1, ""..vDeltaTLvl.."mB/Sec")
- else
- gpu.set((((w - 5) * vTLvl) * 0.5), i+1, ""..vDeltaTLvl.."mB/Sec")
- end
- gpu.setBackground(1, true)
- gpu.setForeground(15, true)
- gpu.set(6, i, ""..b.label)
- gpu.set((w - 25), i, ""..b.amount.."/"..b.capacity.."mB")
- end
- gpu.setBackground(1, true)
- gpu.setForeground(15, true)
- i = i + 5
- ARRoldAmount[sides] = b.amount
- end
- else
- print("No Tank detected")
- end
- end
- vDeltaTLvl = 0
- os.sleep(0.1)
- end
- --[[ChangeLog
- 23.01.2021 changed vOldAmount to vars[sides.."oldAmount"]
- failed
- 23.01.2021 changed from vars to array for oldAmount
- 23.01.2021 changed low level message
- 23.01.2021 added if for b.label is empty
- 23.01.2021 changed the MB/Min to MB/Sec because the os sleeps for 2 seconds
- 23.01.2021 added a "clearline" row 52
- 24.01.2021 added a "clearlin" for the Labels
- ]]--
Add Comment
Please, Sign In to add comment