Advertisement
Guest User

loadingbar

a guest
May 29th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. mon = peripheral.wrap("right")
  2.  
  3. function refreshBar(x, xmax)
  4.   ratio = x / xmax * 10
  5.   text =""
  6.   a = 0
  7.   while a < ratio do
  8.     a = a + 1
  9.     text = text .. "  "  
  10.   end
  11.   mon.write(text)
  12.   print(ratio)
  13. end
  14.  
  15. x = 0
  16. mon.setTextScale(1)
  17.  
  18. while true do
  19.   mon.clear()
  20.  
  21.   if x < 10 then
  22.     x = x + 1
  23.   end
  24.  
  25.   if x == 10 then
  26.     x = 0
  27.   end
  28.  
  29.   mon.setCursorPos(1,1)
  30.   mon.setBackgroundColor(colors.lime)
  31.   refreshBar(x,10)
  32.   mon.setBackgroundColor(colors.black)
  33.   sleep(0.5)
  34.   print(x)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement