Looping Multi-Tile Objects

with Set To Next

Looping all tiles in a multi-tile object should be easy, there's a Set To Next for the task.

But wait, there's a cryptic comment on the Set To Next page "N.B. Some Set To Next varients have a quirk where they will never return False." And when we check the part of a multi-tile object sub-page we see "This particular enumeration works a little differently from the others because it will never return false."

Ummmm. So if Set To Next for a multi-tile object never returns false, how are we supposed to know when we've processed all of the sub-tiles?

There is a solution given for the obj on same tile sub-action, but it can be simplified for the "part of a multi-tile object" sub-action.

We can use the fact that any tile in a multi-tile object can identify the lead tile to avoid storing the starting object, so long as we start from the lead tile. The general form is ...

0x0: SO := SO's lead tile                           0x1, Error
0x1: Set To Next (SO, part of multi-tile object)    0x2, 0x4
0x2: Do something with the found sub-tile in SO     0x3, Error
0x3: SO != SO's lead tile                           0x1, 0x4
0x4: Do something else, SO will be lead tile here	

From some real code.

Hope these notes are of use to someone. Enjoy!