Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- local monSide = "top"
- local Rside = "back"
- local OPD = "front"
- local Ic2sensor = "left"
- local xPosIc2 = 1
- local yPosIc2 = -3
- local zPosIc2 = 1
- local Invsensor = "right"
- local xPosInv = 1
- local yPosInv = -3
- local zPosInv = -1
- -- Stat true = Reactor laeuft beim starten, Stat false, Reaktor aus beim starten
- local Stat = false
- mon = peripheral.wrap(monSide)
- 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.black)
- 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 checkIC2()
- sen = sensor.wrap(Ic2sensor)
- for a,b in pairs(sen.getTargets()) do
- if b.Name == "Nuclear Reactor"
- and b.Position.X == xPosIc2
- and b.Position.Y == yPosIc2
- and b.Position.Z == zPosIc2
- then
- print("Reaktor detection complete. X: "..b.Position.X.." Y: "..b.Position.Y.." Z: "..b.Position.Z)
- for k,v in pairs(sen.getTargetDetails(a)) do
- if type(v) == "table" then
- else
- if k == "Active" then
- term.write("Reaktor: ")
- if v == true then
- Status = true
- print("AN")
- else
- Status = false
- print("AUS")
- end
- end
- if k == "Output" then
- print("Output: "..v.." eu/t")
- Output = v
- end
- if k == "Heat" then
- print("Heat: "..v)
- Heat = v
- end
- if k == "MaxHeat" then
- print("maxHeat: "..v)
- maxHeat = v
- end
- end
- end
- end
- end
- end
- function checkInv()
- Name = {}
- Schaden = {}
- sUranC = 0
- dUranC = 0
- qUranC = 0
- Schaden = 0
- Anzahl = 0
- SchadenR = 0
- AnzahlR = 0
- sen = sensor.wrap(Invsensor)
- for k,v in pairs(sen.getTargets()) do
- if v.Name == "Nuclear Reactor"
- and v.Position.X == xPosInv
- and v.Position.Y == yPosInv
- and v.Position.Z == zPosInv
- then
- details = sen.getTargetDetails(k)
- Slots = #details.Slots
- for Slot = 1,Slots do
- Name[Slot] = details.Slots[Slot].Name
- if Name[Slot] == "Uranium Cell" then
- sUranC = sUranC+1
- elseif Name[Slot] == "Dual Uranium Cell" then
- dUranC = dUranC+1
- elseif Name[Slot] == "Quad Uranium Cell" then
- qUranC = qUranC+1
- end
- if Name[Slot] == "Uranium Cell"
- or Name[Slot] == "Dual Uranium Cell"
- or Name[Slot] == "Quad Uranium Cell"
- then
- Schaden = Schaden + details.Slots[Slot].DamageValue
- Anzahl = Anzahl + 1
- else
- if Name[Slot] ~= "empty" then
- SchadenR = 0
- AnzahlR = 0
- SchadenR = SchadenR + details.Slots[Slot].DamageValue
- AnzahlR = AnzahlR + 1
- end
- end
- end
- end
- end
- end
- function graph(Wert1,Wert2,xPos,xMax,yPos,col1,col2)
- mon.setBackgroundColor(col2)
- for xP = xPos,xMax do
- mon.setCursorPos(xP,yPos)
- mon.write(" ")
- mon.setCursorPos(xP,yPos+1)
- mon.write(" ")
- end
- percentageWert = (Wert1/Wert2)*100
- space = xMax-xPos
- mon.setBackgroundColor(col1)
- for xP = xPos,xPos+math.floor(space*(percentageWert/100)) do
- mon.setCursorPos(xP,yPos)
- mon.write(" ")
- mon.setCursorPos(xP,yPos+1)
- mon.write(" ")
- end
- end
- function graph2(Wert1,Wert2,xPos,xMax,yPos,col1,col2)
- mon.setBackgroundColor(col2)
- for xP = xPos,xMax do
- mon.setCursorPos(xP,yPos)
- mon.write(" ")
- mon.setCursorPos(xP,yPos+1)
- mon.write(" ")
- end
- percentageWert = 100-((Wert1/Wert2)*100)
- space = xMax-xPos
- mon.setBackgroundColor(col1)
- for xP = xPos,xPos+math.floor(space*(percentageWert/100)) do
- mon.setCursorPos(xP,yPos)
- mon.write(" ")
- mon.setCursorPos(xP,yPos+1)
- mon.write(" ")
- end
- end
- function Button(xP1,xP2,yP1,yP2,col)
- mon.setBackgroundColor(col)
- for xPos = xP1,xP2 do
- for yPos = yP1,yP2 do
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function checkButton()
- os.startTimer(10)
- event,_,xPos,yPos = os.pullEvent()
- if event == "monitor_touch"
- and xPos >= 33 and xPos <= xMax-10
- and yPos >= 14 and yPos <= yMax-2
- then
- Stat = true
- elseif event == "monitor_touch"
- and xPos >= xMax-9 and xPos <= xMax-2
- and yPos >= 14 and yPos <= yMax-2
- then
- Stat = false
- end
- if event == "timer" then
- print("time out")
- end
- end
- while true do
- if rs.getInput(OPD) then
- checkIC2()
- checkInv()
- Background(colors.black)
- JoJa(xMax/2-7,1)
- edge(2,3,30,yMax-1)
- mon.setTextColor(colors.white)
- overlay(4,3," Info ")
- overlay(3,5," Heat ")
- graph(Heat,maxHeat,4,28,6,colors.red,colors.lightGray)
- overlay(3,9," Durability Uran ")
- graph2(Schaden/Anzahl,10000,4,28,10,colors.lime,colors.lightGray)
- overlay(3,13," Durability Components ")
- graph2(SchadenR/AnzahlR,10000,4,28,14,colors.cyan,colors.lightGray)
- edge(32,3,xMax-1,11)
- overlay(34,3," Data ")
- overlay(33,5," Status: ")
- if Status then
- mon.setTextColor(colors.lime)
- mon.write("ON ")
- mon.setTextColor(colors.white)
- else
- mon.setTextColor(colors.red)
- mon.write("OFF")
- mon.setTextColor(colors.white)
- end
- overlay(33,6," Output: "..Output.."eu/t")
- overlay(33,7," s.UranC:"..sUranC)
- overlay(33,8," d.UranC:"..dUranC)
- overlay(33,9," q.UranC:"..qUranC)
- edge(32,13,xMax-1,yMax-1)
- overlay(34,13," Menu ")
- Button(33,xMax-10,14,yMax-2,colors.lime)
- Button(xMax-9,xMax-2,14,yMax-2,colors.red)
- mon.setBackgroundColor(colors.lime)
- mon.setCursorPos(34,15)
- mon.write("Reactor")
- mon.setCursorPos(36,16)
- mon.write("ON")
- mon.setBackgroundColor(colors.black)
- mon.setBackgroundColor(colors.red)
- mon.setCursorPos(xMax-8,15)
- mon.write("Reactor")
- mon.setCursorPos(xMax-6,16)
- mon.write("OFF")
- mon.setBackgroundColor(colors.black)
- checkButton()
- rs.setOutput(Rside, Stat)
- else
- Background(colors.black)
- JoJa(xMax/2-7,1)
- mon.setCursorPos(xMax/2-4,yMax/2)
- mon.setTextColor(colors.gray)
- mon.write("offline")
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment