Added GameLogic.globalDict, this is a place where data can be stored even when new blend files are loaded. Using for apricot so frankie can go into levels in new blendfiles keeping his inventory, currently it dosnt work for the blenderplayer which stops python before loading new blend files.
This commit is contained in:
@@ -116,7 +116,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
|
||||
// Acquire Python's GIL (global interpreter lock)
|
||||
// so we can safely run Python code and API calls
|
||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||
|
||||
|
||||
PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */
|
||||
|
||||
bgl::InitExtensions(true);
|
||||
|
||||
do
|
||||
@@ -310,6 +312,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
|
||||
initRasterizer(rasterizer, canvas);
|
||||
PyObject *gameLogic = initGameLogic(startscene);
|
||||
PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module.
|
||||
PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
|
||||
initGameKeys();
|
||||
initPythonConstraintBinding();
|
||||
initMathutils();
|
||||
@@ -384,6 +387,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
|
||||
// which allows the scene to safely delete them :)
|
||||
// see: (space.c)->start_game
|
||||
PyDict_Clear(PyModule_GetDict(gameLogic));
|
||||
PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict);
|
||||
|
||||
ketsjiengine->StopEngine();
|
||||
exitGamePythonScripting();
|
||||
|
||||
Reference in New Issue
Block a user