OpenXcom Forum
OpenXcom Forks => OpenXcom Extended (OXCE) => OXCE Support => Topic started by: talamask on August 13, 2021, 01:17:30 pm
-
Hi!
Is there a way to use wildcards or patterns when writing rules and referencing types or names?
For example we have several Gauss items in items rul. Their types are STR_GAUSS_PISTOL, STR_GAUSS_RIFLE, STR_GAUSS_HEAVY, etc. If I would like to modify, let's say weight attribute on them I would have to set it like this:
items:
- type: STR_GAUSS_PISTOL
weight: 42
- type: STR_GAUSS_RIFLE
weight: 42
- type: STR_GAUSS_HEAVY
weight: 42
My question is if it is possible to use something like this to modify ALL items that *matches* the pattern written in "type":
items:
- type: STR_GAUSS_*
weight: 42
Thank you!
-
You can use anchors and refNode for that purpose. See the first example here (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)) as reference.
For your example it would be like so
items:
- &STR_HEAVY_GAUSS_ANCHOR
type: STR_GAUSS_PISTOL # dash was removed by purpose
weight: 42 # value which is now part of the anchor
- type: STR_GAUSS_RIFLE
refNode: *STR_HEAVY_GAUSS_ANCHOR # includes weight: 42
- type: STR_GAUSS_HEAVY
refNode: *STR_HEAVY_GAUSS_ANCHOR