Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mat = peripheral.find("inductionPort")
- mon = peripheral.find("monitor")
- monX,monY = mon.getSize()
- --Func math.round & textcenter
- function math.round(num, dec)
- local mult = 10^(dec or 2)
- return math.floor(num * mult + 0.5) / mult
- end
- function centerT(text,line,backColor,txtColor)
- mon.setBackgroundColor(backColor)
- mon.setTextColor(txtColor)
- length = (string.len(text))
- dif= math.round(monX-length)
- x = math.round(dif/2)
- mon.setCursorPos(x+1, line)
- mon.write(text)
- end
- --Import & Def value
- function value()
- Energy = mat.getEnergy()
- MaxEnergy = mat.getMaxEnergy()
- EnergyPer = math.round(mat.getEnergyFilledPercentage()*100)
- LastInput = mat.getLastInput()
- LastOutput = mat.getLastOutput()
- TransferCap = mat.getTransferCap()
- IO = math.floor(mat.getLastInput() - mat.getLastOutput())
- Cell = mat.getInstalledCells()
- Provider = mat.getInstalledProviders()
- end
- --Func write
- function writeMon()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- if Energy >= 1000 and Energy < 1000000 then
- title = "Energie: "..math.round((Energy/2.5)/1000).." / "..math.round((MaxEnergy/2.5)/1000).." kFe"
- centerT(title, 3, colors.black, colors.blue)
- elseif Energy >= 1000000 and Energy < 1000000000 then
- title = "Energie: "..math.round((Energy/2.5)/1000000).." / "..math.round((MaxEnergy/2.5)/1000000).." MFe"
- centerT(title, 3, colors.black, colors.blue)
- elseif Energy >= 1000000000 then
- title = "Energie: "..math.round((Energy/2.5)/1000000000).." / "..math.round((MaxEnergy/2.5)/1000000000).." GFe"
- centerT(title, 3, colors.black, colors.blue)
- end
- if LastInput >= 0 and LastInput < 1000 then
- title = "Input: "..math.round(LastInput/2.5).." / "..math.round(TransferCap/2.5).." Fe"
- centerT(title, 5, colors.black, colors.green)
- elseif LastInput >= 1000 and LastInput < 1000000 then
- title = "Input: "..math.round((LastInput/2.5)/1000).." / "..math.round((TransferCap/2.5)/1000).." kFe"
- centerT(title, 5, colors.black, colors.green)
- elseif LastInput >= 1000000 and LastInput < 1000000000 then
- title = "Input: "..math.round((LastInput/2.5)/1000000).." / "..math.round((TransferCap/2.5)/1000000).." MFe"
- centerT(title, 5, colors.black, colors.green)
- elseif LastInput >= 1000000000 then
- title = "Input: "..math.round((LastInput/2.5)/1000000000).." / "..math.round((TransferCap/2.5)/1000000000).." GFe"
- centerT(title, 5, colors.black, colors.green)
- end
- if LastOutput >= 0 and LastOutput < 1000 then
- title = "Output: "..math.round(LastOutput/2.5).." / "..math.round(TransferCap/2.5).." Fe"
- centerT(title, 7, colors.black, colors.red)
- elseif LastOutput >= 1000 and LastOutput < 1000000 then
- title = "Output: "..math.round((LastOutput/2.5)/1000).." / "..math.round((TransferCap/2.5)/1000).." kFe"
- centerT(title, 7, colors.black, colors.red)
- elseif LastOutput >= 1000000 and LastOutput < 1000000000 then
- title = "Output: "..math.round((LastOutput/2.5)/1000000).." / "..math.round((TransferCap/2.5)/1000000).." MFe"
- centerT(title, 7, colors.black, colors.red)
- elseif LastOutput >= 1000000000 then
- title = "Output: "..math.round((LastOutput/2.5)/1000000000).." / "..math.round((TransferCap/2.5)/1000000000).." GFe"
- centerT(title, 7, colors.black, colors.red)
- end
- if IO >= 0 and IO < 1000 then
- title = "IO: "..math.round(IO/2.5).." Fe/t"
- centerT(title, 9, colors.black, colors.orange)
- elseif IO >= 1000 and IO < 1000000 then
- title = "IO: "..math.round((IO/2.5)/1000).." kFe/t"
- centerT(title, 9, colors.black, colors.orange)
- elseif IO >= 1000000 and IO < 1000000000 then
- title = "IO: "..math.round((IO/2.5)/1000000).." MFe/t"
- centerT(title, 9, colors.black, colors.orange)
- elseif IO >= 1000000000 then
- title = "IO: "..math.round((IO/2.5)/1000000000).." GFe/t"
- centerT(title, 9, colors.black, colors.orange)
- else
- title = "IO: "..math.floor(IO/2.5).." Fe/t"
- centerT(title, 9, colors.black, colors.orange)
- end
- title = "Energie: "..EnergyPer.." %"
- centerT(title, 13, colors.black, colors.blue)
- title = "Cells : "..Cell
- centerT(title, 17, colors.black, colors.white)
- title = "Providers : "..Provider
- centerT(title, 18, colors.black, colors.white)
- end
- --Func bar
- function drawBar()
- bar = math.round(((Energy/MaxEnergy)*(monX-2))+0.5)
- mon.setCursorPos(2,monY-4)
- mon.setBackgroundColor(colors.red)
- mon.write(string.rep(" ", monX-2))
- mon.setCursorPos(2,monY-4)
- mon.setBackgroundColor(colors.green)
- mon.write(string.rep(" ", bar))
- end
- while true do
- value()
- writeMon()
- drawBar()
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement