Advertisement
On_The_Edge

Vertikale Füllstandsanzeige Table V1

Feb 23rd, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.74 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. -- event.listen(gpu1)
  13.  
  14. -- Bezeichnungen --
  15. line="--------------------------"
  16.  
  17.  
  18. -- OPTION --
  19. Tank1:flush()
  20. Tank2:flush()
  21.  
  22. -- DATEN --
  23. z = 0
  24. o = 5 -- oberes ende
  25. u = o+13 -- unteres ende
  26.  
  27. function getdata()
  28. V1 = Tank1.fluidcontent
  29. F1 = Tank1.flowfill*60 - Tank1.flowdrain*60
  30.  
  31. V1 = math.floor(V1) -- runden --
  32. F1 = math.floor(F1) -- runden --
  33.  
  34. V2 = Tank2.fluidcontent
  35. F2 = Tank2.flowfill*60 - Tank2.flowdrain*60
  36.  
  37. V2 = math.floor(V2) -- runden --
  38. F2 = math.floor(F2) -- runden --
  39. end
  40.  
  41. -- AUSGABE --
  42. function stream()
  43. gpu1:fill(0,0,100,20," ")
  44. gpu1:setText(0,z,"Tank 1: "..V1.."L")   -- Tank1
  45. gpu1:setText(15,z,"|".."\tNET: "..F1)
  46.  
  47. gpu1:setText(0,z+1,line)                -- Trennlinie
  48.  
  49. gpu1:setText(0,z+2,"Tank 2: "..V2.."L") -- Tank2
  50. gpu1:setText(15,z+2,"|".."\tNET: "..F2)
  51.  
  52. gpu1:setText(0,z+3,line)                -- Trennlinie
  53.  
  54.  
  55. h1 = math.random(2400) -- Füllstand 1
  56. h2 = math.random(2400) -- Füllstand 2
  57. h3 = math.random(2400) -- Füllstand 3
  58. -- h = 2400
  59. p1 = math.floor((100/2400)*h1/10)
  60. p2 = math.floor((100/2400)*h2/10)
  61. p3 = math.floor((100/2400)*h3/10)
  62.  
  63. x = 29 -- x Spalte für Anzeigen
  64.  
  65. function Zahlenformat() -- Anzeige der Zahl je nach Länge der Zahl
  66. if Z < 10 then Z = "   "..h1
  67. return Z
  68. end
  69.  
  70. if Z < 100 then Z = "  "..h1
  71. return Z
  72. end
  73.  
  74. if Z < 1000 then Z = " "..h1
  75. return Z
  76. end
  77. end
  78.  
  79. -- Tank 1 --
  80. Z = h1
  81. Zahlenformat()
  82.  
  83. gpu1:setBackground(0,0,255,1)
  84. gpu1:fill(x+1,u-p1,2,p1," ")
  85. gpu1:setBackground(0,0,0,0)
  86. gpu1:setText(x,u,"----")
  87. gpu1:fill(x,o+3,1,10,"|")
  88. gpu1:fill(x+3,o+3,1,10,"|")
  89. gpu1:setText(x,o+2,"----")
  90. gpu1:setText(x,o+1,Z)
  91. gpu1:setText(x,o,"----")
  92.  
  93. -- Tank 2 --
  94. x = x + 6
  95. -- Z = h2
  96. -- Zahlenformat()
  97.  
  98. gpu1:setBackground(0,0,255,1)
  99. gpu1:fill(x+1,u-p2,2,p2," ")
  100. gpu1:setBackground(0,0,0,0)
  101. gpu1:setText(x,u,"----")
  102. gpu1:fill(x,o+3,1,10,"|")
  103. gpu1:fill(x+3,o+3,1,10,"|")
  104. gpu1:setText(x,o+2,"----")
  105. gpu1:setText(x,o+1,h2)
  106. gpu1:setText(x,o,"----")
  107.  
  108. -- Tank 3 --
  109. x = x + 6
  110. -- Z = h3
  111. -- Zahlenformat()
  112.  
  113. gpu1:setBackground(0,0,255,1)
  114. gpu1:fill(x+1,u-p3,2,p3," ")
  115. gpu1:setBackground(0,0,0,0)
  116. gpu1:setText(x,u,"----")
  117. gpu1:fill(x,o+3,1,10,"|")
  118. gpu1:fill(x+3,o+3,1,10,"|")
  119. gpu1:setText(x,o+2,"----")
  120. gpu1:setText(x,o+1,h3)
  121. gpu1:setText(x,o,"----")
  122.  
  123. print(Z..h1)
  124.  
  125. gpu1:flush()
  126. end
  127.  
  128. function Balken()
  129.  
  130.  
  131. end
  132.  
  133.  
  134.  
  135. -- RUN --
  136.  
  137. while true do
  138. event.pull(2)
  139. getdata()
  140. -- print(V1,"\t",V2)
  141. stream()
  142. Z = ""
  143.  
  144. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement