Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mfsu = {}
- mfsu["1"] = peripheral.wrap("mfsu_3")
- mfsu["2"] = peripheral.wrap("mfsu_4")
- mfsu["3"] = peripheral.wrap("mfsu_5")
- mfsu["4"] = peripheral.wrap("mfsu_6")
- mfsu["5"] = peripheral.wrap("mfsu_7")
- mfsu["6"] = peripheral.wrap("mfsu_8")
- mfsu["7"] = peripheral.wrap("mfsu_9")
- mfsu["8"] = peripheral.wrap("mfsu_10")
- mfsu["9"] = peripheral.wrap("mfsu_11")
- m = peripheral.wrap("monitor_13")
- m.clear()
- storedEU = {}
- storedPerc = {}
- plotter = {}
- printer = {}
- energyTotals = 0
- energyFlow = 0
- function storedTotal()
- energyTotal = 0
- for i = 1,9 do
- energyTotal = energyTotal + mfsu[tostring(i)].getEUStored()
- end
- energyFlow = (energyTotal - energyTotals) / 20
- energyTotals = energyTotal
- energyPercentage = shorten(tostring(energyTotal / 360000000 * 100))
- m.setCursorPos(3,3)
- m.write("Total Energy Stored: "..energyTotal.." EU")
- m.setCursorPos(9,4)
- m.write("Total Capacity: ")
- colorPerc(energyPercentage)
- end
- function storedEach()
- for i = 1,9 do
- storedEU[i] = mfsu[tostring(i)].getEUStored()
- storedPerc[i] = shorten(tostring(storedEU[i] / 40000000 * 100))
- end
- m.setCursorPos(1,6)
- for i = 1,3 do
- m.write("MFSU"..i..": ")
- colorPerc(storedPerc[i])
- xPos = i * 14
- m.setCursorPos(xPos,6)
- end
- m.setCursorPos(1,7)
- for i = 4,6 do
- m.write("MFSU"..i..": ")
- colorPerc(storedPerc[i])
- xPos = (i-3) * 14
- m.setCursorPos(xPos,7)
- end
- m.setCursorPos(1,8)
- for i = 7,9 do
- m.write("MFSU"..i..": ")
- colorPerc(storedPerc[i])
- xPos = (i-6) * 14
- m.setCursorPos(xPos,8)
- end
- end
- function shorten(num)
- if num ~= nil then
- dec = string.find(tostring(num),".",1,true)
- if dec ~= nil then
- dec = dec + 1
- return (string.sub(num,1,dec))
- end
- else
- return ("0")
- end
- end
- function percRound(num)
- subW,subR,whole,remainder = 0,0,0,0
- subW,subR = string.len(num) - 2 , string.len(num)
- whole = tonumber(string.sub(num,1,subW))
- remainder = tonumber(string.sub(num,subR,subR))
- if remainder >= 5 then
- whole = whole + 1
- end
- return whole
- end
- function colorPerc(num)
- num = tonumber(num)
- if num ~= nil then
- if num >= 0 then
- m.setTextColor(colors.red)
- end
- if num > 30 then
- m.setTextColor(colors.orange)
- end
- if num > 60 then
- m.setTextColor(colors.yellow)
- end
- if num > 90 then
- m.setTextColor(colors.lime)
- end
- m.write(num.."%")
- space = string.len(tostring(num)) - 5 * (-1)
- for i = 1,space do
- m.write(" ")
- end
- m.setTextColor(colors.white)
- end
- end
- function flowChart()
- for i = 1,15 do
- m.setCursorPos(6,(i + 10))
- m.write("|")
- end
- for i = 1,39 do
- m.setCursorPos(i,26)
- m.write("-")
- end
- for i = 1,15 do
- m.setCursorPos(34,(i + 10))
- m.write("|")
- end
- for i = 1,2 do
- if i == 1 then
- yP = 1
- else
- yP = 35
- end
- m.setCursorPos(yP,11)
- m.write("2.1k ")
- m.setCursorPos(yP,13)
- m.write("1.5k ")
- m.setCursorPos(yP,15)
- m.write(" 900 ")
- m.setCursorPos(yP,17)
- m.write(" 300 ")
- m.setCursorPos(yP,19)
- m.write("-300 ")
- m.setCursorPos(yP,21)
- m.write("-900 ")
- m.setCursorPos(yP,23)
- m.write("-1.5k")
- m.setCursorPos(yP,25)
- m.write("-2.1k")
- end
- end
- function drawPlots()
- m.setCursorPos(12,26)
- m.write("--("..energyFlow.." EU/t)--------")
- yPos = plotPos(energyFlow) + 18
- printer[34] = yPos
- for i = 7,33 do
- j = i + 1
- h = i
- printer[i] = printer[j]
- for i = 11,25 do
- m.setCursorPos(h,i)
- if i == printer[h] then
- if i < 18 then
- m.setBackgroundColor(colors.cyan)
- else
- m.setBackgroundColor(colors.blue)
- end
- else
- m.setBackgroundColor(colors.black)
- end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- end
- end
- end
- function plotPos(num)
- plotter,plotW,plotR = 0,0,0
- plotter = energyFlow / 300
- if plotter < 0 then
- plotW = tonumber(string.sub(tostring(plotter),2,2))
- plotR = tonumber(string.sub(tostring(plotter),4,4))
- negative = true
- else
- plotW = tonumber(string.sub(tostring(plotter),1,1))
- plotR = tonumber(string.sub(tostring(plotter),3,3))
- negative = false
- end
- if plotR ~= nil then
- if plotR >= 5 then
- plotW = plotW + 1
- end
- end
- if negative == false then
- plotW = plotW * (-1)
- end
- return plotW
- end
- function label()
- m.setCursorPos(13,1)
- m.write("Energy Monitor")
- m.setCursorPos(1,10)
- m.write("---------- Energy Flow (EU/t)----------")
- end
- label()
- flowChart()
- while true do
- storedTotal()
- storedEach()
- drawPlots()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment