Blender won't let me import the pickle....


(Haunted-House) #1

edit: I have remade the script, it is now perfect!


(saluk) #2

You have to install python for this to work, get it from www.python.org

Make sure you install the older version of python, 2.0, not 2.2, because 2.2 does not work right from blender.

If python20 is already installed, make sure the python path is set right.


(Haunted-House) #3

I have python installed but it’s 2.2, I dont have a python path under enviroment variables…thats the problem…


(Haunted-House) #4

The problem was:
I didn’t have PYTHONPATH (Well I did but, when I upgraded to XP I forgot to set it again)
I have Python 2.2, for Blender2.23 Python 2.0 is needed


(Ben) #5

Tip:
-Use cPickle instead of pickle. It’s 1000 faster.The use is the same.


(Haunted-House) #6

Ben can you please show me a small example of using cpickle to save dictionaries to a text file, I would be very grateful if you could.


(Ben) #7

-If you want to save something e.g. named data,first add an int prop named nr ,than write:

import GameLogic
import cPickle
Con = GameLogic.getCurrentController()
us = Con.getOwner()

data = range(length of the list)
if us.nr <length of the list -1:
us.nr = us.nr + 1

f = open(“filename.txt”,“a”)
cPickle.dump(data[us.nr],f)
file.close()

in this way you save a list named data with “length of the list” elements