Advertisement
On_The_Edge

Vertikale Füllstandsanzeige Table mit realen Daten V1

Feb 23rd, 2021 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. -- Komponenten --
  2. event.ignoreAll()
  3. gpu1 = computer.getGPUs(1)[1]
  4. Screen = component.proxy("FEC3E5EA47C6B134A9613FB0CC51CCD3")
  5. Tank1 = component.proxy("E19432AE46CCC08F1A5D09969E33CF85")
  6. Tank2 = component.proxy("98A62C4B4C2233627321D1B30816F8E5")
  7.  
  8. gpu1:bindScreen(Screen)
  9. gpu1:setsize(100,20)
  10. gpu1:setForeground(1,1,1,1)
  11. gpu1:setBackground(0,0,0,0)
  12.  
  13. -- OPTION --
  14. Tank1:flush()
  15. -- Tank2:flush()
  16.  
  17. -- DATEN --
  18. z = 0 -- Zeilenreset
  19. o = 5 -- oberes ende
  20. u = o+13 -- unteres ende
  21. T = 2 -- Anzahl der Tanks
  22. h = {}
  23. p = {}
  24.  
  25. function getdata()
  26. V1 = Tank1.fluidcontent
  27. V1 = math.floor(V1) -- runden --
  28. if V1 > 2400 then V1 = 2400
  29. end
  30.  
  31. V2 = Tank2.fluidcontent
  32. V2 = math.floor(V2) -- runden --
  33. if V2 > 2400 then V2 = 2400
  34. end
  35. print (V1, V2)
  36.  
  37. hx = 1 -- Start h = 1
  38. VS = {V1, V2}
  39.  
  40. for i = 1,T,1 do
  41. h[hx] = VS[hx]
  42. p[hx] = math.floor((100/2400)*h[hx]/10)
  43. print ((h[hx]), (p[hx]))
  44. hx = hx + 1
  45. end
  46. end
  47.  
  48. -- AUSGABE --
  49. function stream()
  50. gpu1:fill(0,0,100,20," ")
  51.  
  52. x = 5 -- x Spalte für Anzeigen vom linken Rand
  53.  
  54. function Zahlenformat() -- Anzeige der Zahl je nach Länge der Zahl
  55. if Z < 10 then Z = "   "..h[hx]
  56. return Z
  57. end
  58.  
  59. if Z < 100 then Z = "  "..h[hx]
  60. return Z
  61. end
  62.  
  63. if Z < 1000 then Z = " "..h[hx]
  64. return Z
  65. end
  66. end
  67.  
  68. -- Tank 1 --
  69. hx = 1
  70. Z = h[hx]
  71. Zahlenformat()
  72.  
  73. gpu1:setBackground(0,0,255,1)
  74. gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
  75. gpu1:setBackground(0,0,0,0)
  76. gpu1:setText(x,u,"----")
  77. gpu1:fill(x,o+3,1,10,"|")
  78. gpu1:fill(x+3,o+3,1,10,"|")
  79. gpu1:setText(x,o+2,"----")
  80. gpu1:setText(x,o+1,Z)
  81. gpu1:setText(x,o,"----")
  82. gpu1:setText(x,o-1," T1")
  83.  
  84. -- Tank 2 --
  85. x = x + 7 -- Abstand der Anzeigen zueinander
  86. hx = hx +1
  87. Z = h[hx]
  88. Zahlenformat()
  89.  
  90. gpu1:setBackground(0,0,255,1)
  91. gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
  92. gpu1:setBackground(0,0,0,0)
  93. gpu1:setText(x,u,"----")
  94. gpu1:fill(x,o+3,1,10,"|")
  95. gpu1:fill(x+3,o+3,1,10,"|")
  96. gpu1:setText(x,o+2,"----")
  97. gpu1:setText(x,o+1,Z)
  98. gpu1:setText(x,o,"----")
  99. gpu1:setText(x,o-1," T2")
  100.  
  101.  
  102. gpu1:flush()
  103. end
  104.  
  105. -- RUN --
  106. while true do
  107. event.pull(2)
  108. getdata()
  109. stream()
  110. hx = 1
  111. Z = ""
  112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement