Hello again. There is a question. I know that the globalDict keeps data that is accesible from other scenes even from the same scene if it is restarted. For example if I create a variable logic.globalDict[“Player”] = Myself and then I execute startGame() using the same .blend file I can read the “Player” field added to the globalDict, it works perfectly in the bge player, but it doesnt work in the standalone executable, is there any way to save the globalDict data without creating a temporary file? I can do this but…I dont think is a good solution.
Did you save the information first, because I did a quick test using globalDict in the standalone player and I found out that the issue might the fact that what you save in the embedded player can’t be loaded in the standalone player (but it will still load data providing you also used the same player to save the data).
Ok if it worked for you I might need a small test for this. I saved the information and loaded again, it works for me only in the embebed player. If I export the game to a standalone executable it works like if the data havent been saved. When I execute the “startGame” command I use the name of the standaloneplayer, I tried that because I thought that if I use the .blend name it will start the whole game as a new game and wont keep the data.
I just use logic to transfer data between scenes, it only saves it as long as the game is running, never failed on me yet.
from bge import logic #store logic.ammo = owner['ammo'] #load in the scene you want ammo = logic.ammo
Oh btw above code cannot be externally saved. Like globaldict can.
To clarify, the variable above can be saved and loaded to and from an external file; it just uses the normal built-in Python method of opening a file and writing to it. Globaldict can use a logic brick to save and load data to and from it.
Yes I know, but in this case I need to restart the same scene but with changes. the only way to do this is using the globalDict. You can assign values to the globalDict, reestart the scene, check if the globalDict has theese values and load them. My problem is that, what Im saying works in the embebed player, but when you create the external player it won’t work.
if "Player" in globalDict: print(globalDict["Player"]) globalDict["Player"] ="PlayerOne" logic.startGame("BlenderFile.blend")
Hello, thanks for your answer, I know that I can save the globalDict content in a temporary external file but that is something that I was trying to avoid, I was trying to find why you can read the globalDict in the embebed player and you cant do it in the external player, just in case if was a a configuration issue or something like that. But if there is no other alternative for sure I’ll do that, its my B plan
I did a test with 2.68:
When using the GameActuator to start a new game from blend, it keeps the content of globalDict in both embedded and with blenderplayer.
When running embedded the globalDict has the identical Id, when running from blenderplayer it has a different Id with equal content -> except you get errors (e.g. “Error, bge.logic.globalDict could not be marshal’d”).
Thanks a lot, I did another test, I attach it for the example bu I think I got what u meant.
DataSaveTestblend.blend (440 KB)
Finnally. Solved. The Game Actuator RestartScene combined with a function which stores in the globalDict everything I need accomplishes the goal I need. Thanks a lot again