Advertisement
On_The_Edge

Vertikale Füllstandsanzeige Table V2

Feb 23rd, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.73 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. h = {}
  55. p = {}
  56. hx = 1 -- Start h = 1
  57. hz = 3 -- Anzahl der Tanks
  58. for i = 1, hz, 1 do
  59. h[hx] = math.random(2400)
  60. p[hx] = math.floor((100/2400)*h[hx]/10)
  61. -- print (h[hx], p[hx])
  62. hx = hx + 1
  63. end
  64.  
  65. x = 29 -- x Spalte für Anzeigen
  66.  
  67. function Zahlenformat() -- Anzeige der Zahl je nach Länge der Zahl
  68. if Z < 10 then Z = "   "..h[hx]
  69. return Z
  70. end
  71.  
  72. if Z < 100 then Z = "  "..h[hx]
  73. return Z
  74. end
  75.  
  76. if Z < 1000 then Z = " "..h[hx]
  77. return Z
  78. end
  79. end
  80.  
  81. -- Tank 1 --
  82. hx = 1
  83. Z = h[hx]
  84. Zahlenformat()
  85.  
  86. gpu1:setBackground(0,0,255,1)
  87. gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
  88. gpu1:setBackground(0,0,0,0)
  89. gpu1:setText(x,u,"----")
  90. gpu1:fill(x,o+3,1,10,"|")
  91. gpu1:fill(x+3,o+3,1,10,"|")
  92. gpu1:setText(x,o+2,"----")
  93. gpu1:setText(x,o+1,Z)
  94. gpu1:setText(x,o,"----")
  95.  
  96. -- Tank 2 --
  97. x = x + 6
  98. hx = hx +1
  99. Z = h[hx]
  100. Zahlenformat()
  101.  
  102. gpu1:setBackground(0,0,255,1)
  103. gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
  104. gpu1:setBackground(0,0,0,0)
  105. gpu1:setText(x,u,"----")
  106. gpu1:fill(x,o+3,1,10,"|")
  107. gpu1:fill(x+3,o+3,1,10,"|")
  108. gpu1:setText(x,o+2,"----")
  109. gpu1:setText(x,o+1,Z)
  110. gpu1:setText(x,o,"----")
  111.  
  112. -- Tank 3 --
  113. x = x + 6
  114. hx = hx +1
  115. Z = h[hx]
  116. Zahlenformat()
  117.  
  118. gpu1:setBackground(0,0,255,1)
  119. gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
  120. gpu1:setBackground(0,0,0,0)
  121. gpu1:setText(x,u,"----")
  122. gpu1:fill(x,o+3,1,10,"|")
  123. gpu1:fill(x+3,o+3,1,10,"|")
  124. gpu1:setText(x,o+2,"----")
  125. gpu1:setText(x,o+1,Z)
  126. gpu1:setText(x,o,"----")
  127.  
  128.  
  129. gpu1:flush()
  130. end
  131.  
  132. function Balken()
  133.  
  134.  
  135. end
  136.  
  137.  
  138.  
  139. -- RUN --
  140.  
  141. while true do
  142. event.pull(2)
  143. getdata()
  144. -- print(V1,"\t",V2)
  145. stream()
  146. Z = ""
  147.  
  148. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement