loading problems.

obj = GameLogic.getCurrentScene().getObjectList()
loadFile = open(“dungeon.fps”, “r”)

header = loadFile.readline()
header = header[0:-1]
if header == “SAVED DATA:”: #has to be the same as the Save script\

a = obj[“OBCube”]
propa = loadFile.readline()
a.level = int(propa[0:-1])

a = obj[“OBCube”]
pexp = loadFile.readline()
a.exp = int(pexp[0:-1])
loadFile.close()

that is the load script I am using. the second part (pexp) is not loading. but the first part(propa) works! Anyone know what I am doing wrong?

oh yes and here is the save script:

import GameLogic
file = open(“dungeon.fps”, “w”) #the name of the new file
scene = GameLogic.getCurrentScene()

file.write("SAVED DATA:
")

obj = scene.getObjectList()[“OBCube”]

file.write(str(obj.level) + "
")
file.write(str(obj.exp) + "
")

file.close()

It looks like it should work.

But first, you don’t have to call “OBCube” twice, since it is the same object. You wouldn’t even have to call the object at all if you have your sensor hooked up to OBCube. I don’t think any of these things are causing your problem though, since you say it’s loading the first property.

Verify that your script is writing (saving) what you want it to with Notepad or a similar program. And are there any errors in the console?

Also, are you using an integer, string or a float for the “exp” property? If it is a float, then change the appropriate “Load script” line to "a.exp = float(pexp[0:-1]). Use “str” in place of float for a string property. Not sure, but I think that’s right.

Saving/Loading scripts are still confusing to me with python/BGE, but I believe I’m the one who posted that script, of which you modified, on this forum some time ago. So, if you still have problems, post the .blend. I can probably figure it out rather quickly.

here’s the simple blend:
http://hyperupload.com/download/02bc71af79/save_test.blend.html

Here you go. It was just an indention error, and perhaps a typo (or I could have accidentally done the typo. Anyway, it works now.

http://www.4shared.com/file/46871425/15fabe7c/save001.html

THANK YOU!
I did NOT want to make seperate save files for everything…

EDIT: now that i look at it… hits self