Package: kkloader
KoikatuCharaLoaderA simple deserializer / serializer for Koikatu / EmotionCreators / Honeycome character data.日本語マニュアルがここにありますInstallationYou can install this module fromPyPI.$ pip install kkloaderIf this does not work, try the following command (for Windows users, maybe).$ python -m pip install kkloaderBasic Usage$python>>>fromkkloaderimportKoikatuCharaData# Load a module.>>>kc=KoikatuCharaData.load("./data/kk_chara.png")# Load a character data.>>>kc["Parameter"]["nickname"]# Print character's nickname.'かずのん'>>>kc["Parameter"]["nickname"]="chikarin"# Renaming nickname.>>>kc.save("./kk_chara_modified.png")# Save to `kk_chara_modified.png`.that's it :)List of ClassesSupports saving and loadingKoikatuCharaDataEmocreCharaDataHoneycomeCharaDataSupports loading onlyKoikatuSaveDataEmocreMapDataEmocreSceneDataAny class can be imported likefrom kkloader import KoikatuCharaDataand data can be loaded using the.load(filename)method.Mechanism of the BlockdataA character data of koikatu consists of someblockdata.
Theblockdatais a collection of character parameters.
A typical Koikatsu character data contains the following blockdata:name of blockdatadescriptionCustomValues for the character's face, body, and hairstyle.CoordinateValues for clothes and accessories worn by characters.ParameterValues for character names, birthdays, preferences, etc.StatusValues for clothed states, etc. (I'm not sure how they are used in the game)AboutuserID & dataID (added from Koikatu Sunshine)KKExValues used in MODYou can check which block data exists fromblockdatain KoikatuCharaData.>>> kc.blockdata
['Custom', 'Coordinate', 'Parameter', 'Status']If there is block data in an unknown format, it can be checked withunknown_blockdata.Access to BlockdataThe blockdata can be accessed as a member variable of theKoikatuCharaDataclass, or accessed as a dictionary.>>>kc.Custom<kkloader.KoikatuCharaData.Customobjectat0x7f406bf18460>>>>kc["Custom"]<kkloader.KoikatuCharaData.Customobjectat0x7f406bf18460>So, these lines both access the samekc.Custom.Find VariablesBy using theprettifymethod, the contents of the variables contained in the block of data will be displayed in an easy-to-read format.
This is useful to find which variables exists.>>> kc["Custom"].prettify()
{
  "face": {
    "version": "0.0.2",
    "shapeValueFace": [
      ...
    ],
    "headId": 0,
    "skinId": 0,
    "detailId": 0,
    "detailPower": 0.41674190759658813,
    ...Export to JSON filefrom kkloader import KoikatuCharaData

k = KoikatuCharaData.load("./data/kk_chara.png")
k.save_json("data.json")data.json{
  "product_no": 100,
  "header": "\u3010KoiKatuChara\u3011",
  "version": "0.0.0",
  "Custom": {
    "face": {
      "version": "0.0.2",
      "shapeValueFace": [
        0.5403226017951965,
        1.0,
        0.2016129046678543,
        0.0,
        0.22580644488334656,
        0.0,
        0.0,
        0.1794193685054779,
        0.0,
...If you addinclude_image=Trueto the argument ofsave_json, base64-encoded images will be included in json.RecipesRename Character's NamefromkkloaderimportKoikatuCharaDatak=KoikatuCharaData.load("./data/kk_chara.png")k["Parameter"]["lastname"]="春野"k["Parameter"]["firstname"]="千佳"k["Parameter"]["nickname"]="ちかりん"k.save("./data/kk_chara_modified")Set the Height of Character to 50fromkkloaderimportKoikatuCharaDatak=KoikatuCharaData.load("./data/kk_chara.png")k["Custom"]["body"]["shapeValueBody"][0]=0.5k.save("./data/kk_chara_modified.png")Remove Swim CapfromkkloaderimportKoikatuCharaDatak=KoikatuCharaData.load("./data/kk_chara.png")fori,cinenumerate(k["Coordinate"]):forn,pinenumerate(c["accessory"]["parts"]):ifp["id"]==5:k["Coordinate"][i]["accessory"]["parts"][n]["type"]=120k.save("./data/kk_chara_modified.png")Remove Under HairfromkkloaderimportKoikatuCharaDatakc=KoikatuCharaData.load("./data/kk_chara.png")kc["Custom"]["body"]["underhairId"]=0kc.save("./data/kk_chara_modified.png")ContributingYou need Python 3.9 andpoetrycommand (you can install withpip install poetry).Fork this repository and then pull.Domake installto install dependencies.Create a new branch and make change the code.Domake formatandmake checkWhen you passedmake check, then push the code and make pull request on this repository.Acknowledgementsmartinwu42/pykoikatuContact@tropical_362827