Skip to content
Minh Ngo edited this page May 8, 2013 · 6 revisions

The mapdata module contains functions for iterating map data. Note that the orientation is assumed to be +x going right and +y going down.


mapdata.imageData(imagedata)

Returns an iterator which iterates through all pixels. The returned values for each iteration are x,y,r,g,b,a. Note that top left pixel starts at (1,1).


mapdata.string(string)

Returns an iterator which iterates through all non-space characters; each space character occupies 1 tile. The returned values for each iteration are x,y,char.


mapdata.array(array,width,height)

Returns an iterator which iterates through all values in the array. The returned values for each iteration are x,y,v. The width and height arguments are the dimensions of the map.


mapdata.grid(grid)

Returns an iterator which iterates through all values in the grid. The returned values for each iteration are x,y,v. The grid is row ordered such that v = grid[y][x].

Clone this wiki locally