Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local C = require("component")
- local E = require("event")
- local gpu = C.gpu
- local W, H = gpu.maxResolution()
- local tank, name, color, X, p, e
- local rawList = C.list("tankvalvetile")
- local list = {}
- local tColors = {
- ["?"] = 0xFFFFFF,
- ["lava"] = 0xFFDD00,
- ["water"] = 0x0066FF,
- ["creosote"] = 0x88FF00
- }
- for i in pairs(rawList) do
- table.insert(list, C.proxy(i))
- end
- if #list == 0 then
- print("ERROR: Valve block not found.")
- os.exit()
- end
- gpu.fill(1, 1, W, H, " ")
- gpu.setResolution(16*#list+#list-1, 22)
- while true do
- gpu.fill(1, 1, W, H, " ")
- for i = 1, #list do
- tank = list[i].getTankInfo()[1]
- if tank.contents then
- p = math.ceil((tank.contents.amount/tank.capacity)*100)
- name = tank.contents.name
- X = (i-1)*17+1
- if tColors[name] then
- color = tColors[name]
- else
- color = tColors["?"]
- end
- gpu.setForeground(color)
- gpu.set(X, 1, name:sub(1, 10).." "..p.." %")
- gpu.set(X, 2, "("..tank.contents.amount/1000 .." mB)")
- gpu.setForeground(0xFFFFFF)
- gpu.setBackground(color)
- gpu.fill(X, 23-math.ceil(p/5), 16, math.ceil(p/5), " ")
- gpu.setBackground(0x000000)
- end
- end
- e = E.pull(3, "key_down")
- if e then
- gpu.setResolution(W, H)
- gpu.fill(1, 1, W, H, " ")
- os.exit()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement