It doesn’t need to loop through both if you store the positions of the tiles logically. What I mean by that is like this:
The way you’re doing it, to my understanding, is that you simply store the positions of the tiles in an array, and then check those positions against another array with the actual objects to find them. What if you store the objects where the positions say they are? Like:
positions = [ [0, 0, 0], [1, 0, 0], etc. ]
objects = [
[
[
Tile, #0 (X-axis) - the first tile from above
Tile, #1 (X-axis) - the second tile from above (positions)
] # 0 (Y-Axis)
] # 0 (Z-Axis)
]
This way you could use the positions as the indices to store the data.
However, a much better way would be to just use a dictionary to store the positions and objects in the same place -
cubes = dict({
[0, 0, 1]:Tile
[0, 0, 2]:Tile... # In this case, 'Tile' refers to a pointer to the actual tile object.
})
With a dictionary, you can find the tile knowing the position, or the position if you know the tile (either using the tile object’s position property, or by going backwards in the dictionary. The Python help file goes into detail about going about this backwards). Also, you can dynamically add tiles to the dictionary, and it doesn’t matter where they’re added - you can easily loop through each occurance of the dictionary.
EDIT: I would go for the dictionary route, as it’s far easier to look at, and far easier to deal with.
EDIT 2: I was going to say that you could use a Near or Collision sensor, get all of the hit blocks, and display or hide them that way, but that would kill physics, even if the blocks were static ghost actors.