[solved] comma = or syntax

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
white_haired_uncle
Posts: 1231
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

[solved] comma = or syntax

Post by white_haired_uncle »

Often, you can use a comma to represent (effectively) "or", like type=Ghost,Wraith,Shadow. But, is this on a case by case basis (at least where it makes sense), or is it a general rule? Does it apply only to values, or keys as well?

I guess I should ask about "-" for range as well.

In particular I'm looking to do something like the following without all that [or][/or] stuff, or rand, or WFL. I can make what I want work, I just want to know if I could make it this easy. But my question is about the general case.

Code: Select all

[if]
  [variable]
      name=$unit.level
      equals=3,4,5
      #equals=3-5


[unit_type]
   type=Bridge Guardian
   name="Heimdallr", "Hallinskiði", "Vindhlér"
Bonus question: Are proper names normally treated as translatable, or not? Does it matter if they are famous characters known by different names in multiple languages (a bad example, but the best I can think of would be Ares/Mars who IIRC are basically the same guy), vs John Smith, the baker at the local doughnut shop?
Last edited by white_haired_uncle on April 24th, 2024, 4:54 pm, edited 1 time in total.
Speak softly, and carry Doombringer.
User avatar
Ravana
Forum Moderator
Posts: 3025
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: comma = or syntax

Post by Ravana »

For multiple assignements on one line you can do equals,name=3,unit.level. If values to be split themselves contain comma you can probably do something with quotes, but not sure.

For single key like type=Ghost,Wraith,Shadow it is only supported in keys where such support was intentionally added.

I do not expect anyone to translate anything, so I just use _ as syntax to show that something is visible to player.
white_haired_uncle
Posts: 1231
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: comma = or syntax

Post by white_haired_uncle »

If I understand you correctly, in the general case:

Code: Select all

[if]
    [variable]
         name,equals=unit.level,3
is equivalent to:

Code: Select all

[if]
    [variable]
         name=unit.level
         equals=3
While

Code: Select all

[if]
    [variable]
         name=unit.level
         equals=3,4 # or 3-6
might work, if it happens that someone implemented support for this specific case, but cannot be expected to apply to all possible cases (hence, I should probably use [or], or [and] with greater_than and less_than or something).
Speak softly, and carry Doombringer.
User avatar
Ravana
Forum Moderator
Posts: 3025
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: comma = or syntax

Post by Ravana »

Yes.
User avatar
Celtic_Minstrel
Developer
Posts: 2252
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [solved] comma = or syntax

Post by Celtic_Minstrel »

Apart from the case of commas on the left hand side of the =, it's based on the key whether or not a comma has any special meaning. So for example, it won't work with name in most cases.

The same goes for the range syntax – that's specific to certain places and doesn't generally work anywhere.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply