Or?

Post » Tue Jun 19, 2012 11:47 pm

Hi.

I want to check if an object is either array 0 or array 1, I just can't figure out how to use "or" in Papyrus.
I tried these:

if (HT_TrapReplacement == HT_TrapReplaceItemCheck[0]) or (HT_TrapReplacement == HT_TrapReplaceItemCheck[1])


if (HT_TrapReplacement == HT_TrapReplaceItemCheck[0] or HT_TrapReplacement == HT_TrapReplaceItemCheck[1])

But neither compiles.
I rather not make another elseif check with the same actions in two different comparisons.
User avatar
Rozlyn Robinson
 
Posts: 3528
Joined: Wed Jun 21, 2006 1:25 am

Post » Wed Jun 20, 2012 4:34 am

|| is or just as in c+ or javascript, && is and.
User avatar
Jonathan Egan
 
Posts: 3432
Joined: Fri Jun 22, 2007 3:27 pm

Post » Wed Jun 20, 2012 7:13 am

|| is or just as in c+ or javascript, && is and.

Ah.
Thank you. =)
User avatar
Dawn Porter
 
Posts: 3449
Joined: Sun Jun 18, 2006 11:17 am

Post » Wed Jun 20, 2012 8:24 am

Just so you know, this information is available in the wiki's http://www.creationkit.com/Operator_Reference.

Cipscis
User avatar
matt oneil
 
Posts: 3383
Joined: Tue Oct 09, 2007 12:54 am

Post » Wed Jun 20, 2012 10:20 am

Where it really gets hairy is in quest conditionals, which is just a list of conditions with "AND" or "OR" affixed to the end. There are no parentheses equivalents, so it is hard to do something like

If ((A == B ) || (C == D) && !(B == C) ; This means "If A and B are the same, OR C and D are the same, and B and C are different"

You can do it in a script, but doing it in quest conditionals is hard, if not impossible.
User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Wed Jun 20, 2012 7:13 am

Where it really gets hairy is in quest conditionals, which is just a list of conditions with "AND" or "OR" affixed to the end. There are no parentheses equivalents, so it is hard to do something like

If ((A == B ) || (C == D) && !(B == C) ; This means "If A and B are the same, OR C and D are the same, and B and C are different"

You can do it in a script, but doing it in quest conditionals is hard, if not impossible.

I haven't tried it, but I'd assume AND binds more tightly than OR.

If so you could write

A && (B || C) as  A && B || A && C 

Which would be a pain, but better than nothing.
User avatar
Silvia Gil
 
Posts: 3433
Joined: Mon Nov 20, 2006 9:31 pm

Post » Wed Jun 20, 2012 4:06 am

In Oblivion, I think I remember OR binding more tightly than AND. But who knows, it might have changed.
User avatar
naomi
 
Posts: 3400
Joined: Tue Jul 11, 2006 2:58 pm

Post » Wed Jun 20, 2012 6:52 am

Oblivion scripts use the standard operator precedence as well: "multiplication and division before addition or subtraction"

The rumor that Oblivion works differently comes from an ambiguous description on the Wiki pages regarding dialogue / quest conditions.


Forget all you know about script operators when working with the condition-menus AND / OR is just slang for "Always" and "One of them".

A condition flagged with AND must always apply. Of the conditions flagged with OR only one needs to apply. The sequence doesn't matter

((A == B ) || (C == D)) && !(B == C) is

A == B / OR
C == D / OR
B != C / AND

as is

A == B / OR
B != C / AND
C == D / OR


(A == B ) || (C == D) && !(B == C) can't be done that way if you need the condition to be true when A=B=C.
if you really need such a complicated condition it's better to split it up or use a script to set a simple flag for the condition.
User avatar
Ebony Lawson
 
Posts: 3504
Joined: Fri Feb 16, 2007 11:00 am


Return to V - Skyrim

cron