Caves of Qud

Caves of Qud

My =subject.waterRitualLiquid= is Yours
UnderDoug 10 月 18 日 下午 8:40
[mod compat] NRE if GatWaterRitualLiquid is called outside a conversation
Just a heads-up, the patch for GetWaterRitualLiquid causes an NRE if there's no speaker when when the method is called.

In GetWaterRitualLiquid.cs, changing:
if (The.Speaker.HasTagOrProperty("WaterRitualAltLiquid")) { __result = The.Speaker.GetTag("WaterRitualAltLiquid"); return false; }
to
if (The.Speaker?.GetPropertyOrTag("WaterRitualAltLiquid", null) is string altLiquid) { __result = altLiquid; return false; }
has fixed it for me. That's adding a "?" after "The.Speaker" (plus the "is" pattern), so that if it's null it doesn't try to continue the method chain and it resolves to false if it's null. It also solves the issue of if something has "WaterRitualAltLiquid" as a property instead of a tag, that __result won't have null assigned to it when GetTag doesn't find the property value. "HasTagOrProperty" checks both tags and properties, but GetTag only retrieves tags. Also, for some reason, it's "HasTagOrProperty" but "GetPropertyOrTag", no idea why.

I love this mod, and I don't want my use of ritual liquids in the game text when I'm writing mods to make them incompatible with this one.

Regarding the use-case: in my Tinkering Bytes mod, I occasionally use a tinker trader's water ritual liquid in the UI game text, but there's no speaker under those circumstances.
最后由 UnderDoug 编辑于; 10 月 18 日 下午 8:49