Advertisement
On_The_Edge

3 vertikale Tankanzeigen

Feb 23rd, 2021
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 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. h1 = math.random(2400) -- Füllstand 1
  55. h2 = math.random(2400) -- Füllstand 2
  56. h3 = math.random(2400) -- Füllstand 3
  57. -- h = 2400
  58. p1 = math.floor((100/2400)*h1/10)
  59. p2 = math.floor((100/2400)*h2/10)
  60. p3 = math.floor((100/2400)*h3/10)
  61.  
  62. x = 29 -- x Spalte für Anzeigen
  63.  
  64.  
  65.  
  66. -- Tank 1 --
  67. gpu1:setBackground(0,0,255,1)
  68. gpu1:fill(x+1,u-p1,2,p1," ")
  69. gpu1:setBackground(0,0,0,0)
  70. gpu1:setText(x,u,"----")
  71. gpu1:fill(x,o+3,1,10,"|")
  72. gpu1:fill(x+3,o+3,1,10,"|")
  73. gpu1:setText(x,o+2,"----")
  74. gpu1:setText(x,o+1,h1)
  75. gpu1:setText(x,o,"----")
  76.  
  77. -- Tank 2 --
  78. x = x + 6
  79.  
  80. gpu1:setBackground(0,0,255,1)
  81. gpu1:fill(x+1,u-p2,2,p2," ")
  82. gpu1:setBackground(0,0,0,0)
  83. gpu1:setText(x,u,"----")
  84. gpu1:fill(x,o+3,1,10,"|")
  85. gpu1:fill(x+3,o+3,1,10,"|")
  86. gpu1:setText(x,o+2,"----")
  87. gpu1:setText(x,o+1,h2)
  88. gpu1:setText(x,o,"----")
  89.  
  90. -- Tank 3 --
  91. x = x + 6
  92.  
  93. gpu1:setBackground(0,0,255,1)
  94. gpu1:fill(x+1,u-p3,2,p3," ")
  95. gpu1:setBackground(0,0,0,0)
  96. gpu1:setText(x,u,"----")
  97. gpu1:fill(x,o+3,1,10,"|")
  98. gpu1:fill(x+3,o+3,1,10,"|")
  99. gpu1:setText(x,o+2,"----")
  100. gpu1:setText(x,o+1,h3)
  101. gpu1:setText(x,o,"----")
  102.  
  103.  
  104. gpu1:flush()
  105. end
  106.  
  107. function Balken()
  108.  
  109.  
  110. end
  111.  
  112.  
  113.  
  114. -- RUN --
  115.  
  116. while true do
  117. event.pull(2)
  118. getdata()
  119. -- print(V1,"\t",V2)
  120. stream()
  121.  
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement