otherSide Switching

Here’s a slightly less esoteric question. PathPassage A starts the game as the masterObject for PathPassage B. As a puzzle, however, I later need PathPassage A to become the masterObject for PathPassage C or D instead.

The docs state that the setting of otherSide is handled during initialization, and state that you “usually” don’t need to set it in your own code. But in this case, I obviously need to set it manually. My question is, what else (if anything) do I need to set? Will it work if I simply say

A.otherSide = C; C.otherSide = A;

Can I set the masterObject of C and D to A at the beginning of the game, or will that confuse the initialization? Do I need to set it later in order to keep the objects in sync? (Given that this is a PathPassage, not a door, “in sync” may not have any meaning.) What else do I need to do? Thanks!

To be thorough, you should also update C’s masterObject value. And possibly seal off B and D as well.

A.otherSide = C;
C.otherSide = A;
C.masterObject = A;
B.otherSide = nil;
B.masterObject = self;
D.otherSide = nil;
D.masterObject = self;

Since the PathPassage won’t be closed or locked, I doubt this will do anything, but it preserves the 1:1 relationship. And if your testers somehow wind up in B or D when C is active, it will be immediately obvious that something has gone wrong.

You definitely shouldn’t set the masterObject of C or D to A in your code. That is used during initializeThing() to set the masterObject’s otherSide property to the object. You’ll wind up in a situation where A’s otherSide is B, C, or D. Exactly which is undefined and may depend on source code order.

Thanks. By taking care of all of those details, I uncovered a bug that play-testers would (I hope) have stumbled over. It pays to be thorough!