Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- power = peripheral.wrap("back")
- mon = peripheral.wrap("top")
- wmod= peripheral.wrap("left")
- 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,1)
- 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,2)
- mon.write(" Currrent: ")
- mon.write(shorthand(getEnergy(power)))
- mon.setCursorPos(1,3)
- mon.write(" Input: ")
- mon.write(shorthand(getInput(power)))
- mon.setCursorPos(1,4)
- mon.write(" Output: ")
- mon.write(shorthand(getOutput(power)))
- end
- function drawbar()
- sendmsg = perPower .."%Full"
- teste = {cur = getEnergy(power), maxe = getMaxEnergy(power), per = sendmsg, scur = shorthand(getEnergy(power))}
- wmod.closeAll()
- wmod.open(1)
- wmod.transmit(1, 1, teste)
- end
- function red()
- if perPower < 30 then
- redstone.setOutput("right",true)
- else
- redstone.setOutput("right",false)
- end
- end
- while true do
- writeMon()
- per()
- drawbar()
- red()
- print(shorthand(getEnergy(power)) .. "/" .. shorthand(getMaxEnergy(power)))
- sleep(0.5)
- end
Add Comment
Please, Sign In to add comment