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 = 2 -- Anzahl der Tanks
- h = {}
- p = {}
- function getdata()
- V1 = Tank1.fluidcontent
- V1 = math.floor(V1) -- runden --
- if V1 > 2400 then V1 = 2400
- end
- V2 = Tank2.fluidcontent
- V2 = math.floor(V2) -- runden --
- if V2 > 2400 then V2 = 2400
- end
- -- print (V1, V2)
- hx = 1 -- Start h = 1
- VS = {V1, V2}
- for i = 1,T,1 do
- 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
- 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
- -- print(V1, (u-p[hx]), p[hx])
- 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")
- 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