Andy73

progressBar.lua

Apr 22nd, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. --progressBar Element for ACOS GUI Framework
  2. --USE WITHOUT MY (viluon's) EXPLICIT PERMISSION IS AGAINST THE COPYRIGHT!!!!!!!!!!!!!
  3. progressBar={
  4.  localValue=0,
  5.  width=0,
  6.  backgroundColor=colors.white,
  7.  foregroundColor=colors.green,
  8.  value=function(this,val)
  9.     if not this then error("'this' equals nil",2) end
  10.     if val then
  11.         this.localValue=val
  12.         return this.localValue
  13.     else
  14.         return this.localValue
  15.     end
  16.  end,
  17.  print=function(this,x,y)
  18.     if not this then error("'this' equals nil",2) end
  19.     local xOrg,yOrg=term.getCursorPos()
  20.     term.setCursorPos(x,y)
  21.     term.setBackgroundColor(this.backgroundColor)
  22.     write(string.rep(" ",this.width))
  23.     term.setCursorPos(x,y)
  24.     term.setBackgroundColor(this.foregroundColor)
  25.     write(string.rep(" ",(this.width/100)*this.localValue))
  26.     term.setCursorPos(xOrg,yOrg)
  27.  end,
  28.  new=function(this,object)
  29.     object = object or {}
  30.      setmetatable(object, this)
  31.      this.__index = this
  32.      return object
  33.  end,
  34. }
  35.  
  36. x=progressBar:new({width=10,localValue=70})
  37. print(x:value())
  38. term.clear()
  39. x:print(10,11)
Advertisement
Add Comment
Please, Sign In to add comment