Pushok

wedge-shaped table

May 1st, 2013
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. math.randomseed(os.time())
  2. math.random()
  3.  
  4. tblHeight = 8
  5. step = 1
  6. maxWidth = 80
  7. strLen = 2
  8.  
  9. symPairs = {}
  10.  
  11. for i = 1, tblHeight do
  12.     symPairs[i] = {}
  13.     for j = 1, 2 do
  14.         local str = ''
  15.         for k = 1, strLen do
  16.             str = str..string.char(math.random(0x61, 0x7A))
  17.         end
  18.         symPairs[i][j] = str
  19.     end
  20. end
  21.  
  22. for i = 1, tblHeight do
  23.     local line = ''
  24.     local half = math.floor(maxWidth / 2) - strLen
  25.     line = line..string.rep(' ', half - step * i - 1)
  26.     line = line..symPairs[i][1]
  27.     line = line..string.rep(' ', step * i)
  28.     line = line..i
  29.     line = line..string.rep(' ', step * i)
  30.     line = line..symPairs[i][2]
  31.     print(line..'\n')
  32. end
  33. io.read()
Advertisement
Add Comment
Please, Sign In to add comment