On_The_Edge

Nuclear Waste Depot Display V2

Feb 25th, 2021 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. -- Nuclear Waste Depot --
  2. gpu1 = computer.getGPUs(1)[1]
  3. NDisplay = component.proxy("E0ABBDA54599F50C06DB8DAD5E2F875F")
  4. gpu1:bindScreen(NDisplay)
  5. gpu1:setsize(35,10)
  6. gpu1:setForeground(1,1,1,1)
  7. gpu1:setBackground(0,0,0,0)
  8.  
  9. -- DATA --
  10. local pw = 0 -- percentage space left
  11. local ws = 0 -- total number waste
  12. local ns = 48  -- Slotsize Container
  13. local was = 500  -- Stacksize
  14. local x = 108 -- number of containers
  15. local wc = (x * was * ns) -- max Capacity
  16. wc = math.floor(wc)
  17.  
  18. -- bar colors --
  19. function barcolor()
  20. if pw <= 55 then gpu1:setBackground(0,255,0,0.5)
  21. end
  22. if pw > 55 and pw < 70 then gpu1:setBackground(255,120,0,1)
  23. end
  24. if pw >= 79 then gpu1:setBackground(255,0,0,1)
  25. else
  26. end
  27. end
  28.  
  29. function getdata()
  30. ws = 0
  31. storagesum = component.proxy(component.findComponent("NuclearWasteStorage"))
  32. for _,m in ipairs(storagesum) do
  33. ws = ws + m:getInventories()[1].ItemCount
  34. end
  35. pw = (100 / wc) * ws
  36. pw = math.floor(pw)
  37. end
  38.  
  39. -- display results --
  40. while true do
  41. event.pull(30)
  42. gpu1:fill(0,0,35,10," ")
  43. getdata()
  44. cap = wc / 1000
  45. cap = math.floor(cap)
  46. usd = ws / 1000
  47. usd = math.floor(usd)
  48. gpu1:setForeground(255,165,0,1)
  49. gpu1:setText(1,1,"N U C L E A R  W A S T E")
  50. gpu1:setForeground(1,1,1,1)
  51. gpu1:setText(1,3,"CAPACITY: "..cap.." K")
  52. gpu1:setText(1,5,"USED: "..usd.." K")
  53. gpu1:setText(1,7,"PERC: "..pw.."%")
  54. gpu1:setText(14,7,"|")
  55. gpu1:setText(25,7,"|")
  56. barcolor()
  57. pw = pw / 10
  58. pw = math.floor(pw)
  59. gpu1:fill(15,7,pw,1," ") -- Balken Display
  60. gpu1:setBackground(0,0,0,0)
  61. gpu1:flush()
  62. end
Add Comment
Please, Sign In to add comment