Advertisement
PaymentOption

Box Class

May 12th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. Box = {}
  2.  
  3. Box.new = function(y, width, height, borderChar, text)
  4.     local self = {}
  5.    
  6.     width = width or 5
  7.     height = height or 5
  8.     borderChar = borderChar or '*'
  9.    
  10.     self.draw = function()
  11.         cPrint(y, string.rep(borderChar, width))
  12.         for i=1, height-2 do
  13.             cPrint(y+1, borderChar..string.rep(" ", width-2)..borderChar)
  14.             y = y +1
  15.            
  16.             if i == (height-2)/2 then
  17.                 cPrint(y, " "..string.rep(" ", (width/2)-string.len(text))..text..string.rep(" ", (width/2)-string.len(text)).." ")
  18.             end
  19.         end
  20.         cPrint(y, string.rep(borderChar, width))
  21.     end
  22.     return self
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement