[solved] result of conditional with invalid qualifier

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: 1228
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

[solved] result of conditional with invalid qualifier

Post by white_haired_uncle »

WML and I don't get along real well. It does a lot of things I don't like, I assume in the name of being "user friendly". I'm just not sure if this is one of those times, or if it's a bug (I'm strongly in favor of the latter).

In the following code, [harm_unit] always happens, regardless of the value of weapon.range. I think it should blow up with an error instead.

Code: Select all

        [if]
            [variable]
                name=weapon.range
                equal="melee"
            [/variable]
            [then]
                [harm_unit]
                    [filter]
                        x,y=$x1,$y1
                    [/filter]
                    [filter_second]
                        x,y=$x2,$y2
                    [/filter_second]
                    amount=$damage_inflicted
                    damage_type=lightning
                    fire_event=yes
                    experience=no
                    animate=no
                    kill=yes
                [/harm_unit]
            [/then]
        [/if]
Spoiler:
Last edited by white_haired_uncle on April 19th, 2024, 4:36 am, edited 1 time in total.
Speak softly, and carry Doombringer.
User avatar
Ravana
Forum Moderator
Posts: 3020
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: result of conditional with invalid qualifier

Post by Ravana »

You could make https://github.com/wesnoth/wesnoth/blob ... ls.lua#L25 wml.error if none of comparisons is provided.
Soliton
Site Administrator
Posts: 1688
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: result of conditional with invalid qualifier

Post by Soliton »

This is more like the opposite of user friendliness. There are places where it makes sense to allow arbitrary WML so users can potentially store their own stuff to use elsewhere but conditions and filters and such can definitely benefit from more rigorous checking. Someone just has to implement it.

The schema validation should tell you about this (about the superfluous key not about missing any comparison key) but a runtime check is a good idea either way.
"If gameplay requires it, they can be made to live on Venus." -- scott
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: result of conditional with invalid qualifier

Post by Celtic_Minstrel »

I agree, a variable condition with no valid condition should raise an error, not simply return always true.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
white_haired_uncle
Posts: 1228
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: result of conditional with invalid qualifier

Post by white_haired_uncle »

Speak softly, and carry Doombringer.
Post Reply