Advertisement
On_The_Edge

Vertikale Füllstandsanzeige Table V3

Feb 23rd, 2021
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  22. function getdata()
  23. V1 = Tank1.fluidcontent
  24. F1 = Tank1.flowfill*60 - Tank1.flowdrain*60
  25.  
  26. V1 = math.floor(V1) -- runden --
  27. F1 = math.floor(F1) -- runden --
  28.  
  29. V2 = Tank2.fluidcontent
  30. F2 = Tank2.flowfill*60 - Tank2.flowdrain*60
  31.  
  32. V2 = math.floor(V2) -- runden --
  33. F2 = math.floor(F2) -- runden --
  34. end
  35.  
  36. -- AUSGABE --
  37. function stream()
  38. gpu1:fill(0,0,100,20," ")
  39.  
  40. h = {}
  41. p = {}
  42. hx = 1 -- Start h = 1
  43. hz = 3 -- Anzahl der Tanks
  44. for i = 1, hz, 1 do
  45. h[hx] = math.random(2400)
  46. p[hx] = math.floor((100/2400)*h[hx]/10)
  47. hx = hx + 1
  48. end
  49.  
  50. x = 5 -- x Spalte für Anzeigen vom linken Rand
  51.  
  52. function Zahlenformat() -- Anzeige der Zahl je nach Länge der Zahl
  53. if Z < 10 then Z = "   "..h[hx]
  54. return Z
  55. end
  56.  
  57. if Z < 100 then Z = "  "..h[hx]
  58. return Z
  59. end
  60.  
  61. if Z < 1000 then Z = " "..h[hx]
  62. return Z
  63. end
  64. end
  65.  
  66. -- Tank 1 --
  67. hx = 1
  68. Z = h[hx]
  69. Zahlenformat()
  70.  
  71. gpu1:setBackground(0,0,255,1)
  72. gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
  73. gpu1:setBackground(0,0,0,0)
  74. gpu1:setText(x,u,"----")
  75. gpu1:fill(x,o+3,1,10,"|")
  76. gpu1:fill(x+3,o+3,1,10,"|")
  77. gpu1:setText(x,o+2,"----")
  78. gpu1:setText(x,o+1,Z)
  79. gpu1:setText(x,o,"----")
  80.  
  81. -- Tank 2 --
  82. x = x + 7 -- Abstand der Anzeigen zueinander
  83. hx = hx +1
  84. Z = h[hx]
  85. Zahlenformat()
  86.  
  87. gpu1:setBackground(0,0,255,1)
  88. gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
  89. gpu1:setBackground(0,0,0,0)
  90. gpu1:setText(x,u,"----")
  91. gpu1:fill(x,o+3,1,10,"|")
  92. gpu1:fill(x+3,o+3,1,10,"|")
  93. gpu1:setText(x,o+2,"----")
  94. gpu1:setText(x,o+1,Z)
  95. gpu1:setText(x,o,"----")
  96.  
  97. -- Tank 3 --
  98. x = x + 7
  99. hx = hx +1
  100. Z = h[hx]
  101. Zahlenformat()
  102.  
  103. gpu1:setBackground(0,0,255,1)
  104. gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
  105. gpu1:setBackground(0,0,0,0)
  106. gpu1:setText(x,u,"----")
  107. gpu1:fill(x,o+3,1,10,"|")
  108. gpu1:fill(x+3,o+3,1,10,"|")
  109. gpu1:setText(x,o+2,"----")
  110. gpu1:setText(x,o+1,Z)
  111. gpu1:setText(x,o,"----")
  112.  
  113. gpu1:flush()
  114. end
  115.  
  116. -- RUN --
  117. while true do
  118. event.pull(2)
  119. getdata()
  120. stream()
  121. Z = ""
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement