Advertisement
johnnic431

Untitled

Aug 8th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. m=peripheral.wrap("left")
  2. p=peripheral.wrap("bottom")
  3.  
  4. term.redirect(m)
  5.  
  6. tX,tY=term.getSize()
  7.  
  8. local function writeTextCentered(text,y,tCol)
  9.     if text==nil or y<=0 then return false; end
  10.     sValue=(tX-string.len(text))/2;
  11.     if tCol then term.setTextColor(tCol) end
  12.     term.setCursorPos(sValue,y);
  13.     term.write(text);
  14.     term.setBackgroundColor(colors.green)
  15. end
  16.  
  17. local function writeTextSpecificCentered(text,sX,eX,y,tCol)
  18.     if text==nil or y<=0 then return false; end
  19.     sValue=(((eX+1)-sX)-string.len(text))/2;
  20.     if tCol then term.setTextColor(tCol) end
  21.     term.setCursorPos(sValue+sX,y);
  22.     term.write(text);
  23.     term.setBackgroundColor(colors.green)
  24. end
  25.  
  26. local function drawLoadingScreen(count,total,info)
  27.     term.setBackgroundColor(colors.white)
  28.     paintutils.drawLine(1,tY-3,tX,tY-3,colors.white)
  29.     writeTextCentered(info,tY-3,colors.blue)
  30.     paintutils.drawLine(2,tY-1,tX-2,tY-1,colors.white)
  31.     paintutils.drawLine(2,tY-1,1+((count*(tX-2))/total),tY-1,colors.green)
  32. end
  33.  
  34. function main()
  35.     while true do
  36.         h=p.getEnergyStored()
  37.         mx=p.getMaxEnergyStored()
  38.         if h==mx then
  39.             rs.setOutput("back",true)
  40.         else
  41.             rs.setOutput("back",false)
  42.         end
  43.         pc=h/mx
  44.         ts=tostring(tostring(h).."/"..tostring(mx).." ("..tostring(pc*100).."%)")
  45.         paintutils.drawFilledBox(1,1,tX,tY,colors.white)
  46.         paintutils.drawBox(1,tY-2,tX,tY,colors.lightGray)
  47.         drawLoadingScreen(h,mx,ts)
  48.         sleep(1)
  49.     end
  50. end
  51.  
  52. _,err=pcall(main)
  53.  
  54. term.setBackgroundColor(colours.black)
  55. term.setTextColor(colours.white)
  56.  
  57. print("\n\n\n\n"..err)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement