[solved] result of conditional with invalid qualifier
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.
-
- Posts: 1241
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
[solved] result of conditional with invalid qualifier
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.
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.
Re: result of conditional with invalid qualifier
You could make https://github.com/wesnoth/wesnoth/blob ... ls.lua#L25 wml.error if none of comparisons is provided.
Re: result of conditional with invalid qualifier
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.
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
- Celtic_Minstrel
- Developer
- Posts: 2256
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: result of conditional with invalid qualifier
I agree, a variable condition with no valid condition should raise an error, not simply return always true.
-
- Posts: 1241
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: result of conditional with invalid qualifier
Speak softly, and carry Doombringer.