Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bCol = colors.black
- local tCol = colors.white
- local monSide = "top"
- local reactorCoords = {178,35,5563}
- local senIC2Side = "bottom"
- local senIC2Coords = {185,36,5563}
- local senInvSide = "left"
- local senInvCoords = {185,37,5564}
- local bunSide = "back"
- --text,displayColor,cableColor
- local status = {}
- status[1] = { "Reaktor abgeschaltet.", colors.gray, 0}
- status[2] = { "Keine Stoerungen gefunden.", colors.blue, colors.white}
- status[3] = { "Keine Uranzellen vorhanden.",colors.orange, colors.orange}
- status[4] = {"Keine Isotopezellen vorhanden.",colors.orange, colors.magenta}
- status[5] = { "Kein Lapis Lazuli vorhanden.",colors.orange,colors.lightBlue}
- status[6] = { "Spieler nicht online.",colors.orange, colors.yellow}
- status[7] = { "Reaktor ueberhitzt.", colors.red, colors.lime}
- os.loadAPI("ocs/apis/sensor")
- local m = peripheral.wrap(monSide)
- m.setTextScale(.5)
- local xMax,yMax = m.getSize()
- local damageVal = {}
- --Uranium Cells
- damageVal[1] = {}
- damageVal[1][1] = {"Uranium Cell","Dual Uranium Cell","Quad Uranium Cell"}
- damageVal[1][2] = {}
- --Isotope and Re-Enriched Cells
- damageVal[2] = {}
- damageVal[2][1] = {"Depleted Isotope Cell","Re-Enriched Uranium Cell"}
- damageVal[2][2] = {}
- --Reactor Components
- damageVal[3] = {}
- damageVal[3][1] = {"Heat Vent","Reactor Heat Vent","Overclocked Heat Vent","Advanced Heat Vent","Component Heat Vent","Heat Exchanger","Reactor Heat Exchanger","Component Heat Exchanger","Advanced Heat Exchanger","RSH-Condensator","LZH-Condensator","Neutron Reflector","Thick Neutron Reflector","10k Coolant Cell","30k Coolant Cell","60k Coolant Cell"}
- damageVal[3][2] = {}
- --Status,Output,Heat,MaxHeat,damageVal(array)
- local reactorInfo = {}
- reactorInfo[5] = {}
- function JoJa()
- m.setBackgroundColor(colors.gray)
- m.setCursorPos(1,1)
- for xP = 1,xMax do
- m.write(" ")
- end
- m.setCursorPos(1,1)
- m.setTextColor(colors.cyan)
- m.write("Jo")
- m.setTextColor(colors.orange)
- m.write("Ja ")
- m.setTextColor(colors.lightGray)
- m.write("Productions")
- end
- function drawField(xStart,yStart,xEnd,yEnd,col)
- m.setBackgroundColor(col)
- for yP = yStart,yEnd do
- m.setCursorPos(xStart,yP)
- for xP = xStart,xEnd do
- m.write(" ")
- end
- end
- end
- function bg(col)
- drawField(0,0,xMax,yMax,col)
- end
- function drawFrame(xStart,yStart,xEnd,yEnd,col1,col2,txt)
- drawField(xStart,yStart,xEnd,yEnd,col1)
- drawField(xStart+1,yStart+1,xEnd-1,yEnd-1,col2)
- m.setCursorPos(xStart+2,yStart)
- m.write(" "..txt.." ")
- end
- function showStat()
- local i
- for i = 1,#status do
- if colors.test(rs.getBundledInput(bunSide),status[i][3]) then
- txt = status[i][1]
- col = status[i][2]
- end
- end
- drawField(xMax/2+9, 6,xMax-3,10,col)
- local arr = {}
- i = 1
- local p = string.find(txt," ")
- while p ~= nil do
- arr[i] = string.sub(txt,1,p-1)
- txt = string.sub(txt,p+1)..""
- i = i+1
- p = string.find(txt," ")
- end
- arr[i] = txt
- local j = 1
- i = 1
- temp = arr[1]
- while true do
- i = i+1
- if i > #arr then break end
- while #temp+#arr[i] <= (xMax-4)-(xMax/2+10) do
- temp = temp.." "..arr[i]
- i = i+1
- if i >= #arr then break end
- end
- m.setCursorPos(xMax/2+10,6+j)
- m.write(temp)
- j = j+1
- temp = arr[i]
- end
- m.setCursorPos(xMax/2+10,6+j)
- m.write(temp)
- end
- function drawGraph(xStart,yStart,xEnd,yEnd,col1,col2,val)
- local temp = xStart+math.floor((xEnd-xStart)*(val/100)+.5)
- if temp > xEnd then temp = xEnd end
- for yP = yStart,yEnd do
- m.setCursorPos(xStart,yP)
- m.setBackgroundColor(col1)
- for xP = xStart,temp do
- m.write(" ")
- end
- m.setBackgroundColor(col2)
- if temp+1 <= xEnd then
- for xP = xStart+math.floor((xEnd-xStart)*(val/100)+.5)+1,xEnd do
- m.write(" ")
- end
- end
- end
- end
- function checkIC2Reactor()
- local s = sensor.wrap(senIC2Side)
- for k1,v1 in pairs(s.getTargets()) do
- if v1.Name == "Nuclear Reactor"
- and v1.Position.X == reactorCoords[1]-senIC2Coords[1]
- and v1.Position.Y == reactorCoords[2]-senIC2Coords[2]
- and v1.Position.Z == reactorCoords[3]-senIC2Coords[3] then
- for k2,v2 in pairs(s.getTargetDetails(k1)) do
- if k2 == "Active" then
- reactorInfo[1] = v2
- elseif k2 == "Output" then
- reactorInfo[2] = v2
- elseif k2 == "Heat" then
- reactorInfo[3] = v2
- elseif k2 == "MaxHeat" then
- reactorInfo[4] = v2
- end
- end
- end
- end
- end
- function checkInvReactor()
- for i = 1,#damageVal do
- damageVal[i][2][1] = 0
- damageVal[i][2][2] = 0
- end
- local s = sensor.wrap(senInvSide)
- for k1,v1 in pairs(s.getTargets()) do
- if v1.Name == "Nuclear Reactor"
- and v1.Position.X == reactorCoords[1]-senInvCoords[1]
- and v1.Position.Y == reactorCoords[2]-senInvCoords[2]
- and v1.Position.Z == reactorCoords[3]-senInvCoords[3] then
- for k2,v2 in pairs(s.getTargetDetails(k1)) do
- if k2 == "Slots" then
- for i = 1,#v2 do
- for j1 = 1,#damageVal do
- for j2 = 1,#damageVal[j1][1] do
- if v2[i].Name == damageVal[j1][1][j2] then
- damageVal[j1][2][1] = damageVal[j1][2][1]+v2[i].DamageValue
- damageVal[j1][2][2] = damageVal[j1][2][2]+v2[i].Size
- end
- end
- end
- end
- end
- end
- end
- end
- for i = 1,#damageVal do
- reactorInfo[5][i] = 100-((damageVal[i][2][1]/damageVal[i][2][2])/99.9)
- if tostring(reactorInfo[5][i]) == "nan" or reactorInfo[5][i] < 0 then
- reactorInfo[5][i] = 0
- end
- end
- end
- bg(bCol)
- JoJa()
- m.setTextColor(tCol)
- drawFrame(3, 4,xMax/2+4,22,colors.gray,bCol,"Info.")
- m.setCursorPos(5,6)
- m.write("Status:")
- m.setCursorPos(5,8)
- m.write("Output:")
- m.setCursorPos(5,10)
- m.write("Uranium")
- m.setCursorPos(5,14)
- m.write("Komponenten")
- m.setCursorPos(5,18)
- m.write("Hitze")
- drawFrame(xMax/2+7, 4,xMax-1,12,colors.gray,bCol,"Status")
- drawFrame(xMax/2+7,14,xMax-1,22,colors.gray,bCol,"Menue")
- while true do
- local temp
- local time = textutils.formatTime(os.time(), true)
- checkIC2Reactor()
- checkInvReactor()
- m.setBackgroundColor(colors.gray)
- temp = " "
- for i = 1,2 do
- m.setCursorPos(xMax+1-#temp,1)
- m.write(temp)
- temp = time
- end
- m.setBackgroundColor(bCol)
- m.setCursorPos(xMax/2,6)
- if reactorInfo[1] then
- m.setTextColor(colors.lime)
- m.write(" AN")
- else
- m.setTextColor(colors.red)
- m.write("AUS")
- end
- m.setTextColor(tCol)
- temp = " "
- for i = 1,2 do
- m.setCursorPos(xMax/2+3-#temp,8)
- m.write(temp)
- temp = tostring(reactorInfo[2]).." eu/t"
- end
- drawGraph(5,11,xMax/2+2,11, colors.lime,colors.lightGray,reactorInfo[5][1])
- drawGraph(5,12,xMax/2+2,12,colors.yellow,colors.lightGray,reactorInfo[5][2])
- drawGraph(5,15,xMax/2+2,16, colors.cyan,colors.lightGray,reactorInfo[5][3])
- drawGraph(5,19,xMax/2+2,20, colors.red,colors.lightGray,(reactorInfo[3]/reactorInfo[4])*100)
- showStat()
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment