Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Komponenten --
- event.ignoreAll()
- gpu1 = computer.getGPUs(1)[1]
- Screen = component.proxy("FEC3E5EA47C6B134A9613FB0CC51CCD3")
- Tank1 = component.proxy("E19432AE46CCC08F1A5D09969E33CF85")
- Tank2 = component.proxy("98A62C4B4C2233627321D1B30816F8E5")
- gpu1:bindScreen(Screen)
- gpu1:setsize(100,20)
- gpu1:setForeground(1,1,1,1)
- gpu1:setBackground(0,0,0,0)
- -- OPTION --
- Tank1:flush()
- -- Tank2:flush()
- -- DATEN --
- z = 0 -- Zeilenreset
- o = 5 -- oberes ende
- u = o+13 -- unteres ende
- T = 3 -- Anzahl der Tanks
- h = {}
- p = {}
- function getdata()
- VS = {}
- VS = {Tank1.fluidcontent, Tank2.fluidcontent, Tank2.fluidcontent}
- xv = 1 -- Datensatz Start 1
- T = 3 -- Anzahl der Tanks
- for i = 1,T,1 do -- Daten schreiben
- VS[xv] = math.floor(VS[xv]) -- runden --
- if VS[xv] > 2400 then VS[xv] = 2400
- end
- xv = xv +1
- end
- hx = 1 -- Start h = 1
- for i = 1,T,1 do -- Prozente für Balken ausrechnen
- h[hx] = VS[hx]
- p[hx] = math.floor((100/2400)*h[hx]/10)
- -- print ((h[hx]), (p[hx]))
- hx = hx + 1
- end
- end
- -- AUSGABE --
- function stream()
- gpu1:fill(0,0,100,20," ")
- x = 5 -- x Spalte für Anzeigen vom linken Rand
- -- Display Titel --
- 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")
- gpu1:SetBackground(60,60,60,0.3)
- gpu1:fill(5,2,47,1," ")
- function Zahlenformat() -- Anzeige der Zahl je nach Länge der Zahl
- if Z < 10 then Z = " "..h[hx]
- return Z
- end
- if Z < 100 then Z = " "..h[hx]
- return Z
- end
- if Z < 1000 then Z = " "..h[hx]
- return Z
- end
- end
- -- Farbe der Balken festlegen --
- function Balkenfarbe()
- if Z < 400 then gpu1:setBackground(255,0,0,1)
- end
- if Z >= 400 and Z < 2000 then gpu1:setBackground(255,165,0,1)
- end
- if Z >= 2000 then gpu1:setBackground(0,255,0,1)
- end
- end
- -- Tank 1 --
- hx = 1 -- Datensatz 1 starten
- Z = h[hx]
- Balkenfarbe()
- Zahlenformat()
- if VS[hx] < 240 then p[hx] = 1
- end
- gpu1:fill(x+1,u-p[hx],2,p[hx]," ") -- Füllstand Balken zeichnen
- gpu1:setBackground(0,0,0,0)
- gpu1:setText(x,u,"----")
- gpu1:fill(x,o+3,1,10,"|")
- gpu1:fill(x+3,o+3,1,10,"|")
- gpu1:setText(x,o+2,"----")
- gpu1:setText(x,o+1,Z)
- gpu1:setText(x,o,"----")
- gpu1:setText(x,o-1," T1")
- -- Tank 2 --
- x = x + 7 -- Abstand der Anzeigen zueinander
- hx = hx +1
- Z = h[hx]
- Balkenfarbe()
- Zahlenformat()
- if VS[hx] < 240 then p[hx] = 1
- end
- gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
- gpu1:setBackground(0,0,0,0)
- gpu1:setText(x,u,"----")
- gpu1:fill(x,o+3,1,10,"|")
- gpu1:fill(x+3,o+3,1,10,"|")
- gpu1:setText(x,o+2,"----")
- gpu1:setText(x,o+1,Z)
- gpu1:setText(x,o,"----")
- gpu1:setText(x,o-1," T2")
- -- Tank 3 --
- x = x + 7 -- Abstand der Anzeigen zueinander
- hx = hx +1
- Z = h[hx]
- Balkenfarbe()
- Zahlenformat()
- if VS[hx] < 240 then p[hx] = 1
- end
- gpu1:fill(x+1,u-p[hx],2,p[hx]," ")
- gpu1:setBackground(0,0,0,0)
- gpu1:setText(x,u,"----")
- gpu1:fill(x,o+3,1,10,"|")
- gpu1:fill(x+3,o+3,1,10,"|")
- gpu1:setText(x,o+2,"----")
- gpu1:setText(x,o+1,Z)
- gpu1:setText(x,o,"----")
- gpu1:setText(x,o-1," T2")
- gpu1:flush()
- end
- -- RUN --
- while true do
- event.pull(2)
- getdata()
- stream()
- hx = 1
- Z = ""
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement