Advertisement
Doob

tankCL [OpenComputers][RailCraft]

Jan 15th, 2017
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local C = require("component")
  2. local E = require("event")
  3. local gpu = C.gpu
  4. local W, H = gpu.maxResolution()
  5. local tank, name, color, X, p, e
  6. local rawList = C.list("tankvalvetile")
  7. local list = {}
  8.  
  9. local tColors = {
  10.   ["?"] = 0xFFFFFF,
  11.   ["lava"] = 0xFFDD00,
  12.   ["water"] = 0x0066FF,
  13.   ["creosote"] = 0x88FF00
  14. }
  15.  
  16. for i in pairs(rawList) do
  17.   table.insert(list, C.proxy(i))
  18. end
  19. if #list == 0 then
  20.   print("ERROR: Valve block not found.")
  21.   os.exit()
  22. end
  23. gpu.fill(1, 1, W, H, " ")
  24. gpu.setResolution(16*#list+#list-1, 22)
  25. while true do
  26.   gpu.fill(1, 1, W, H, " ")
  27.   for i = 1, #list do
  28.     tank = list[i].getTankInfo()[1]
  29.     if tank.contents then
  30.       p = math.ceil((tank.contents.amount/tank.capacity)*100)
  31.       name = tank.contents.name
  32.       X = (i-1)*17+1
  33.       if tColors[name] then
  34.         color = tColors[name]
  35.       else
  36.         color = tColors["?"]
  37.       end
  38.       gpu.setForeground(color)
  39.       gpu.set(X, 1, name:sub(1, 10).." "..p.." %")
  40.       gpu.set(X, 2, "("..tank.contents.amount/1000 .." mB)")
  41.       gpu.setForeground(0xFFFFFF)
  42.       gpu.setBackground(color)
  43.       gpu.fill(X, 23-math.ceil(p/5), 16, math.ceil(p/5), " ")
  44.       gpu.setBackground(0x000000)
  45.     end
  46.   end
  47.   e = E.pull(3, "key_down")
  48.   if e then
  49.     gpu.setResolution(W, H)
  50.     gpu.fill(1, 1, W, H, " ")
  51.     os.exit()
  52.   end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement