Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- power = peripheral.wrap("back")
- mon = peripheral.wrap("top")
- local maxPower = 0
- local curPower = 0
- local perPower = 0
- local outPower = 0
- local inpPower = 0
- local capPower = 0
- local warning = 10
- monX,monY = mon.getSize()
- function getMaxEnergy(cube)
- return cube.getMaxEnergy() * 0.4
- end
- function getEnergy(cube)
- return cube.getEnergy() * 0.4
- end
- function getOutput(cube)
- return cube.getOutput() * 0.4
- end
- function getInput(cube)
- return cube.getInput() * 0.4
- end
- function per()
- mon.setBackgroundColor(colors.black)
- perPower = math.floor(((getEnergy(power)/getMaxEnergy(power))*100+0.4))
- mon.setCursorPos(1,2)
- mon.write(" Power: " .. perPower .. "%")
- end
- function shorthand(number)
- assert(type(number) == "number", "Type number cannot be a "..type(number))
- local letters = {'rf', 'Krf', 'Mrf', 'Grf', 'Trf', 'QDrf', 'QTrf'}
- local log = math.max(math.log10(number), 0)
- local pwr = math.floor(log / 3)
- assert(pwr + 1 <= #letters, "Number too big - we don't have enough suffixes")
- return ("%.3g%s"):format(number / 1000^pwr, letters[pwr + 1])
- end
- function writeMon()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,3)
- mon.write(" Currrent: ")
- mon.write(shorthand(getEnergy(power)))
- mon.setCursorPos(1,4)
- mon.write(" Input: ")
- mon.write(shorthand(getInput(power)))
- mon.setCursorPos(1,5)
- mon.write(" Output: ")
- mon.write(shorthand(getOutput(power)))
- end
- function semess()
- rednet.open("left")
- teste = {cur = shorthand(getEnergy(power)), intpu = shorthand(getInput(power)), per = perPower, outpu = shorthand(getOutput(power))}
- rednet.broadcast(teste,"matrix")
- rednet.close("left")
- end
- function red()
- if perPower > 90 then
- term.clearLine()
- redstone.setBundledOutput("right",0)
- redstone.setBundledOutput("right", colors.blue)
- mon.setCursorPos(1,6)
- mon.setTextColor(colors.green)
- mon.write(" Dischanging Energy")
- mon.setTextColor(colors.white)
- end
- if perPower < 20 then
- term.clearLine()
- redstone.setBundledOutput("right", colors.combine(colors.white, colors.orange))
- mon.setCursorPos(1,6)
- mon.setTextColor(colors.red)
- mon.write(" Low Energy ")
- mon.setTextColor(colors.white)
- x = 0
- end
- if (perPower>20) and not (perPower > 90) then
- term.clearLine()
- redstone.setBundledOutput("right",0)
- redstone.setBundledOutput("right", colors.white)
- mon.setCursorPos(1,6)
- mon.setTextColor(colors.yellow)
- mon.write(" Charging Energy")
- mon.setTextColor(colors.white)
- x = 0
- end
- end
- while true do
- writeMon()
- per()
- semess()
- red()
- print(shorthand(getEnergy(power)) .. "/" .. shorthand(getMaxEnergy(power)))
- sleep(0.5)
- end
Add Comment
Please, Sign In to add comment