0
$\begingroup$

I want to make a nice game, but I need a function, so player can save all his game data. I want to know, how to make it so it saves all game data to the same folder, as the executable Standalone Runtime game file is located. Of course in another folder called Saves, which is located in Game File's folder. Plus, I want to know how to make multiple saves and how to make player able to delete some save files in-game. Please, help me.

$\endgroup$
1
$\begingroup$

Blender treats paths beginning with "//" as relative to the blend file directory. You can use bge.logic.expandPath to get the absolute path that you can use in standard python file calls to create data files containing all the variable data you want to store.

bge.logic.expandPath(path) Converts a blender internal path into a proper file system path.

Use / as directory separator in path You can use ‘//’ at the start of the string to define a relative path; Blender replaces that string by the directory of the startup .blend or runtime file to make a full path name (doesn’t change during the game, even if you load other .blend). The function also converts the directory separator to the local file system format.

Parameters: path (string) – The path string to be converted/expanded.
Returns: The converted string
Return type: string

| improve this answer | |
$\endgroup$
  • $\begingroup$ OK! But how do I make save it in the same folder as runtime game? Could you give examples or images? $\endgroup$ – Adrians Netlis Dec 28 '14 at 15:16
  • $\begingroup$ P.S. I am not well in Python and I am still learning. I am making most of game parts with Logic Bricks(all I can) $\endgroup$ – Adrians Netlis Dec 28 '14 at 17:37
  • $\begingroup$ I don't think there is a way to write to disk without python, this could get you started $\endgroup$ – sambler Dec 30 '14 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.