# cycle through 16 x and 16 y values, # which generate a total of 256 tile indexes for $y ( 0..15 ) { for $x ( 0..15 ) { # this calculates the tile index we are currently at, # using the x and y coords in this block $tile_index = $y+($x*16); # this calculates the real x and y values of this tile $rx = ($bx*16)+$x; $ry = ($by*16)+$y; # insert type data into the internal map array and # note that there was change in this block if applicable if ( !defined $tiles[$rx][$ry][$bz][type] || $tiles[$rx][$ry][$bz][type] != $type_data[$tile_index] ) { $changed = 1; $tiles[$rx][$ry][$bz][type] = $type_data[$tile_index]; } } }