Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local eio = peripheral.find("tile_blockcapacitorbank_name")
- local m = peripheral.wrap("top")
- function drawBar(val,x,y)
- local blockCols = {}
- blockCols[1] = colors.red
- blockCols[2] = colors.red
- blockCols[3] = colors.red
- blockCols[4] = colors.red
- blockCols[5] = colors.yellow
- blockCols[6] = colors.yellow
- blockCols[7] = colors.yellow
- blockCols[8] = colors.green
- blockCols[9] = colors.green
- blockCols[10] = colors.green
- for i = 1,10 do
- if i <= val then
- m.setBackgroundColor(blockCols[i])
- m.setCursorPos(x,Y)
- m.write(" ")
- else
- m.setBackgroundColor(colors.black)
- m.setCursorPos(x,y)
- m.write(" ")
- end
- y = y - 1
- end
- end
- function formatPlace(val,digits)
- local shift = 10 ^ digits
- result = math.floor(val * shift + 0.5) / shift
- return result
- end
- function fromatVal(val)
- local mil = val / 1000000
- local thous = val / 1000
- if mil > 0 then
- return formatPlace(mil,1).."M"
- end
- if thous > 0 then
- return formatPlace(thous,1).."M"
- end
- end
- function draw()
- local bankStored = eio.getEnergyStored()
- local bankMax - eio.getMaxEnergyStored()
- local s = bankStored / bankMax
- local s = s * 10
- local barNum = math.ceil(s)
- drawBar(s,35,12)
- end
- while true do
- draw()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement