# I cannot figure out how to use/print globalDict

I am trying to see (printed in the terminal window) a list of all the objects in the game while game is running.

Posted game file on Github

The print statements you have should show the globalDict contents, if it is empty then you will only see {}, once containing values, it would show as -

{'key1': 'Value One', 'key2': 2}


Note that it doesn't have any values unless you add them, bge.logic.globalDict is a user data dictionary, it doesn't contain game engine properties.

As with any python dictionary, you can loop over the contents using dict.items() to get more control over formatting, there is also dict.keys() and dict.values() if you don't want both of them.

import bge

print('globalDict is')
for k,v in bge.logic.globalDict.items():
print(k,v)

• Your code here works in my game, both inside and outside the main function / loop. So apparently I'm trying to get the globalDict to do something it's not made for. When a player adds new objects to the game, I'd assume that the game has a way of keeping track of those objects (on its own, independent of any code I write.) What I am trying to do is access that data, and hopefully be able to change it. I may be trying to go in a completely wrong direction. I simply want to be able to go back in a turn based game and undo the spawning of objects. – quazipseudo Oct 27 '17 at 14:28
• Just because a game maintains data doesn't mean it is using the globaldict. The code you linked to only prints the globaldict, it doesn't alter it in any way. Each object can have game properties, maybe that is what you are looking for. – sambler Oct 28 '17 at 3:40