Events: Logical Operators

Post bug reports and ask for game support here.
Post Reply
User avatar
AH4Ever
Posts: 628
Joined: Wed Jul 29, 2009 5:30 pm
Location: NU JOYZ

Events: Logical Operators

Post by AH4Ever »

How do you use both logical operators within a condition section of an event?

Is it even possible?

Will a configuration such as this work:

<condition>
...<or>
......<expression>
......</expression>
......<expression>
......</expression>
...</or>
...<and>
......<expression>
......</expression>
...</and>
</condition>
JJMC

The next best thing to being clever is being able to quote someone who is.

You weren't there Thursday... You MISSED it!
User avatar
doomtrader
Posts: 5319
Joined: Tue Jul 22, 2008 5:21 am
Location: Poland
Contact:

RE: Events: Logical Operators

Post by doomtrader »

Yes, this should work.
User avatar
Bleck
Posts: 741
Joined: Sun Mar 08, 2009 1:35 pm
Location: Poland
Contact:

RE: Events: Logical Operators

Post by Bleck »

ORIGINAL: AH4Ever

Will a configuration such as this work:

<condition>
...<or>
......<expression>
......</expression>
......<expression>
......</expression>
...</or>
...<and>
......<expression>
......</expression>
...</and>
</condition>
This won't work as you think. Look:

Code: Select all

 <condition>
 ...<or>
 ......<expression1></expression1>
 ......<expression2></expression2>
 ...</or>
 ...<and>
 ......<expression3></expression3>
 ......<expression4></expression4>
 ...</and>
 </condition>
It can be translated to:

Code: Select all

if (expression1 OR expression2) (expression3 AND expression4) then...
As you can see there is nothing co connect both brackets (OR bracket and AND bracket). It should look like this:

Code: Select all

if ( (expression1 OR expression2) AND (expression3 AND expression4) ) then...
or this:

Code: Select all

if ( (expression1 OR expression2) OR (expression3 AND expression4) ) then...
In other words, there should be only one <and> or <or> node in <condition>, and in this <and> or <or> node you can mix them. For example:

Code: Select all

 <condition>
 ...<and>
 ......<or>
 .........<expression1></expression1>
 .........<expression2></expression2>
 ......</or>
 ......<and>
 .........<expression3></expression3>
 .........<expression4></expression4>
 ......</and>
 ...</and>
 </condition>
 
can be translated as "if any of (expr1 or expr2) and both (expr3 and expr4) then..."


Hope that helps.
Wastelands Interactive member (Programmer)
User avatar
Bleck
Posts: 741
Joined: Sun Mar 08, 2009 1:35 pm
Location: Poland
Contact:

RE: Events: Logical Operators

Post by Bleck »

to delete
Wastelands Interactive member (Programmer)
User avatar
Bleck
Posts: 741
Joined: Sun Mar 08, 2009 1:35 pm
Location: Poland
Contact:

RE: Events: Logical Operators

Post by Bleck »

to delete
Wastelands Interactive member (Programmer)
User avatar
AH4Ever
Posts: 628
Joined: Wed Jul 29, 2009 5:30 pm
Location: NU JOYZ

RE: Events: Logical Operators

Post by AH4Ever »

Thank you, using your example produced what you see.
I hope you approve and it works.


<condition>
...<and>
......<and>
......<!--Random check-->
......<expression>
.........<leftOperand method="System.GetRandomNumber" param0="2" param1="150"/>
.........<operator value="greaterOrEqual"/>
.........<rightOperand constValue="61"/>
......</expression>
......<!--Flag not fired yet-->
......<expression>
.........<leftOperand method="Flag.GetValue" param0="5045"/>
.........<operator value="equals"/>
.........<rightOperand constValue="0"/>
......</expression>
......</and>
......<or>
......<!--Ships at sea-->
......<expression>
.........<leftOperand method="AI.IsSeaZonePatrolled" param0="2" param1="12" param2="0"/>
.........<operator value="equals"/>
.........<rightOperand constValue="1"/>
......</expression>
......<!--Ships at sea-->
......<expression>
.........<leftOperand method="Country.GetShipsAmountInSeaZone" param0="2" param1="12" param2="41"/>
.........<operator value="equals"/>
.........<rightOperand constValue="1"/>
.......</expression>
......</or>
...</and>
</condition>
JJMC

The next best thing to being clever is being able to quote someone who is.

You weren't there Thursday... You MISSED it!
User avatar
Bleck
Posts: 741
Joined: Sun Mar 08, 2009 1:35 pm
Location: Poland
Contact:

RE: Events: Logical Operators

Post by Bleck »

Yes, this should work.
Wastelands Interactive member (Programmer)
Post Reply

Return to “Tech Support”