Load/save option

Hi
I would like to know how to create those options :

  • a save game option
  • a load game option
  • to allow the players to configure the keys of its keyboard

Save/load Game : to allow a player to save all the caracteristics of his character (player). For example, in a RPG, save his the place where the player is, save his inventory, his stats, his quests, spellbooks, and so. When the player wants to play again, the game load all this saved caracteristics.

I can use Python Scripting, but I’m just a beginner in Python :wink:

If you have a tutoriel or a .blend, I’m very interesting.
Thank you.

youre going to have to save those properties in a text file using a python script. Im at school right now so i cant go into much detail due to a lack of time, but do a search for text file functions such as open() write() read() readlines() close()…

heres an example from my monster truck game’s map editor(which i happen to have on a usb drive :wink: )

if over.isPositive():
               if lftbtn.isPositive():
                    save = open("C:\\Maps\	estmap.sav", "w")
                    for line in G.properties:
                           save.write(str(line)+"
")
                    save.close()

it might not make sense to you but…

save = open(“C:\Maps\ estmap.sav”, “w”)

that bit of code gets the file “testmap.sav” ready for writing to “w”

save.write(str(line)+"
")

that writes the lines to the text file

save.close()

closes the file (its always good programming practice to close the file when youre done with it)

yeah so thats what you need to do… use text files to store data such as health, energy, etc. and player position(s)

im sure someone else will explain it better >_>

Go here:
http://blenderartists.org/forum/showthread.php?t=11430

and download Blengine’s “.zip of files”

Stickies are everyone’s friend.

Blendenzo also did a small tutorial to help explain the example.
http://www.blendenzo.com/tutSaveLoad.html

Hi

Stella : Thank you for your Python code, I will study that

Dim : Thanks, I have forget the blendgine example (of load/save and other interesting things)

unsettlingsilence : the blendenzo tutorials are good to understand some Python code too. Thank you for the link.

So now, I have to study all those Python code. :smiley:

There is one minor problem with my tutorial that came up later (when someone actually tried to use it). If you add new line characters (like I suggest in the tutorial), you will need to subtract them before converting back to your original format. You can read about it on the thread regarding the tutorial (follow this link)