How to create a grid based on a 2D table?

 local map = {
    		{E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E},
    		{E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E},
    		{E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E},
    		{E,E,E,E,E,E,E,B,E,E,E,E,E,E,E,E},
    		{E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E},
    		{E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E},
    		{E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E},
    		{E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E},
    	}

The above table consists of 8 rows and 16 columns

for x=1,#map do
        for y=1,#map[x] do
           -- Code to create tiles          
        end
    end

The code above creates a grid with 16 rows and 8 columns. which is opposite of the “Map” table.

Perhaps switch the X and Y variables in the loop?

4 Likes