2. have a "get current character" global function that will return whichever character object is selected. use a global variable to hold the "selected character" indicator
Mandatory side note:
It's tempting to directly copy the character in the "selected character" indicator. Something like
selectedCharacter = character2 if selectedCharacter == character1 else character1
.
But Ren'Py rely on pickle to generate, then load the save files. This mean that when you'll load a save file, "selectedCharacter" would be a new object independent from both "character1" and "character2".
What mean that, like you said it effectively need both an indicator and a way to get the character. But they don't necessarily need to be separated, nor to rely on a function call.
In fact, the best way to do it is to rely on a proxy object that will be constant from starts to stop of the game. It's it that will decide which "AdvancedCharacter" object to use each time a call is done.
Something that would looks like this:
/!\ It's late and I wrote it on the fly, there's perhaps some typos /!\
Python:
init python:
class AdvancedCharacter( renpy.python.RevertableObject ):
def __init__( self, [...] ):
[...]
def getQuest( self ):
[...]
@property
def health( self ):
return self.health
class ProxyCharacter( renpy.python.RevertableObject ):
def __init__( self ):
self.current = 0
def switch( self ):
self.current = 1 if self.current == 0 else 0
def __getattr__( self, aName ):
if aName in ["current", "switch"]:
return super( ProxyCharacter, self).__getattr__( aName )
else:
return getattr( store.characters[self.current], aName )
default characters = [ AdvancedCharacter( [...] ), AdvancedCharacter( [...] ) ]
default mc = ProxyCharacter()
And now the whole game can be developed without having to care what character is currently selected. Rely on "mc" from starts to stop, and it's it that will give you the correct information depending on what character is actually selected.
The only constraint is to not randomly permit to switch from one character to the other. Switching can only be done on "safe place" ; a safe place being an eventless label, like MC's bedroom, the map, or anything like this.
Edit: Typo and formatting error