Switching between background scenes

Hello Forums,
I am currently trying to be able to switch between scenes. Unfortunately I can’t use the SetScene mode of the scene actuator, because I’m using a background scene.
The thing I want to achieve seems simple from a classic scripting view to me: I have an ‘empty’ that has an ‘always’ sensor with a dummy controller and a ‘scene actuator’ in ‘Add Background Scene’ mode with a certain scene selected. Now I want to change the background scene from within the underlayed scene. To do this I tried the following code (inspired by this) without success:


import bge
gl = bge.logic
sce = [sce for sce in gl.getSceneList() if sce.name == '_OVERLAY'][0]
o = sce.objects
def change(cont):
    own = cont.owner
    o['sceneLoader'].actuators['scene'].scene = own.get('goto')

How do I get this to work?
Is the way I’m doing it good practice?

you do not need Python code. It does not offer any additional features.

You can simply remove one background scene and add another background scene. Just two scene actuators.

You can even do that from the scene to be removed.

Ah, so I have to remove it first. Thanks.
But still, if I have more than 50 scenes I want to switch, wouldn’t it make more sense to code than to make a huge bulk of actuators?
Adding stuff with a GUI seems to me tedious and not professional.

I meant, you do not need Python code for the requested feature as it does not depend on a Python only interface. This is important for anyone who is not familiar to Python (and is reading this thread).

You still can use Python. Especially in the described situation I recommend to use Python whether to setup the actuator or to use the Python API complement.

Your code configures the actuator. It reads the scene name from a property which is quite a flexible method to setup the scene actuator.