Jump to content

[LE] Help with AND/OR logic for CK Conditions


Recommended Posts

I am familiar with logic when it comes to scripting, especially since it comes with parenthesis. However, I am at a point where I must use CK conditions for certain things to function and I am a bit puzzled with how AND/OR works with complex conditions in CK. Here is what I have in mind script wise for easier understanding:

 

For a magic effect to take place I want the following conditions to be met first:

 

a || b || c || d || e || (f && (g || h || (i && j)))
After running the function through a boolean algebra calculator I found online, here is the result:
a OR b OR c OR d OR e OR (f AND g) OR (f AND h) OR (f AND i AND j)
Based on this, I am assuming that this should be the order in which the conditions are placed? (see below)
a OR
b OR
c OR
f AND
g OR
f AND
h OR
f AND
i AND
j AND
Is this correct? I am guessing that the first 3 conditions (a-c) are correct but where there were parenthesis in the original statements are what's confusing me as well as the fact that OR takes precedence over AND.
Any help would be greatly appreciated!
Link to comment
Share on other sites

The ()'s logic looks wrong ???? ...
A few clips covering the harder part of that. Source

To properly check whether ((A AND B) OR (C AND D)) is true, one would use:
(A OR C AND B OR C AND A OR D AND B OR D)
To properly check whether ((A AND B) OR (C AND D) OR (E AND F)) is true, one would use:
(A OR C OR E AND A OR C OR F AND A OR D OR E AND A OR D OR F AND B OR C OR E AND B OR C OR F AND B OR D OR E AND B OR D OR F)
Edited by NexusComa2
Link to comment
Share on other sites

Not exactly.

 

CK conditions group all adjacent OR's into one set of "parentheses".

So for example in the conditions window,

a AND

b OR

c OR

d AND

 

Is equivalent to:

a && (b || c) && d

 

That's the only way how it works with CK conditions, it's hardwired.

What you wrote:

a OR
b OR
c OR
f AND
g OR
f AND
h OR
f AND
i AND
j AND
will be parsed by the CK as
(a || b || c) && f && (g || h) && f && i && j
That's not what you want if I understand correctly.
I'm not sure if
a || b || c || d || e || (f && (g || h || (i && j)))
can be converted into the CK conditions syntax, it's a bit too complex. You can use the de-Morgan identities and other boolean tricks, I'm not clever enough to figure it out. If you have some boolean calculator, it might help getting it into the desired format.
Link to comment
Share on other sites

WhiteWolf is right. Here are examples: https://www.creationkit.com/index.php?title=Category:Conditions

A or B or C or D or E or (F and G) or (F and H) or (F and I and J)

I think it should look like this in CK conditions:

A or B or C or D or E or F and
A or B or C or D or E or G or H or I and
A or B or C or D or E or G or H or J and

22 conditions, you can probably shorten this with different logic.

Edited by Dromundas
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...