Advertisement
On_The_Edge

Tanks und PowerGrid

Feb 23rd, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.26 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. V1 = math.floor(V1) -- runden --
  51. F1 = math.floor(F1) -- runden --
  52.  
  53. V2 = FCTank2.fluidcontent
  54. F2 = FCTank2.flowfill - FCTank2.flowdrain
  55.  
  56. V2 = math.floor(V2) -- runden --
  57. F2 = math.floor(F2) -- runden --
  58.  
  59. V3 = FCTank3.fluidcontent
  60. F3 = FCTank3.flowfill - FCTank3.flowdrain
  61.  
  62. V3 = math.floor(V3) -- runden --
  63. F3 = math.floor(F3) -- runden --
  64.  
  65. V4 = FCTank4.fluidcontent
  66. F4 = FCTank4.flowfill - FCTank4.flowdrain
  67.  
  68. V4 = math.floor(V4) -- runden --
  69. F4 = math.floor(F4) -- runden --
  70.  
  71. Capa = PowerDet.capacity
  72. Verbr = PowerDet.consumption
  73. Free = Capa - Verbr
  74. Ausl = (100/Capa)*Verbr
  75.  
  76. Capa = math.floor(Capa)
  77. Verbr = math.floor(Verbr)
  78. Free = math.floor(Free)
  79. Ausl = math.floor(Ausl)
  80. AuslProz = math.floor(Ausl*10)/10
  81. AuslProz = math.floor(AuslProz)
  82. n = AuslProz / 10
  83.  
  84. -- Auslastung --
  85. Ausl = math.floor(Ausl)
  86. end
  87.  
  88. -- AUSGABE Bildschirm 1--
  89. function stream1()
  90. gpu1:fill(0,0,FC1w,FC1h," ")
  91.  
  92. gpu1:setText(fcx,1,"FUEL CITY")
  93.  
  94. gpu1:setText(fcx,z,"Tank 1: "..V1.."L")   -- Tank1
  95. gpu1:setText(15,z,"|".."\tNET: "..F1)
  96.  
  97. gpu1:setText(fcx,z+1,line)                -- Trennlinie
  98.  
  99. gpu1:setText(fcx,z+2,"Tank 2: "..V2.."L") -- Tank2
  100. gpu1:setText(15,z+2,"|".."\tNET: "..F2)
  101.  
  102. gpu1:setText(fcx,z+3,line)                -- Trennlinie
  103.  
  104. gpu1:setText(fcx,z+4,"Tank 3: "..V3.."L") -- Tank3
  105. gpu1:setText(15,z+4,"|".."\tNET: "..F3)
  106.  
  107. gpu1:setText(fcx,z+5,line)                -- Trennlinie
  108.  
  109. gpu1:setText(fcx,z+6,"Tank 4: "..V4.."L") -- Tank4
  110. gpu1:setText(15,z+6,"|".."\tNET: "..F4)
  111.  
  112. gpu1:setText(fcx,z+7,line)                -- Trennlinie
  113.  
  114. gpu1:flush()
  115. end
  116.  
  117. -- AUSGABE Bildschirm 2--
  118. function stream2()
  119. xn = 14 -- Startabstand (xn) für Balken
  120. gpu2:fill(0,0,FC2w,FC2h," ")
  121. gpu2:setText(fcx,1,"POWER GRID")
  122. gpu2:setText(fcx,z,"CAP:  "..Capa.." MWh")
  123. gpu2:setText(fcx,z+2,"USE:  "..Verbr.." MWh")
  124. gpu2:setText(fcx,z+4,"AUSL: "..Ausl.." %")
  125. gpu2:setText(fcx+12,z+4,"[")
  126. gpu2:setText(fcx+23,z+4,"]")
  127. for i = 1,n,1 do
  128. gpu2:setText(xn,z+4,"#")
  129. xn = xn+1
  130. end
  131. gpu2:flush()
  132. end
  133.  
  134.  
  135. -- RUN --
  136.  
  137. while true do
  138. event.pull(1)
  139. getdata()
  140. stream1()
  141. stream2()
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement