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

modGuid validation as Table / Array in JSON Config #90

Open RandoRuda opened 7 months ago

RandoRuda commented 7 months ago

Part of #46

As more and more mods are becoming the backbone of people's playthroughs of BG3, being able to check if multiple mods are loaded before attempting to add things to the queue seems necessary.

In order to avoid causing another refactoring issue, I'm wondering what might be the best implementation method.

1) Use modGuids when requiring multiple mods.

It might not be elegant, but it will work for easier differentiation. It is also a method already used with UUIDs in Progressions.

function ProgressionJsonHandler(data, modGuid)
  Utils.Info("Entering ProgressionJsonHandler")
  for _, progressions in pairs(data) do
    if progressions.UUIDs ~= nil then
      for _, uuid in pairs(progressions.UUIDs) do
        ProgressionSubSectionHandler(progressions, uuid, modGuid)
      end
    elseif progressions.UUID ~= nil then
      ProgressionSubSectionHandler(progressions, progressions.UUID, modGuid)
    end
  end
end

2) Use type(modGuid) to determine if it is a String or a Table.

I don't have much experience with LUA, but I understand this might be a slow or resource heavy method?


In any case, I am curious where others sit. In addition, I guess making sure I don't start building something that has already been started elsewhere on a local repo.

NellsRelo commented 7 months ago

Thankfully, lua's pretty fast, so that method shouldn't be too unwieldly.

I haven't started on this feature, so feel free to build it out :D

NellsRelo commented 7 months ago

Thinking on it, it may be worth having a parentModGuid field automatically filled out in the JSON loader, to differentiate required mods & the mod providing the changes, to assist in debugging