SHOW:
|
|
- or go back to the newest paste.
1 | -- Komponenten -- | |
2 | event.ignoreAll() | |
3 | gpu1 = computer.getGPUs(1)[1] | |
4 | - | Screen = component.proxy("FEC3E5EA47C6B134A9613FB0CC51CCD3") |
4 | + | Screen = component.proxy("27982CDC4CD4B0C3C4B874A848A7A007") |
5 | Tank1 = component.proxy("E19432AE46CCC08F1A5D09969E33CF85") | |
6 | - | Tank2 = component.proxy("98A62C4B4C2233627321D1B30816F8E5") |
6 | + | Tank2 = component.proxy("5A8736A345158E9700D710BDF83AB387") |
7 | Tank3 = component.proxy("6681E56349AD7FABB0E07B8A69148B2A") | |
8 | Tank4 = component.proxy("7082385B48C55BF5B1E64E94D30BD8BF") | |
9 | Tank5 = component.proxy("F102D89B4394932DF65DA2BCA05323A5") | |
10 | Tank6 = component.proxy("5B8B130D496D10FF3B486596D99BF3DF") | |
11 | Tank7 = component.proxy("6347B26B42EA2FBA38232BBB58B7EA30") | |
12 | Tank8 = component.proxy("9BA0A46E414F3B1F722789898807FF32") | |
13 | Tank9 = component.proxy("9CA14D0D412674B09226569E0864E5E1") | |
14 | Tank10 = component.proxy("EE90BD0248789F7897BD07BE730693A8") | |
15 | Tank11 = component.proxy("BA3F48844C6CCA90D53AF995FC630383") | |
16 | Tank12 = component.proxy("52C78C1D4D8657F2BD241C8F632C283E") | |
17 | Tank13 = component.proxy("117A436640B42B5BCEB4C9B8D067E1CA") | |
18 | ||
19 | ||
20 | gpu1:bindScreen(Screen) | |
21 | - | T = 3 -- Anzahl der Tanks |
21 | + | |
22 | gpu1:setForeground(1,1,1,1) | |
23 | gpu1:setBackground(0,0,0,0) | |
24 | ||
25 | -- OPTION -- | |
26 | Tank1:flush() | |
27 | -- Tank2:flush() | |
28 | - | VS = {Tank1.fluidcontent, Tank2.fluidcontent, Tank2.fluidcontent} |
28 | + | |
29 | -- DATEN -- | |
30 | z = 0 -- Zeilenreset | |
31 | - | T = 3 -- Anzahl der Tanks |
31 | + | |
32 | u = o+13 -- unteres ende | |
33 | T = 13 -- Anzahl der Tanks | |
34 | h = {} | |
35 | p = {} | |
36 | ||
37 | function getdata() | |
38 | ||
39 | VS = {} | |
40 | VS = {Tank1.fluidcontent, Tank2.fluidcontent, Tank3.fluidcontent, Tank4.fluidcontent, Tank5.fluidcontent, Tank6.fluidcontent, Tank7.fluidcontent, Tank8.fluidcontent, Tank9.fluidcontent, Tank10.fluidcontent, Tank11.fluidcontent, Tank12.fluidcontent, Tank13.fluidcontent} | |
41 | ||
42 | xv = 1 -- Datensatz Start 1 | |
43 | T = 13 -- Anzahl der Tanks | |
44 | ||
45 | for i = 1,T,1 do -- Daten schreiben | |
46 | VS[xv] = math.floor(VS[xv]) -- runden -- | |
47 | if VS[xv] > 2400 then VS[xv] = 2400 | |
48 | end | |
49 | xv = xv +1 | |
50 | end | |
51 | ||
52 | hx = 1 -- Start h = 1 | |
53 | for i = 1,T,1 do -- Prozente für Balken ausrechnen | |
54 | h[hx] = VS[hx] | |
55 | p[hx] = math.floor((100/2400)*h[hx]/10) | |
56 | -- print ((h[hx]), (p[hx])) | |
57 | hx = hx + 1 | |
58 | end | |
59 | end | |
60 | ||
61 | -- AUSGABE -- | |
62 | function stream() | |
63 | gpu1:fill(0,0,100,20," ") | |
64 | ||
65 | x = 5 -- x Spalte für Anzeigen vom linken Rand | |
66 | ||
67 | -- Display Titel -- | |
68 | gpu1:setText(5,1,"S U P E R C O M P U T E R // F U E L T A N K S") | |
69 | gpu1:SetBackground(60,60,60,0.3) | |
70 | gpu1:fill(5,2,47,1," ") | |
71 | ||
72 | function Zahlenformat() -- Anzeige der Zahl je nach Länge der Zahl | |
73 | if Z < 10 then Z = " "..h[hx] | |
74 | return Z | |
75 | end | |
76 | ||
77 | if Z < 100 then Z = " "..h[hx] | |
78 | return Z | |
79 | end | |
80 | ||
81 | if Z < 1000 then Z = " "..h[hx] | |
82 | return Z | |
83 | end | |
84 | end | |
85 | ||
86 | -- Farbe der Balken festlegen -- | |
87 | function Balkenfarbe() | |
88 | if Z < 400 then gpu1:setBackground(255,0,0,1) | |
89 | end | |
90 | if Z >= 400 and Z < 2000 then gpu1:setBackground(255,165,0,1) | |
91 | end | |
92 | if Z >= 2000 then gpu1:setBackground(0,255,0,1) | |
93 | end | |
94 | end | |
95 | ||
96 | ||
97 | -- Tank 1 -- | |
98 | hx = 1 -- Datensatz 1 starten | |
99 | Z = h[hx] | |
100 | Balkenfarbe() | |
101 | Zahlenformat() | |
102 | if VS[hx] < 240 then p[hx] = 1 | |
103 | end | |
104 | gpu1:fill(x+1,u-p[hx],2,p[hx]," ") -- Füllstand Balken zeichnen | |
105 | gpu1:setBackground(0,0,0,0) | |
106 | gpu1:setText(x,u,"----") | |
107 | gpu1:fill(x,o+3,1,10,"|") | |
108 | gpu1:fill(x+3,o+3,1,10,"|") | |
109 | gpu1:setText(x,o+2,"----") | |
110 | gpu1:setText(x,o+1,Z) | |
111 | gpu1:setText(x,o,"----") | |
112 | gpu1:setText(x,o-1," T1") | |
113 | ||
114 | -- Tank 2 -- | |
115 | x = x + 7 -- Abstand der Anzeigen zueinander | |
116 | hx = hx +1 | |
117 | Z = h[hx] | |
118 | Balkenfarbe() | |
119 | Zahlenformat() | |
120 | if VS[hx] < 240 then p[hx] = 1 | |
121 | end | |
122 | gpu1:fill(x+1,u-p[hx],2,p[hx]," ") | |
123 | gpu1:setBackground(0,0,0,0) | |
124 | gpu1:setText(x,u,"----") | |
125 | gpu1:fill(x,o+3,1,10,"|") | |
126 | gpu1:fill(x+3,o+3,1,10,"|") | |
127 | gpu1:setText(x,o+2,"----") | |
128 | gpu1:setText(x,o+1,Z) | |
129 | gpu1:setText(x,o,"----") | |
130 | gpu1:setText(x,o-1," T2") | |
131 | ||
132 | -- Tank 3 -- | |
133 | x = x + 7 -- Abstand der Anzeigen zueinander | |
134 | hx = hx +1 | |
135 | Z = h[hx] | |
136 | Balkenfarbe() | |
137 | Zahlenformat() | |
138 | if VS[hx] < 240 then p[hx] = 1 | |
139 | end | |
140 | gpu1:fill(x+1,u-p[hx],2,p[hx]," ") | |
141 | gpu1:setBackground(0,0,0,0) | |
142 | gpu1:setText(x,u,"----") | |
143 | gpu1:fill(x,o+3,1,10,"|") | |
144 | gpu1:fill(x+3,o+3,1,10,"|") | |
145 | gpu1:setText(x,o+2,"----") | |
146 | gpu1:setText(x,o+1,Z) | |
147 | gpu1:setText(x,o,"----") | |
148 | gpu1:setText(x,o-1," T3") | |
149 | ||
150 | gpu1:flush() | |
151 | end | |
152 | ||
153 | -- RUN -- | |
154 | while true do | |
155 | event.pull(2) | |
156 | getdata() | |
157 | stream() | |
158 | hx = 1 | |
159 | Z = "" | |
160 | end |