diff --git a/spec/System/TestModStore_spec.lua b/spec/System/TestModStore_spec.lua new file mode 100644 index 0000000000..d46fb4f3b3 --- /dev/null +++ b/spec/System/TestModStore_spec.lua @@ -0,0 +1,10 @@ +describe("ModStore source filter", function() + it("selects mods without filtering what their tags read", function() + local modDB = new("ModDB"):ModDB() + modDB:NewMod("Multiplier:Socket", "BASE", 1, "Item Sockets") + modDB:NewMod("Life", "INC", 12, "Tree:1", { type = "Multiplier", var = "Socket" }) + modDB:NewMod("Life", "INC", 30, "Item:1") + + assert.are.equals(12, modDB:Sum("INC", { source = "Tree" }, "Life")) + end) +end) diff --git a/src/Classes/ModStore.lua b/src/Classes/ModStore.lua index 0dd30e41d6..e7c4b46ac5 100644 --- a/src/Classes/ModStore.lua +++ b/src/Classes/ModStore.lua @@ -361,6 +361,11 @@ end ---@param globalLimits? table ---@return any function ModStoreClass:EvalMod(mod, cfg, globalLimits) + -- cfg.source only selects which mods a query reads. Multipliers and conditions read by tags can come from any source. + if cfg and cfg.source then + cfg = copyTable(cfg, true) + cfg.source = nil + end local value = mod.value local GetStat = self.GetStat local GetMultiplier = self.GetMultiplier