Jump to content
Sign in to follow this  
shadow

Something wrong with 'or'

Recommended Posts

Seems to me that 'OR' (||) behaves like 'AND' (&&) in some cases in v1.75

Here's a sample:

I got 2 tanks (tank1 and tank2).

My objective is to steal atleast one of them. I have done this by making one trigger for each of the tanks and grouped them.

When tank1 arrives at a certain point (vehicle present) the trigger sets: 'tank1done=true'.

I did the same with the other with 'tank2done=true'.

In my objective trigger I would expect this condition to word: tank1done || tank2done

...but it does'nt. In this case 'OR' behaves like 'AND'.

'OR' works fine with getdammage/alive etc only not with statements I make.

Is this a bug that came with OFP:R or has it always been there?

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">In this case 'OR' behaves like 'AND'.

<span id='postcolor'>

Can you send some simple mission source demonstrating the problem?

I am quite sure OR works always as OR and not as AND and I expect that after you will send your source, we will be able to find some other problem in the mission.

Share this post


Link to post
Share on other sites

You can send it there, or you can include mission source right in the forum post.

Share this post


Link to post
Share on other sites

I emailed it last night. The mission consists of only 1 player, 2 empty tanks and 3 triggers. The misbehaviour is in there, so I'm pretty sure I have'nt done anything wrong....but you never know tounge.gif

sidenote: the campaign-mission : 'SCRAP' has an objective to steal some armour and it works. Maybe you can look into how you guys solved it there. Just a thought smile.gif

Share this post


Link to post
Share on other sites

OR does behave like AND, check this sample mission.

Use radio Alpha and Bravo.

Mission source no longer needed ... Removed by Suma

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (ALDEGA @ July 24 2002,13:51)</td></tr><tr><td id="QUOTE">OR does behave like AND, check this sample mission.

Use radio Alpha and Bravo.<span id='postcolor'>

The problem with your mission is that go1 and go2 are not initialized.

This is defined as follows (see command reference, Scripting topics/Variables):

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">

Variable must be inicialized before being used. When any uninitialized variable is detected in any expression, the whole expression results nil (undefined value). When undefined value is encountered in field where boolean value is expected, it is converted to false.

<span id='postcolor'>

When you activate Alpha, go1 is set true, but go2 is still undefined. As written in the definition above, when undefined go2 is encountered, whole expression is evaluated as nil, which is then converted to false.

Fixing it is easy: you need to add go1=false;go2=false into init.sqs or init field of some unit.

Share this post


Link to post
Share on other sites

Didn't know this was necessary wink.gif

Thanks for clearing this up.

Share this post


Link to post
Share on other sites

I got the same explanation in an email from Viktor Bocan.

Thanks for reminding me about the pre-init of the variables. wink.gif

It does'nt make any sense why I have to pre-init the variables when using 'OR' but not when using 'AND'

How about making an error msg appear when this issue occur.

Keep up the good work, BIS smile.gif

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">It does'nt make any sense why I have to pre-init the variables when using 'OR' but not when using 'AND'

<span id='postcolor'>

SUMA explained this wink.gif

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Shadow @ July 24 2002,23:40)</td></tr><tr><td id="QUOTE">It does'nt make any sense why I have to pre-init the variables when using 'OR' but not when using 'AND'

How about making an error msg appear when this issue occur.<span id='postcolor'>

Well, with "and" both variables will have a value("true" for example) before the statement is even supposed to be true, but with "or" another of the variable might not exist yet (not "initialised") so the statement wont be true... Makes sense wink.gif

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Kegetys @ July 24 2002,23:10)</td></tr><tr><td id="QUOTE"></span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Shadow @ July 24 2002,23:40)</td></tr><tr><td id="QUOTE">It does'nt make any sense why I have to pre-init the variables when using 'OR' but not when using 'AND'

How about making an error msg appear when this issue occur.<span id='postcolor'>

Well, with "and"  both variables will have a value("true" for example) before the statement is even supposed to be true, but with "or" another of the variable might not exist yet (not "initialised") so the statement wont be true... Makes sense wink.gif<span id='postcolor'>

aaah......but...but...ofcourse when you put it that way biggrin.gif

Thanks, Keg smile.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×