Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Author: Richard Worring --
- --Date: 17.06.2019 --
- --
- --URL: UWMH9HmT pastebin --
- ----------------------------------------------------------
- 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 vOldAmount = 0
- function stats()
- --Get stats of tanks
- for sides = 0,5 do
- if type(tank.getFluidInTank(sides)) == "table" then
- tanks = {} --Why?!
- 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 - vOldAmount) * 12
- if b.amount == 0 then
- gpu.set(6, i+1, "Der Tank an der Seite "..sides.." ist leer.")
- 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/Min")
- else
- gpu.set((((w - 5) * vTLvl) * 0.5), i+1, ""..vDeltaTLvl.."mB/Min")
- end
- --Set background and display label and level of fuel
- --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
- i = i + 5
- vOldAmount = b.amount
- end
- term.clear()
- else
- print("No Tank detected")
- end
- end
- end
- --function fTankEmpty(sides)
- -- print("Tank an der Seite"..sides.."leer.")
- -- return true
- --end
- --Loop for updates
- while true do
- gpu.setBackground(1, true)
- i = 5
- stats()
- os.sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement