On_The_Edge

Tanks und PowerGrid V3

Feb 23rd, 2021 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.66 KB | None | 0 0
  1. -- Komponenten --
  2. event.ignoreAll()
  3. gpu1 = computer.getGPUs(1)[1]
  4. gpu2 = computer.getGPUs(1)[2]
  5.  
  6. FCScreen = component.proxy("A4F4F5B84ABECA3C00DC4B911D08A25C")
  7. PowerScreen = component.proxy("9884839E45D712B4E80C1EA10678D423")
  8. PowerPole = component.proxy("93C9C4D14EBE274BCB5F90BE120604DD")
  9.  
  10. FCTank1 = component.proxy("8FBB53534CD146B2C164BAA2B239FDFA")
  11. FCTank2 = component.proxy("4A5240694B7F6B7B6A0167A502D56F17")
  12. FCTank3 = component.proxy("23B113894643C8A082F0AD8298719AAE")
  13. FCTank4 = component.proxy("F09587554E2831D602495CB71F83882D")
  14.  
  15. PowerStat = PowerPole:getPowerConnectors()[1]
  16. PowerDet = PowerStat:getCircuit()
  17.  
  18. gpu1:bindScreen(FCScreen)
  19. gpu2:bindScreen(PowerScreen)
  20. FC1w, FC1h = gpu1:getSize()
  21. FC2w, FC2h = gpu2:getSize()
  22.  
  23. gpu1:setsize(FC1w,FC1h)
  24. gpu2:setsize(35,10)
  25. gpu1:setForeground(1,1,1,1)
  26. gpu1:setBackground(0,0,0,0)
  27. gpu2:setForeground(1,1,1,1)
  28. gpu2:setBackground(0,0,0,0)
  29. --event.listen(gpu1)
  30. --event.listen(gpu2)
  31.  
  32.  
  33. -- Bezeichnungen --
  34. line = "-------------------------"
  35.  
  36.  
  37. -- OPTION --
  38. -- Tank1:flush()
  39. -- Tank2:flush()
  40.  
  41.  
  42. -- DATEN --
  43. z = 3  -- Zeilen --
  44. fcx = 1 -- Spalte links Abstand --
  45.  
  46. function getdata()
  47. V1 = FCTank1.fluidcontent
  48. F1 = FCTank1.flowfill - FCTank1.flowdrain
  49.  
  50.  
  51. V1 = math.floor(V1) -- runden --
  52. if V1 > 2400 then V1 ="2400" else
  53. end
  54. F1 = math.floor(F1) -- runden --
  55.  
  56. V2 = FCTank2.fluidcontent
  57. F2 = FCTank2.flowfill - FCTank2.flowdrain
  58.  
  59. V2 = math.floor(V2) -- runden --
  60. if V2 > 2400 then V2 ="2400" else
  61. end
  62. F2 = math.floor(F2) -- runden --
  63.  
  64. V3 = FCTank3.fluidcontent
  65. F3 = FCTank3.flowfill - FCTank3.flowdrain
  66.  
  67. V3 = math.floor(V3) -- runden --
  68. if V3 > 2400 then V3 ="2400" else
  69. end
  70. F3 = math.floor(F3) -- runden --
  71.  
  72. V4 = FCTank4.fluidcontent
  73. F4 = FCTank4.flowfill - FCTank4.flowdrain
  74.  
  75. V4 = math.floor(V4) -- runden --
  76. if V4 > 2400 then V4 ="2400" else
  77. end
  78. F4 = math.floor(F4) -- runden --
  79.  
  80. Capa = PowerDet.capacity
  81. Verbr = PowerDet.consumption
  82. Free = Capa - Verbr
  83. Ausl = (100/Capa)*Verbr
  84.  
  85. Capa = math.floor(Capa)
  86. Verbr = math.floor(Verbr)
  87. Free = math.floor(Free)
  88. Ausl = math.floor(Ausl)
  89. AuslProz = math.floor(Ausl*10)/10
  90. AuslProz = math.floor(AuslProz)
  91. n = AuslProz / 10
  92. -- print(n)
  93. n = math.floor(n)+1
  94. -- print(n)
  95.  
  96. -- Auslastung --
  97. Ausl = math.floor(Ausl)
  98. end
  99.  
  100. -- AUSGABE Bildschirm 1--
  101. function stream1()
  102. gpu1:fill(0,0,FC1w,FC1h," ")
  103.  
  104. gpu1:setForeground(255,165,0,1)
  105. gpu1:setText(fcx,1,"FUEL CITY")
  106.  
  107. gpu1:setForeground(1,1,1,1)
  108. gpu1:setText(fcx,z,"Tank 1: "..V1.."L")   -- Tank1
  109. gpu1:setText(15,z,"|".."\tNET: "..F1)
  110.  
  111. gpu1:setText(fcx,z+1,line)                -- Trennlinie
  112.  
  113. gpu1:setText(fcx,z+2,"Tank 2: "..V2.."L") -- Tank2
  114. gpu1:setText(15,z+2,"|".."\tNET: "..F2)
  115.  
  116. gpu1:setText(fcx,z+3,line)                -- Trennlinie
  117.  
  118. gpu1:setText(fcx,z+4,"Tank 3: "..V3.."L") -- Tank3
  119. gpu1:setText(15,z+4,"|".."\tNET: "..F3)
  120.  
  121. gpu1:setText(fcx,z+5,line)                -- Trennlinie
  122.  
  123. gpu1:setText(fcx,z+6,"Tank 4: "..V4.."L") -- Tank4
  124. gpu1:setText(15,z+6,"|".."\tNET: "..F4)
  125.  
  126. gpu1:setText(fcx,z+7,line)                -- Trennlinie
  127.  
  128. gpu1:flush()
  129. end
  130.  
  131. -- AUSGABE Bildschirm 2--
  132. function stream2()
  133. xn = 14 -- Startabstand (xn) für Balken
  134. gpu2:fill(0,0,FC2w,FC2h," ")
  135.  
  136. gpu2:setForeground(255,165,0,1)
  137. gpu2:setText(fcx,1,"POWER GRID")
  138.  
  139. gpu2:setForeground(1,1,1,1)
  140. gpu2:setText(fcx,z,"CAP:  "..Capa.." MWh")
  141. gpu2:setText(fcx,z+2,"USE:  "..Verbr.." MWh")
  142. gpu2:setText(fcx,z+4,"AUSL: "..Ausl.." %")
  143. gpu2:setText(fcx+12,z+4,"|")
  144. gpu2:setText(fcx+23,z+4,"|")
  145.  
  146. gpu2:setBackground(0,0,255,1) -- Farbe für Balken
  147. gpu2:fill(xn,z+4,n,1," ") -- Balken Display
  148. gpu2:setBackground(0,0,0,0)
  149.  
  150. gpu2:flush()
  151. end
  152.  
  153.  
  154. -- RUN --
  155.  
  156. while true do
  157. event.pull(1)
  158. getdata()
  159. stream1()
  160. stream2()
  161. end
Add Comment
Please, Sign In to add comment