Advertisement
eniallator

grid

Jul 24th, 2015
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. grid = {}
  2. width, height = term.getSize()
  3. gradient = height/width
  4. heightIntercept = -(gradient*width) + height
  5.  
  6. for w=1,width do
  7.   grid[w] = {}
  8.  
  9.   for h=1,height do
  10.     grid[w][h] = ""
  11.     equation = gradient*w + heightIntercept
  12.    
  13.     if equation%1 < 0.5 then
  14.       equation = math.floor(equation)
  15.     else
  16.       equation = math.ceil(equation)
  17.     end
  18.    
  19.     term.setCursorPos(w,h)
  20.    
  21.     if w == 1 or h == 1 or w == width or h == height then
  22.       term.setBackgroundColor(colors.green)
  23.       term.write(" ")
  24.      
  25.     elseif h == equation then
  26.       term.setBackgroundColor(colors.green)
  27.       term.write("x")
  28.      
  29.     else
  30.       term.setBackgroundColor(colors.lime)
  31.       term.write(" ")
  32.     end
  33.   end
  34. end
  35.  
  36. sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement