Advertisement
Guest User

startup

a guest
Feb 8th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. local b = peripheral.wrap("back")
  2. local e=0
  3. local lastE=0
  4. local diff=0
  5. local mon=peripheral.find("monitor")
  6.  
  7. local function mw(txt,x,y,col)
  8.   for _,name in pairs(peripheral.getNames()) do
  9.     if peripheral.getType(name)=="monitor" then
  10.       mm=peripheral.wrap(name)
  11.       mm.setCursorPos(x,y)
  12.       mm.setTextColour(col)
  13.       mm.write(txt)
  14.     end
  15.   end
  16. end
  17.  
  18.  
  19. local function padLeft(str,_w)
  20.   return string.rep(" ",_w)..str
  21. end
  22.  
  23. local function nf(n,l)
  24.   local str=tostring(n)
  25.   local n=string.len(str)
  26.   local so=""
  27.  
  28.   while n>2 do
  29.     so=","..string.sub(str,n-2)..so
  30.     str=string.sub(str,1,n-3)
  31.     n=string.len(str)
  32.   end
  33.   so=str..so
  34.   if string.sub(so,1,1)=="," then
  35.     so=string.sub(so,2)
  36.   end
  37.  
  38.   n=string.len(so)
  39.   if n~=nil then
  40.     if l>n then
  41.       l=l-n  
  42.       so=padLeft(so,l)
  43.     end
  44.    end
  45.   return so
  46. end
  47.  
  48.  
  49.  
  50. while true do
  51.   e=b.getEnergyStored()
  52.   diff=math.floor((e-lastE)/20)
  53.  
  54.   print(nf(e,18))  
  55.   print(nf(diff,18))
  56.  
  57.   mw(nf(e,18),1,1,colors.blue)
  58.   mw(nf(diff,18),1,2,colors.red)
  59.  
  60.   lastE=e
  61.   os.sleep(1)
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement