I'd even settle for an extension to the current drawSheet command to work with an array. For purposes of demonstration, I made 2 versions which get the job done, but are slow. The first draws a horizontal sequence of tiles, which has a start index to the array and a count to loop through. The second draws a 2D grid of tiles,which requires input on width to figure out the height based on array size. It also has a source vector for starting x/y position, as well as the width and height counts to draw). I incorporated wrap-around into them as well.
// Draw a horizontal sequenced set of tiles
function drawASheet( image, tileArray, start, count, xpos, ypos, scale )
size = tileSize( image, 0 ) * scale
if( size.x > 0 ) then
width = len( tileArray )
if( wrap ) then
if( start < 0 ) then
start = ( start % width ) + width
endIf
for i = 0 to ncount loop
drawSheet( image, tileArray[( start + i ) % width ], xpos + ( i * size.x ), ypos, scale )
repeat
else
if( start < 0 ) then
xpos -= start * size.x
count -= start
start = 0
endIf
ncount = min( start + count, width) - start
for i = 0 to ncount loop
drawSheet( image, tileArray[ start + i ], xpos + ( i * size.x * scale ), ypos, scale )
repeat
endIf
endIf
return void
// Draw a 2D grid of tiles
function drawASheetEx( image, tileArray, width, sourceV, xpos, ypos, scale, wrap )
size = tileSize( image, 0 ) * scale
height = int( len( tileArray ) / width )
ty = height * width
if( size.x > 0 and height > 0 ) then
if( wrap ) then
if( sourceV.y < 0 ) then
sourceV.y = ( sourceV.y % height ) + height
endIf
clip = 0
for i = 0 to sourceV.w loop
clip = (( i + sourceV.y ) * width ) % ty
drawASheet( image, tileArray[ clip : clip + width - 1 ], sourceV.x, sourceV.z, xpos, ypos + ( i * size.y ), scale, 1 )
repeat
else
if( sourceV.y < 0 ) then
ypos -= sourceV.y * size.y
sourceV.w -= sourceV.y
sourceV.y = 0
endIf
ncount = min( sourceV.y + sourceV.w, height ) - sourceV.y
for i = 0 to ncount loop
drawASheet( image, tileArray[( i + sourceV.y ) * width : ( i + sourceV.y + 1 ) * width - 1 ], sourceV.x, sourceV.z, xpos, ypos + ( i * size.y ), scale, 0 )
repeat
endIf
endIf
return void