amtep / ck3-tiger

Checks Crusader Kings 3 user mod files for common mistakes and warns about them.
GNU General Public License v3.0
36 stars 13 forks source link

[CK3] <compare_complex_value> (Wildcards) Parsing issue #152

Open xhsu opened 6 days ago

xhsu commented 6 days ago

Hi there,

There seem to be some issues with edging cases when compare_complex_value is used in CK3. It's hard to describe, as I have absolutely no idea what this is officially called.

Consider this example: In script_values/example.txt we have:

example_scripted_val = 
{
    value = "has_trait_xp(lifestyle_hunter|falconer)"
}

In order to get the XP value of a specific track from a specific trait.

This "evaluating string" weird thingy was called compare_complex_value in dumped logs/event_target.log. It will causes ck3 tiger to have errors all over the place, in our example it was:

error(validation): unknown token `has_trait_xp`
 --> [MOD] common\script_values\example.txt
3 |     value = "has_trait_xp(lifestyle_hunter|falconer)"
  |              ^^^^^^^^^^^^ 

Hopefully, this won't get messy to fix. Can't come with a PR, as I have no idea what rust is doing, as I am a c++er. lol

Sincerely, HYDROGEN

PS: Here is the dumped official info for compare_complex_value, and I have to say the official example is bullish!t, they have no idea what they were writing and providing.

compare_complex_value - A comparison trigger that needs a parsable string parameter that will return its value in the context it is used eg: scope:root.number_of(armies)
Wild Card: yes
Requires Data: yes
Output Scopes: value
amtep commented 6 days ago

Thank you :) has_trait_xp is a weird case because it has the trait|track format that needs to be parsed specially.

xhsu commented 4 days ago

Hi amtep:

I highly suspect this is the case for 'invoking with multi-argument functions' in CK3 script. A long-term solution might be worth investing in.

Which means I suspect this is under the hood:

"fn(arg1|arg2|...)"

were explained as

return std::invoke(fn, arg1, arg2, ...);

(as in CPP)