help: SAVE-LOAD (property, scene, OBpos)


(pizdec) #1

Please, give me script “save-load” in .blend file ! :o


(ST150) #2

Save:

try:
		
	f = open('filename.txt', 'w')
		
	f.write(str(GameLogic.Property1) + '
')
	f.write(str(GameLogic.Property2) + '
')
	f.write(str(GameLogic.Property3) + '
')
	
	f.close()

Load:

try:

	f = open('filename.txt', 'r')
	
	GameLogic.Property1 = int(f.readline()[:-1])
	GameLogic.Property2 = int(f.readline()[:-1])
	GameLogic.Property3 = int(f.readline()[:-1])

	f.close()

If you want to save more complex data types you can use the pickle module, but you’ll need to include a whole bunch of additional python files if you want a standalone version.


(pizdec) #3

ST150
Thank. I has not understood :frowning:
In python I LAMER.


(ST150) #4

Unfortunately if you want to save information to a file and reload it, you’ll need to learn some python. This is one thing you can’t do with just logic bricks. Every save script will be different too depending on the game’s setup, so you can’t just use a premade template…