Access Game Objects in Entire Game File?

Hey guys. I was wondering if there was a way to access every game object in the entire game file (not just within the current scene)? I’m not trying to get a String of object names or plain Objects, because I’m also trying to access the Game Object’s Properties.

I’m creating an inventory with subcategory lists like ‘Weapon List’, ‘Misc List’, etc. In the script I’m working on, I have tried accessing objects by comparing names and/or PhysicsIDs, but I think I’m pulling the items from the wrong list.

I’ve tried: (the lists used)

bge.logic.getSceneList().objects
bpy.data.objects
bge.logic.getSceneList().objectsInactive (actually, I’m not sure if this worked at all)

Any advice is helpful. Thanks :slight_smile:

You can only access objects from scenes that are currently active, and getSceneList() only returns the list of active scenes, not all the scenes in the current blend file.

You can just make an inventory scene containing an empty that has all the logic for your inventory system and just add this scene at the beginning of the game.

If you really need something that will work without having to activate scenes, I would suggest just reading from and writing to an external file.

Don’t use bpy - it won’t work for a standalone BGE game.

If you want to grab objects that aren’t spawned, you can use objectsInactive and check its properties from a script, though I’m not sure if you can edit its properties. I usually put all possible objects that you can add in-game in a single group (“Resources”), and then add that group into one of each scene’s inactive layers. That way, each scene has access to every resource object.

I would just use a Python dictionary for an inventory and store it somewhere global, like in the logic or logic.globalDict (?) dictionary for it to carry across scenes. Is there something specific that you needed to access inactive objects to do?

What about python editing a XML? or sending out via the multiplayer socket somehow

The inactive objects will have different purposes, depending on the Properties they have. For example, the objects with the “weapon” property will be spawned from an Empty (child of the Character’s Armature), so that the created object will be used as a weapon. The created object will also be parented by the Armature upon creation. The game is MMRPG-styled, by the way (point and click), and I want to make room for updates.