Save property to external file 2.49

Just like the title says. Im trying to save the current game property of an object to an external “.txt” file in version 2.49. I keep getting this error in the console

" AttributeError: ‘builtin_function_or_method’ has no attribute ‘propstring’ "

Here is my current script:

import GameLogic as gl

Add objects to be saved to this list

cube = GameLogic.getCurrentScene().getObjectList()[“OBCube”]
con= gl.getCurrentController()
own = con.getOwner()

Open the file “Game1.sav” in write mode

saveFile = open(“Game1.sav”, “w”)

Write header to file

saveFile.write("This is a valid save file
")

Write game data to file

prop = own.prop
propstring = repr(prop)
saveFile.write.propstring

Close save file

saveFile.close()

saveFile.write(propstring)
not
saveFile.write.propstring

and to load you can use eval

as you wrote here, “saveFile.write.propstring”, this means that saveFile has a Property or method called “propstring”.
But it hasnt!

Try:

saveFile.write(propstring)

and you are using a Dinosaur-Coding:

change:


own = con.getOwner()
       to
own = con.owner
cube = GameLogic.getCurrentScene().getObjectList()["OBCube"]
                        to
cube = GameLogic.getCurrentScene().objects["OBCube"]
own.prop  
 to 
own['prop']

Should work like this .

Thanks guys