Appending objects in different scene

Hi all!
I am developing a little game in BGE: 5 objects, each belonging to a separate .blend file, are appended into an environment.blend file. The player must be able to choose one of these objects (and the game should identify which object was chosen).

My game features 2 scenes: the “intro” scene and the “game” scene. During the execution, within the intro scene (which I plan to use as the “main menu” scene), a python script is triggered by the pressing of the space-bar: it sets the game scene as the active one (while still visualizing the intro) and appends the 5 objects in it, placing each one of them in the right position (and after this, a logic block scene actuator switches to the “game” scene).

The problem is, in my script I used commands that were based on bpy, so I am now trying to get rid of all of them in order to be able to create a working standalone. But I have absolutely no idea of how I can append objects from other files and tell blender that they must be appended in what is not my current scene.

If you’re wondering why I implemented it like this, well, I tried to do my game in one single scene, but when I appended the objects in runtime, they didn’t appear in the environment until I ended the execution.

What I did with bpy-based code was (being in the “intro” scene):


bpy.context.screen.scene = bpy.data.scenes["Game"]

and then I just appended the objects, which were automatically placed into “game”.
How can I do the same using bge??
Right now what I came up with is this:


scenes = logic.getSceneList()


game = bge.logic.getCurrentScene()
intro = bge.logic.getCurrentScene()

for i in scenes:
    if i.name == "Game":
         game = i
    
game.active = True
intro.active = False

On execution I get an error saying that the KX_scene object has no “active” attribute.
But if I don’t add some code to actually tell blender what scene to activate, I have done nothing but save two scene objects in two variables… Which is not what I want.

Please, help me… And if you have any suggestion, or there’s a simpler way to implement this, don’t hold back, just tell me: I’m a BGE newbie and I’m trying to figure things out step by step…

Thanks a lot!
Lovell

The attribute active of a KX_Scene is not documented. I guess it returns the status of the scene (e.g. after suspending/resumimg). It can’t return the load state of a scene, as only loaded scenes exist in memory.

You can’t add objects that reside in other scenes.
But you can
A) link object from other scenes into an inactive scene which can be used as AddObject Original
B) link and instantiate groups and do the same as with A)
C) use LibLoad to load objects from a blend file into the scene.

As you want to place objects via Python controller, trigger the controller right after scene load (Always sensor no Pulses). As the changes will take place in frame 2, you might want to hide frame 1 with a black plane in front of the camera.