Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- local monSide = "back"
- local Rside = "left"
- local Sensor = "top"
- local OPD = "front"
- local Stat = true
- mon = peripheral.wrap(monSide)
- mon.setTextScale(.5)
- local xMax,yMax = mon.getSize()
- function Background(col)
- mon.setBackgroundColor(col)
- for xPos = 1,xMax do
- for yPos = 1,yMax do
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- end
- end
- function JoJa(xPos,yPos)
- mon.setCursorPos(xPos,yPos)
- mon.setBackgroundColor(colors.gray)
- mon.setTextColor(colors.cyan)
- mon.write("Jo")
- mon.setTextColor(colors.orange)
- mon.write("Ja ")
- mon.setTextColor(colors.lightGray)
- mon.write("Productions")
- mon.setBackgroundColor(colors.gray)
- mon.setTextColor(colors.white)
- end
- function edge(startPosX,startPosY,endPosX,endPosY)
- mon.setBackgroundColor(colors.gray)
- for xPos = startPosX,endPosX do
- mon.setCursorPos(xPos,startPosY)
- mon.write(" ")
- mon.setCursorPos(xPos,endPosY)
- mon.write(" ")
- end
- for yPos = startPosY,endPosY do
- mon.setCursorPos(startPosX,yPos)
- mon.write(" ")
- mon.setCursorPos(endPosX,yPos)
- mon.write(" ")
- end
- end
- function overlay(xPos,yPos,text)
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(xPos,yPos)
- mon.write(text)
- end
- function checkMFSU()
- Anzahl = 1
- Speicher = {}
- sen = sensor.wrap(Sensor)
- for a,b in pairs(sen.getTargets()) do
- for k,v in pairs(sen.getTargetDetails(a)) do
- if type(v) == "table" then
- else
- if k == "StoredPercentage" then
- Speicher[Anzahl] = v
- Anzahl = Anzahl+1
- end
- end
- end
- end
- end
- function graph(xStart,xEnd,yPos,Percentage,col1,col2)
- for xPos = xStart,xEnd do
- mon.setBackgroundColor(col1)
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- Width = ((xEnd-xStart)*Percentage)/100
- for xPos = xStart,xStart+Width do
- mon.setCursorPos(xPos,yPos)
- mon.setBackgroundColor(col2)
- mon.write(" ")
- end
- end
- function Button(xP1,yP1,xP2,yP2,txt1,txt2,col)
- mon.setBackgroundColor(col)
- for xPos = xP1,xP2 do
- for yPos = yP1,yP2 do
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- end
- mon.setCursorPos((xP1+((xP2-xP1)/2))-#txt1/2,(yP1+(yP2-yP1)/2))
- mon.write(txt1)
- mon.setCursorPos((xP1+((xP2-xP1)/2))-#txt2/2,(yP1+1+(yP2-yP1)/2))
- mon.write(txt2)
- mon.setBackgroundColor(colors.black)
- end
- function checkButton()
- os.startTimer(10)
- event,_,xPos,yPos = os.pullEvent()
- if event == "monitor_touch"
- and xPos >= 49 and xPos <= 61
- and yPos >= 24 and yPos <= 29
- then
- Stat = true
- elseif event == "monitor_touch"
- and xPos >= 64 and xPos <= 79
- and xPos >= 24 and yPos <= 29
- then
- Stat = false
- end
- print(Stat)
- end
- while true do
- checkMFSU()
- MaxOutput = #Speicher * 512
- Kapazitaet = #Speicher * 10000000
- Background(colors.black)
- JoJa(xMax/2-7,1)
- edge(2,3,45,yMax-1)
- edge(47,3,xMax-1,20)
- edge(47,22,xMax-1,yMax-1)
- overlay(4,3," Info ")
- overlay(49,3," Data ")
- overlay(49,22," Menu ")
- overlay(50,5,"MaxOutput: "..MaxOutput.." Eu/t")
- overlay(50,7,"Kapazitaet: "..Kapazitaet.." Eu")
- overlay(50,11,"Stromfluss: ")
- if Stat then
- mon.setTextColor(colors.cyan)
- mon.write("aktiviert")
- else
- mon.setTextColor(colors.orange)
- mon.write("deaktiviert")
- end
- mon.setTextColor(colors.white)
- F = 0
- for i = 1,#Speicher do
- F = F+Speicher[i]
- end
- F = math.floor(F/#Speicher)
- overlay(50,9,"Gefuellt: "..F.." %")
- A = #Speicher
- if A > 10 then
- B = A-10
- A = 10
- end
- --print(B)
- for i = 1,A do
- overlay(4,2+3*i,"MFSU "..i.." ")
- graph(4,22,3+3*i,Speicher[i],colors.lightGray,colors.lime)
- end
- if B ~= nil then
- for l = 1,B do
- overlay(24,2+3*l,"MFSU "..10+l.." ")
- graph(24,43,3+3*l,Speicher[10+l],colors.lightGray,colors.lime)
- end
- end
- Button(49,24,61,29,"Stromfluss","aktivieren",colors.cyan)
- Button(64,24,76,29,"Stromfluss","deaktivieren",colors.orange)
- checkButton()
- if Stat then
- rs.setOutput(Rside,true)
- else
- rs.setOutput(Rside,false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment