Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- power = peripheral.wrap("Induction Matrix_4")
- mon = peripheral.wrap("monitor_8")
- local maxPower = 0
- local curPower = 0
- local perPower = 0
- local outPower = 0
- local inpPower = 0
- local capPower = 0
- monX,monY = mon.getSize()
- function checkPower()
- maxPower = power.getMaxEnergy()
- curPower = power.getEnergy()
- perPower = math.floor(((curPower/maxPower)*100)+0.5)
- currentPower = math.floor(((curPower/2.5)/1000000)+0.5)
- outPower = power.getOutput()
- inpPower = power.getInput()
- capPower = power.getTransferCap()
- outputPower = math.floor(((outPower/2.5)/1000)+0.5)
- inputPower = math.floor(((inpPower/2.5)/1000)+0.5)
- cappePower = math.floor(((capPower/2.5)/1000)+0.5)
- end
- function writeMon()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- -- mon.write("Power")
- title = " Power:" .. perPower .. "% Full "
- centerT(title, 1, colors.lightGray, colors.blue)
- title = " Stored Power:" .. currentPower .."Mrf "
- centerT(title, 3, colors.lightGray, colors.blue)
- title = " Input:" .. inputPower .. "/" .. cappedPower .. "Krf"
- centerT(title, 5, colors.lightGray, colors.blue)
- title = " Output:" .. outputPower .. "/" .. cappedPower .. "Krf"
- centerT(title, 7, colors.lightGray, colors.blue)
- end
- function centerT(text,line,backColor,txtColor)
- mon.setBackgroundColor(backColor)
- mon.setTextColor(txtColor)
- length = (string.len(text))
- dif= math.floor(monX-length)
- x = math.floor(dif/2)
- mon.setCursorPos(x+1, line)
- mon.write(text)
- end
- function drawBar()
- bar = math.floor(((curPower/maxPower)*(monX-2))+0.5)
- mon.setCursorPos(2,monY-4)
- mon.setBackgroundColor(colors.red)
- mon.write(string.rep(" ", monX-2))
- end
- while true do
- checkPower()
- writeMon()
- drawBar()
- print(curPower .. "/" .. maxPower)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment