Author Topic: [Answered] Wildcards or pattern matching  (Read 1673 times)

Offline talamask

  • Squaddie
  • *
  • Posts: 2
    • View Profile
[Answered] Wildcards or pattern matching
« 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!
« Last Edit: February 12, 2023, 11:36:10 am by Meridian »

Offline Buscher

  • Colonel
  • ****
  • Posts: 168
    • View Profile
Re: Wildcards or pattern matching
« Reply #1 on: August 13, 2021, 02:23:16 pm »
You can use anchors and refNode for that purpose. See the first example here as reference.

For your example it would be like so
Code: [Select]
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