Operators in CK Perks

Post » Tue Nov 05, 2013 6:15 am

I want the conditions of a perk to work like this:

IfDoingThisThing AND HasKeyWordA OR HasKeyWordB, then apply this perk.

IfDoingThisThing None == 1.00 AND

IfHAsKeyword KeyWordA == 1.00 OR

IfHAsKeyword KeyWordB == 1.00 AND?

But when reading up on Operators in Papyrus scripts, it says that if the first AND is True and the OR is true, it does not proceed to the rest of the statement. This implies that the above will not work.

So how does it work in the CK?

Should it be like this?

IfDoingThisThing None == 1.00 AND

IfHAsKeyword KeyWordA == 1.00 AND

IfHAsKeyword KeyWordB == 1.00 OR

Or something else?

Cheers!

~.~

User avatar
Dj Matty P
 
Posts: 3398
Joined: Sat Jun 09, 2007 12:31 am

Post » Tue Nov 05, 2013 3:03 am

So do you want: (IfDoingThisThing AND HasKeyWordA) OR HasKeyWordB

Or do you want: IfDoingThisThing AND (HasKeyWordA OR HasKeyWordB)

If you want the second option of these two, then use:

IfDoingThisThing None == 1.00 AND

IfHAsKeyword KeyWordA == 1.00 OR

IfHAsKeyword KeyWordB == 1.00

The final operator doesn't matter - it can be And or Or - since nothing comes next as another condition the game just throws it out.

User avatar
Kerri Lee
 
Posts: 3404
Joined: Sun Feb 25, 2007 9:37 pm

Post » Tue Nov 05, 2013 5:59 am

I want to use

IfDoingThisThing

AND you have either

(HasKeyWordA OR HasKeyWordB)

So I need to use:

IfDoingThisThing None == 1.00 AND

IfHAsKeyword KeyWordA == 1.00 OR

IfHAsKeyword KeyWordB == 1.00 OR

Cheers!

User avatar
Jodie Bardgett
 
Posts: 3491
Joined: Sat Jul 29, 2006 9:38 pm

Post » Mon Nov 04, 2013 4:43 pm

Papyrus and Conditions are evaluated differently, AND takes precedence over OR within papyrus, in condition functions OR takes Precedence over AND.

Effectively it equates to this (Using brackets to show how it will be evaluated).

Papyrus : (IfDoingThisThing AND IfHasKeyword) OR IfHasKeyword

So if the left side evaluates to TRUE then there is no need to check the second expression as it's already established the statement is TRUE.

Condition: IfDoingThisThing AND (IfHasKeyword OR IfHasKeyword)

If the first value is TRUE, it will continue to evaluate the rest as it has not fulfilled the requirements to be TRUE yet.

User avatar
Brιonα Renae
 
Posts: 3430
Joined: Mon Oct 22, 2007 3:10 am

Post » Tue Nov 05, 2013 7:57 am

Ah, yes, I think I was misinterpreting it as I recalled reading that OR takes priority, I could not remember where exactly.

But the second and third conditions are mutually exclusive anyway, so the First cannot be True if the Second is.


Cheers!

PS thanks for using colours as I find it easier to see. I am one of those people that needs every step in simple algebra laid out for me to follow the trail. :D
User avatar
bimsy
 
Posts: 3541
Joined: Wed Oct 11, 2006 3:04 pm


Return to V - Skyrim