Modding:Registry Object JSON Parsing: Difference between revisions

From Vintage Story Wiki
→‎Filtering out variants: Document which regex flavor is used
(→‎Filtering out variants: document asset regex patterns)
(→‎Filtering out variants: Document which regex flavor is used)
 
Line 91: Line 91:
After a list of possible variants is enumerated, the list may be filtered down to exclude some combinations. The <code>skipVariants</code> property acts like a denylist: variants matching the denylist are filtered out. The default <code>skipVariants</code> does not filter out any variants. The <code>allowedVariants</code> acts like an allowlist. Any variant that does not match the allowlist is filtered out. The default <code>allowVariants</code> allows all variants (acts like <code>*</code>). <code>skipVariants</code> is processed before <code>allowedVariants</code>. So if a resolved variant matches both lists, <code>skipVariants</code> takes precedence.
After a list of possible variants is enumerated, the list may be filtered down to exclude some combinations. The <code>skipVariants</code> property acts like a denylist: variants matching the denylist are filtered out. The default <code>skipVariants</code> does not filter out any variants. The <code>allowedVariants</code> acts like an allowlist. Any variant that does not match the allowlist is filtered out. The default <code>allowVariants</code> allows all variants (acts like <code>*</code>). <code>skipVariants</code> is processed before <code>allowedVariants</code>. So if a resolved variant matches both lists, <code>skipVariants</code> takes precedence.


Both lists support wildcards. With standard patterns, the wildcard char, "*", matches 0 or more of any character, including "-". Alternatively a regex pattern can be denoted by starting the pattern with "@". Both regex and standard patterns must match the entire resolved collectible code (not just a substring in the middle). Standard patterns act the same as a regex pattern where every "*" is replaced with ".*".
Both lists support wildcards. With standard patterns, the wildcard char, "*", matches 0 or more of any character, including "-". Alternatively a regex pattern can be denoted by starting the pattern with "@". The .NET [https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference regex flavor] is used. Both regex and standard patterns must match the entire resolved collectible code (not just a substring in the middle). Standard patterns act the same as a regex pattern where every "*" is replaced with ".*".


The following example uses <code>allowedVariants</code>, <code>skipVariants</code>, and wildcards:
The following example uses <code>allowedVariants</code>, <code>skipVariants</code>, and wildcards:
Confirmedusers
261

edits