Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local b = peripheral.wrap("back")
- local e=0
- local lastE=0
- local diff=0
- local mon=peripheral.find("monitor")
- local function mw(txt,x,y,col)
- for _,name in pairs(peripheral.getNames()) do
- if peripheral.getType(name)=="monitor" then
- mm=peripheral.wrap(name)
- mm.setCursorPos(x,y)
- mm.setTextColour(col)
- mm.write(txt)
- end
- end
- end
- local function padLeft(str,_w)
- return string.rep(" ",_w)..str
- end
- local function nf(n,l)
- local str=tostring(n)
- local n=string.len(str)
- local so=""
- while n>2 do
- so=","..string.sub(str,n-2)..so
- str=string.sub(str,1,n-3)
- n=string.len(str)
- end
- so=str..so
- if string.sub(so,1,1)=="," then
- so=string.sub(so,2)
- end
- n=string.len(so)
- if n~=nil then
- if l>n then
- l=l-n
- so=padLeft(so,l)
- end
- end
- return so
- end
- while true do
- e=b.getEnergyStored()
- diff=math.floor((e-lastE)/20)
- print(nf(e,18))
- print(nf(diff,18))
- mw(nf(e,18),1,1,colors.blue)
- mw(nf(diff,18),1,2,colors.red)
- lastE=e
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement