Resource icon

JDataKit v0.11: A Modder's Utility 2016-10-05

Compatable: Civ4 v1.61 and Warlords

This mod component is not ment for stand alone use. If you simply add this mod in by itself there will be no ingame changes.

JDataKit Modcomp Thread

This comp is intended as a wrapper to Stone-D's SdToolKit. Instead of importing the methods from SdToolKit, you would instead import this mod's methods. Its main function is that the mod adds another level of storage to SdToolKit. It also automaticly stores the given data under a given unit. The code is pretty well documented and explained in the files so check it out for your self. :)

One final note. I had to put a new function in the SdToolKit file. It is surounded by
## JDataKit Start ##
and
## JDataKit End ##

and is also been added to the SdToolKit's readme file.


This modcomp comes with Dr Elmer Jiggle's CustomEventManager and a CvJDataKitEventManager.py file which sets the onUnitCreated and onUnitLost events. These two events set and remove Types dictionaries on all units so that types and stats can mearly be set and gotten.


The meat of the modcomp and the only file that is nessesary, besides SdToolKit.py, is CvJDataStorageUtils.py.

There are three important terms that are used in this code. They are Type, Stat, and Value. A Type is made up of a Python Dictionary. Each Type dictionary contains 0 or more Stats and each Stat has a Value. Throughout the code and the info below, TypesDict and similar referres to the primary dictionary for each unit that contains the individual sub dictionarys of Stat/Value pairs.

For example take the TypesDict

{ "Physical" : { "Strength" : 4, "Dexterity" : 2, "Stamina" : 3 }, "Social" : { "Appearance" : 3, "Manipulation" : 1, "Charisma" : 4 } }

In that example the entire dictionary would be the primary dictionary that is stored on a specific pUnit object. Each key of the primary dictionary, the "Physical" and "Social" keys, is termed a Type. The value of each Type has set as its value a dictionary, this sub dictionary is termed a StatsDict or a dictionary of Stat/Value pairs. Both Types and Stats should be strings as other kinds of data may have unforseen results. The python dictionary value of each Stat is termed Value and is being referred to when the capitallized version of the word is used. Though I origionally wrote this with the intention of storing only integars and maybe strings as Values, I don't forsee any problems storing any kind of data that would be normally exceptable by SdToolKit.

Also important to note. While I use pUnit in my examples, any Civ obj that has the methods pObj.getOwner() and pObj.getID() can be used to store data in a data pool unique to that object. If at anypoint the owner or ID of the object changes, neither SdToolKit nor my wrapper code transfers stored data, all this must be done by the modder.
Author
Jeckel
Downloads
135
Views
135
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Jeckel

Top Bottom