davidlallen has a valid point, and that is the fact that the mod itself is suboptimal from a custom value storage point-of-view. I doubt anyone is prepared to fix that mess, even if it probably should be done once-and-for-all. Even though I can't help out with that (it does sound like a monumental task) I can share some of the "mysteries" of dictionaries and pickling.
Ok, dictionaries: Its a data structure like a list - or even a string. So it stores data, but not in a sequence (like a list or a string) but it rather works with keys. So this is a empty dictionary:
You add a key (some value) and its associated content (another value) with:
Code:
scriptDict['customValue'] = 3
Now this is what the dictionary looks like:
You can add any number of key-values pairs to a dictionary:
Code:
scriptDict = { 'customValue1': True, 'customValue2': None, 'customValue3': 42, [COLOR="Red"](0, 1)[/COLOR]: 99 }
The last key is actually a tuple data structure!
You access the data from the dictionary by indexing it, just as with lists and strings (which would surely count as "basic" Python, right?):
Code:
scriptDict['custom value']
There is of course a whole lot more to know about how to use dictionaries, but this would be the bare basics. Advanced stuff, eh? If you feel up to it there is more to read on dictionaries
here (first five sections).
And pickling is just a way to covert some type or data structure into a valid string value. Its not more "advanced" than that. What you need to do however is import the pickle module:
Or you could just go for the faster C++ version called cPickle. The choice is yours.
So, to turn any value into a string (to "pickle" it) you use the dumps() function:
Code:
pickledScriptDict = pickle.dumps(scriptDict)
Then you use setScriptData() to store the string value. And to retrieve the dictionary you of course use getScriptData() and use the loads() function:
Code:
scriptDict = pickle.loads(pickledScriptDict)
Thats about it. Any questions?