What will this be used for I wonder? Dictionary-like access to a scene


patch from Mitchell Stokes adding dictionary like access to a scene. (like KX_GameObjects have)

val = scene[“prop”]
scene[“prop”] = newval
if “prop” in scene: …
val = scene.get(“prop”, fallback_val)

This was commited to 2.5 today and I wonder what big useful things this will allow?

So what can you do with it?

Ohhh so you could use it like a globalDict, except it’s different per scene, so you could use it to communicate with UI elements. Like: UIScene[“button1”] = 1, then the script running the UI would check for that and do whatever with it.

Or you could use it to save global variables that aren’t kept between scenes. For example settings about your level. Right now I’m using an empty object for that.

Pretty much for better organisation I guess, so instead of adding scene specific entries to the globalDict you can do it on a scene to scene basis.

The big thing about 2.5 BGE for me is the ability to subclass, and if I remember reading properly it was subclassing of everything, so scenes included hopefully.

This isnt a new feature, 2.49 (and older) can do…
scene.foo = 1
this is just updating for dictionary style access