BG3-Community-Library-Team / BG3-Compatibility-Framework

An API-based Driven Compatibility Framework for Baldur's Gate 3 Mods
MIT License
38 stars 13 forks source link

Booleans insertion error #73

Closed Mythalar closed 8 months ago

Mythalar commented 8 months ago

So a new post !

Seems there is an issue with booleans, at least with json insertion :

{
    "FileVersion": 1,
    "Progressions": [
        {
            "Comment": "Barbarian 1",
            "UUID": "a2198ee9-ea4c-468e-b6b4-22b32d37806e",
            "Strings": [
                {
                    "Action": "Insert",
                    "Type": "PassivesAdded",
                    "Strings": [
                        "Siphoning_Strike"
                    ]
                }
            ]
        },
        {
            "Comment": "Barbarian 2",
            "UUID": "89986e8a-09b1-4163-b1d0-ddb2332bf3c5",
            "Booleans": [
                {
                  "Key": "AllowImprovement",
                  "Value": true
                }
              ]
        },
...

There are quite a lot after this but an error occurs in SE console and only the first passive is added ingame for barbarian (all subsequent insertions are no longer there but were individually functional before that).

[ERROR]: [string "SubclassCompatibilityFramework/JsonLayer/Prog..."]:35: attempt to call a nil value (field 'ParseAndSubmitBoolean')
stack traceback:
    SubclassCompatibilityFramework/JsonLayer/ProgressionHandler.lua:35: in upvalue 'ProgressionSubSectionHandler'
    SubclassCompatibilityFramework/JsonLayer/ProgressionHandler.lua:43: in global 'ProgressionJsonHandler'
    SubclassCompatibilityFramework/JsonLayer/_JsonLoader.lua:6: in upvalue 'SubmitData'
    SubclassCompatibilityFramework/JsonLayer/_JsonLoader.lua:36: in function <SubclassCompatibilityFramework/JsonLayer/_JsonLoader.lua:32>
    [C++ Code]: in function 'xpcall'
    SubclassCompatibilityFramework/JsonLayer/_JsonLoader.lua:47: in global 'LoadConfigFiles'
    SubclassCompatibilityFramework/Init/_InitDefaults.lua:2: in function <SubclassCompatibilityFramework/Init/_InitDefaults.lua:1>
    [C++ Code]: in function 'xpcall'
    builtin://Libs/Event.lua:129: in method 'Throw'
    builtin://Libs/Event.lua:184: in function <builtin://Libs/Event.lua:183>

Copied the boolean from the wiki, full logs and json attached if need be. Extender Runtime 2023-10-26 21-03-13.log CompatibilityFrameworkConfig.json

NellsRelo commented 8 months ago

Ack, typo got past me. Boolean will be updated shortly, alongside some Array support

Mythalar commented 8 months ago

If after all if this all modders do not use the framework to edit vanilla classes...

NellsRelo commented 8 months ago

2.4.12 should resolve the Boolean error you're running into 😄

Mythalar commented 8 months ago

Hum I think there is another one, (or there is a change in the syntax?)

[ERROR]: [string "SubclassCompatibilityFramework/Utils/CacheUti..."]:3: bad argument #1 to 'Get' (string expected, got nil)
stack traceback:
    [C++ Code]: in field 'Get'
    SubclassCompatibilityFramework/Utils/CacheUtils.lua:3: in field 'CacheOrRetrieve'
    SubclassCompatibilityFramework/CompatibilitySupport/BooleanSupport/BooleanSet.lua:3: in upvalue 'SetBoolean'
    SubclassCompatibilityFramework/CompatibilitySupport/BooleanSupport/BooleanSet.lua:14: in global 'HandleBoolean'
    SubclassCompatibilityFramework/API/BooleanApi.lua:11: in field 'Booleans'
    SubclassCompatibilityFramework/JsonLayer/_Utils.lua:185: in field 'ParseAndSubmitBoolean'
    SubclassCompatibilityFramework/JsonLayer/ProgressionHandler.lua:44: in upvalue 'ProgressionSubSectionHandler'
    SubclassCompatibilityFramework/JsonLayer/ProgressionHandler.lua:52: in global 'ProgressionJsonHandler'
    SubclassCompatibilityFramework/JsonLayer/_JsonLoader.lua:6: in upvalue 'SubmitData'
    SubclassCompatibilityFramework/JsonLayer/_JsonLoader.lua:36: in function <SubclassCompatibilityFramework/JsonLayer/_JsonLoader.lua:32>
    [C++ Code]: in function 'xpcall'
    SubclassCompatibilityFramework/JsonLayer/_JsonLoader.lua:47: in global 'LoadConfigFiles'
    SubclassCompatibilityFramework/Init/_InitDefaults.lua:2: in function <SubclassCompatibilityFramework/Init/_InitDefaults.lua:1>
    [C++ Code]: in function 'xpcall'
    builtin://Libs/Event.lua:129: in method 'Throw'
    builtin://Libs/Event.lua:184: in function <builtin://Libs/Event.lua:183>
NellsRelo commented 8 months ago

Aaaaand another typo, both in my test data and my function 🤦‍♂️ It was trying to send data.UUIT instead of data.UUID. 2.4.13 uploading now with a fix

Mythalar commented 8 months ago

Well this is becoming weird (that's version number 13)...

No more error in SE console, but now not any single thing I added to config json is in game (progression or lists).

config file attached since I can't see glaring issue inside and I wanted to wait for it to work before doing the other classes et testing the lists guid arrays, and I think it will not be the evening since it's getting late :p CompatibilityFrameworkConfig.json

(There are 2 "Remove Selectors" that I did not test but it should not be the issue)

NellsRelo commented 8 months ago

Let me know if 2.4.14 resolves the issue. I loaded up your config json, and got a few errors - there were some errors I couldn't resolve that I'm assuming relate to non-vanilla lists, but I was able to make a few tweaks in the code to get past some of them.

Mythalar commented 8 months ago

Yes you are right, nearly all lists are related to other mods.

With last release lists, booleans, passives and selectors seem to be okay but one : boosts (spellslots in my file) are applied twice.

Perhaps that's my fault : To double spellslots I inserted a boost that is identical to the vanilla one, IE lvl1 bard has "ActionResource(SpellSlot,2,1)" twice instead of only one "ActionResource(SpellSlot,4,1)"

Is it better to do this, if even possible ? :

"Action": "Remove",
                    "Type": "Boosts",
                    "Strings": [
                        "ActionResource(SpellSlot,2,1)"
                    ],
"Action": "Insert",
                    "Type": "Boosts",
                    "Strings": [
                        "ActionResource(SpellSlot,4,1)"
                    ]
NellsRelo commented 8 months ago

As of 2.4.15, you can 😄

Mythalar commented 8 months ago

So quick 'o'

Seems you also fixed the doubled boost since now it only shows twice in game ang not thrice (vanilla + 2 x inserted boost).

But the Remove Strings also work and it's cleaner so thanks !

Last thing I can think of, except for occasional bugs, can I remove selectors as of now? Goal is to modify the number of spells one class can select upon level up.

IE bard can choose 4 spells at lvl 1 so has SelectSpells(dcb45167-86bd-4297-9b9d-c295be51af5b,4,0,BardSpells)

I want to change it to something else, say 6, should I do

{
                    "Action": "Remove",
                    "Function": "SelectSpells",
                    "Params": {
                        "Guid": "dcb45167-86bd-4297-9b9d-c295be51af5b",
                        "Amount": "4",
                        "Prepared": "0"
                    }
                },
{
                    "Action": "Insert",
                    "Function": "SelectSpells",
                    "Params": {
                        "Guid": "dcb45167-86bd-4297-9b9d-c295be51af5b",
                        "Amount": "6",
                        "Prepared": "0"
                    }
                }

Is it important to specify BardSpells parameter to ensure the removal since the vanilla selector does include it?

If not supported that's not a real problem, I can just insert a second SelectSpells ^^

Mythalar commented 8 months ago

Seems there is an issue with the Remove Strings, or I do not use it as I have to :

{
            "Comment": "Druid 1",
            "UUID": "b499258c-2823-42f1-b8ca-0a5ee8455e11",
            "Strings": [
                {
                    "Action": "Remove",
                    "Type": "Boosts",
                    "Strings": [
                        "ActionResource(SpellSlot,2,1)"
                    ]
                },
                {
                    "Action": "Insert",
                    "Type": "Boosts",
                    "Strings": [
                        "ActionResource(SpellSlot,4,1)"
                    ]
                },
                {
                    "Action": "Insert",
                    "Type": "PassivesAdded",
                    "Strings": [
                        "GrimHarvest",
                        "SculptSpells"
                    ]
                }
            ]
        },
        {
            "Comment": "Druid 2",
            "UUID": "95322dde-349a-4101-964f-9aa46abd890b",
            "Strings": [
                {
                    "Action": "Remove",
                    "Type": "Boosts",
                    "Strings": [
                        "ActionResource(SpellSlot,1,1)"
                    ]
                },
                {
                    "Action": "Insert",
                    "Type": "Boosts",
                    "Strings": [
                        "ActionResource(SpellSlot,2,1)"
                    ]
                }
            ],
            "Booleans": [
                {
                    "Key": "AllowImprovement",
                    "Value": true
                }
            ]
        },

And then it goes on until lvl12. The first lvl is perfect as it gives 4 spellslots but upon level up I have no more spellsplots at all.

Stranger : using SE console to look at the progression of lvl 2+ I can see the inserted boosts are there (and the removed one are not) :

{
    "AddSpells" : {},
    "AllowImprovement" : true,
    "Boosts" : ";ActionResource(SpellSlot,2,1)",
    "IsMulticlass" : false,
    "Level" : 2,
    "Name" : "Druid",
    "PassivesAdded" : "",
    "PassivesRemoved" : "",
    "ProgressionType" : 0,
    "ResourceUUID" : "95322dde-349a-4101-964f-9aa46abd890b",
    "SelectAbilities" : {},
    "SelectAbilityBonus" : {},
    "SelectEquipment" : {},
    "SelectPassives" : {},
    "SelectSkills" : {},
    "SelectSkillsExpertise" : {},
    "SelectSpells" : {},
    "SubClasses" : 
    {
        "1" : "7458da78-34b7-4150-a42f-37197ab04510",
        "2" : "3eab0689-e51b-4634-a690-0375d3cb2716",
        "3" : "4b61af6c-4a44-436e-aa0a-0d11a2d6b8ee",
        "4" : "90615bcd-6584-4ba7-8196-6df053d263fe"
    },
    "TableUUID" : "6e7b7bad-e122-4679-8b3c-8f8987a9d466",
    "field_D0" : {}
}

Extender Runtime 2023-10-27 10-42-28.log CompatibilityFrameworkConfig.json

NellsRelo commented 8 months ago

For selectors, currently Removing Selectors can only be done using the API - the Config method's implementation is unfinished.

For the lists, that's very odd - wonder if it relates to the preceding semicolon, I'll see if I can clean that up a bit. I wonder, does it still occur when you have the insert placed above the remove entry?

Mythalar commented 8 months ago

Noted for selectors.

Regarding Boost/spellslots it does indeed work when insert is before remove. I change all the druid progression, which work, et try again as a bard (remove before insert) and it does not.

NellsRelo commented 8 months ago

Hrm, I wonder if it might be related to how I'm caching the game data. For now, inserting before removing will be the workaround, but I'll look more into making it work in either direction.

Mythalar commented 8 months ago

Good enough for me really. It seemed to me more logical to clean the strings before adding to them but if swapping works that's nice ^^