Advertisement
On_The_Edge

Tanks und PowerGrid V2

Feb 23rd, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.55 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.  
  93. -- Auslastung --
  94. Ausl = math.floor(Ausl)
  95. end
  96.  
  97. -- AUSGABE Bildschirm 1--
  98. function stream1()
  99. gpu1:fill(0,0,FC1w,FC1h," ")
  100.  
  101. gpu1:setForeground(255,165,0,1)
  102. gpu1:setText(fcx,1,"FUEL CITY")
  103.  
  104. gpu1:setForeground(1,1,1,1)
  105. gpu1:setText(fcx,z,"Tank 1: "..V1.."L")   -- Tank1
  106. gpu1:setText(15,z,"|".."\tNET: "..F1)
  107.  
  108. gpu1:setText(fcx,z+1,line)                -- Trennlinie
  109.  
  110. gpu1:setText(fcx,z+2,"Tank 2: "..V2.."L") -- Tank2
  111. gpu1:setText(15,z+2,"|".."\tNET: "..F2)
  112.  
  113. gpu1:setText(fcx,z+3,line)                -- Trennlinie
  114.  
  115. gpu1:setText(fcx,z+4,"Tank 3: "..V3.."L") -- Tank3
  116. gpu1:setText(15,z+4,"|".."\tNET: "..F3)
  117.  
  118. gpu1:setText(fcx,z+5,line)                -- Trennlinie
  119.  
  120. gpu1:setText(fcx,z+6,"Tank 4: "..V4.."L") -- Tank4
  121. gpu1:setText(15,z+6,"|".."\tNET: "..F4)
  122.  
  123. gpu1:setText(fcx,z+7,line)                -- Trennlinie
  124.  
  125. gpu1:flush()
  126. end
  127.  
  128. -- AUSGABE Bildschirm 2--
  129. function stream2()
  130. xn = 14 -- Startabstand (xn) fΓΌr Balken
  131. gpu2:fill(0,0,FC2w,FC2h," ")
  132.  
  133. gpu2:setForeground(255,165,0,1)
  134. gpu2:setText(fcx,1,"POWER GRID")
  135.  
  136. gpu2:setForeground(1,1,1,1)
  137. gpu2:setText(fcx,z,"CAP:  "..Capa.." MWh")
  138. gpu2:setText(fcx,z+2,"USE:  "..Verbr.." MWh")
  139. gpu2:setText(fcx,z+4,"AUSL: "..Ausl.." %")
  140. gpu2:setText(fcx+12,z+4,"[")
  141. gpu2:setText(fcx+23,z+4,"]")
  142. for i = 1,n,1 do
  143. gpu2:setText(xn,z+4,"#")
  144. xn = xn+1
  145. end
  146. gpu2:flush()
  147. end
  148.  
  149.  
  150. -- RUN --
  151.  
  152. while true do
  153. event.pull(1)
  154. getdata()
  155. stream1()
  156. stream2()
  157. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement