[or] combined with [and]
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: 876
- Joined: November 28th, 2008, 6:18 pm
[or] combined with [and]
I have a question concerning filters and conditions:
According the wiki the result of the code above should be simutaneously true and false.
So how are combined [and], [or] evaluated? I can imagine
Code: Select all
conditionA # any value
[and]
conditionB # false
[/and]
[or]
conditionC # true
[/or]
So how are combined [and], [or] evaluated? I can imagine
- ((((A and B) or C) and D) or E)
or - (A and (B or (C and (D or E))))
- or ...?
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
- Pentarctagon
- Project Manager
- Posts: 5730
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: [or] combined with [and]
Its pretty straight forward. The follow condition:
would evaluate as true and execute the code inside [then] if -
a=1 and b=2
or
c=3 and d=4
or
e=5
So a, b, c, d, and e could all be equal to 5, and it would still evaluate as true.
Code: Select all
[if]
[variable]
name=a
equals=1
[/variable]
[variable]
name=b
equals=2
[/variable]
[or]
[variable]
name=c
equals=3
[/variable]
[variable]
name=d
equals=4
[/variable]
[/or]
[or]
[variable]
name=e
equals=5
[/variable]
[/or]
[then]
...
a=1 and b=2
or
c=3 and d=4
or
e=5
So a, b, c, d, and e could all be equal to 5, and it would still evaluate as true.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: [or] combined with [and]
My question is what happens is both [and], [or] are used:
I replaced 'or' by 'AND':
a=1 and b=2
AND
c=3 and d=4
or
e=5
I replaced 'or' by 'AND':
a=1 and b=2
AND
c=3 and d=4
or
e=5
Re: [or] combined with [and]
Code: Select all
[filter]
{ANYTHING}
[or]
{X}
[/or]
[/filter]
where {ANYTHING} may contain [and], etc.
However, the documentation on the wiki is wrong, in that it is still possible for the filter to evaluate to false even after one [or] filter evaluates to true. For example:
Code: Select all
[filter]
{ANYTHING}
[or]
{X}
[/or]
[not]
# always fail here
[/not]
[/filter]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: [or] combined with [and]
Thank you.
I expect [and] works similar way like [or] (no need to answer if this is true).
I expect [and] works similar way like [or] (no need to answer if this is true).
Re: [or] combined with [and]
FYI, I updated the wiki documentation for ConditionalActionsWML
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: [or] combined with [and]
1. I like your explanation in this thread much than the one you added to wiki.
2. I am confused. I see you edited [or], but why you didn't edit [and] too?
Now the code in the very beginning of this thread
2. I am confused. I see you edited [or], but why you didn't edit [and] too?
Now the code in the very beginning of this thread
- should be false, because of
wiki wrote:[and]
A condition which must evaluate to true in addition to any others. - and simultaneously it should be true, because of
wiki wrote:[or]
This condition, if true, allows the containing tag to also evaluate as true despite any false conditions preceding this one and without regard to any false conditions in the immediate contents of the containing tag. In other words, if any one [or] tag evaluates as true (and no false [and] or [not] tags come after it) then the action will take place.
Re: [or] combined with [and]
Yes, the documentation still has some room for improvement. The goal is to be precise, concise, and also easily comprehensible. I will edit it again when I think of a better phrasing (or someone else can edit it, if they care to try).
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: [or] combined with [and]
I can try something (but then somebody will have to 'translate' it in a better english).
But I have a question: is the list of Meta Condition Tags evaluated from the first one or from the last one? (And is the evaluation strict or non-strict?)
But I have a question: is the list of Meta Condition Tags evaluated from the first one or from the last one? (And is the evaluation strict or non-strict?)
Re: [or] combined with [and]
Ok, after posting a second revision, I think the explanation of meta-conditions is good enough to leave it alone for now.
While I would hope that most people understand "top-to-bottom" without further explanation, for the sake of completeness I added a section which explains exactly what is meant by top-to-bottom evaluation order.
While I would hope that most people understand "top-to-bottom" without further explanation, for the sake of completeness I added a section which explains exactly what is meant by top-to-bottom evaluation order.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: [or] combined with [and]
- I still see [and] to be confusing
- I think it is confusing that [or], [and], [not] are explained a different way.
[or]
A condition which is joined with the summary of all previous conditions by logical "OR". Therefore, when false, it has no effect, but when true, it turns the effect of all previous conditions to true.
[and]
A condition which is joined with the summary of all previous conditions by logical "AND". Therefore, when true, it has no effect, but when false, it turns the effect of all previous conditions to false.
[not]
A condition which is joined with the summary of all previous conditions by logical "AND NOT". Therefore, when false, it has no effect, but when true, it turns the effect of all previous conditions to false.
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums