Jump to content
Sign in to follow this  
Dwarden

ARMA 2: OA beta build 93666 (1.60 MP compatible build, post 1.60 release)

Recommended Posts

I guess my DayZ days are over, didn't spend thousands on a PC just to look a three black monitors. NVGs only use the centre monitor as well.

Night time is easy mode versus AI, be it DayZ or OA anyway. The player always has the advantage in the dark.

You can play DayZ at day as well. I hope you did not spend those thousands of dollars just to play DayZ at night...

I agree with zimms, it's nice that the Brightness/Gamma "cheat" has been fixed.

Edited by Nicholas

Share this post


Link to post
Share on other sites

Apologies for bringing up this old thread.

Lazy evaluation was added in 93632 and this is the closest beta thread I could find.

[93632] New: Lazy evaluation variants of scripting functions and / or.

The thing is it doesn't work. I don't know if it never worked or got broken somewhere in between now and then, but it sure a must have feature.

It doesn't work for either && or AND

private ["_result1","_result2"];
_result1 = "0";
_result2 = "not ok";
a = {
_result1 = "1";
true;
};
b = {
_result1 = "2";
true;
};
c = {
_result1 = "3";
true;
};
if (call a && call b && call c) then {
_result2 = "ok";
};
hintSilent format ["%1 - %2", _result1, _result2];

The results are:

true true true => 3 - ok

true true false => 3 - not ok

true false false => 3 - not ok

false false false => 3 - not ok

false false true => 3 - not ok

false true true => 3 - not ok

true false true = > 3 - not ok

Lazy evaluation for || or OR is equally broken:

private ["_result1","_result2"];
_result1 = "0";
_result2 = "not ok";
a = {
_result1 = "1";
true;
};
b = {
_result1 = "2";
true;
};
c = {
_result1 = "3";
true;
};
if (call a or call b or call c) then {
_result2 = "ok";
};
hintSilent format ["%1 - %2", _result1, _result2];

Results:

true true true => 3 - ok

true true fasle => 3 - ok

true false false => 3 - ok

false false false => 3 - not ok

false false true => 3 - ok

false true true => 3 - ok

true false true = > 3 - ok

Basically no matter what the expression is getting evaluated till the end even though there is no point.

Again sorry for replying to the old thread, I cannot make a new one.

Share this post


Link to post
Share on other sites

when I was testing Arma 3 merge of the lazy evaluation, here is what I used for test

OA 1.62.102678

//AND: when lazy evaluation is used (if left operand is false, evaluation of the right side is skipped completely).

//OR: when lazy evaluation is used (if left operand is true, evaluation of the right side is skipped completely).

//test code (e.g. in unit init)

if ( (false) AND {diag_log "ANDfalse";} ) then {diag_log "Lazy on AND false failed to works!"} else {diag_log "Lazy on AND false works!"};

if ( (true) AND {diag_log "ANDtrue";true} ) then {diag_log "Lazy on AND true works!"};

if ( (false) OR {diag_log "ORfalse";true} ) then {diag_log "Lazy on OR false works!"};

if ( (true) OR {diag_log "ORtrue";} ) then {diag_log "Lazy on OR true works!"};

//result in arma2oa.rpt

"Lazy on AND false works!"

"ANDtrue"

"Lazy on AND true works!"

"ORfalse"

"Lazy on OR false works!"

"Lazy on OR true works!"

//ANDfalse and ORtrue diag_log were skipped correctly

//note

* now needs to be retested in A3alpha 102909

so it was working fine with beta 1.6.2.102678 (and so far I know works still in 1.62.103419)

Share this post


Link to post
Share on other sites

Sorry Dwarden I'm a bit of a noob in ArmA but have some experience with other languages. I'm confused about the use of for example

{diag_log "ANDfalse";} in the if expression.

diag_log "ANDfalse" returns neither true or false in fact

hintSilent format ["%1",{diag_log "ANDfalse";}]; => {diag_log "ANDfalse";}

hintSilent format ["%1",diag_log "ANDfalse"]; => <null>

is there any other more straight forward way to test Lazy evaluation?

---------- Post added at 13:11 ---------- Previous post was at 12:57 ----------

Got it. One of the benefits of lazy evaluation is that it does not check the next condition if the first one fails. So lets say you have an array

you can

if (count _array > 1 && _array select 1 != "") then {};

if Lazy evaluation works properly if array is [] then it should not throw error because _array select 1 doesnt exist. So here is test example

private ["_array"];

_array = ["trololol"];

if (false && _array) then {};

I am intentionally trying to pass array instead of boolean as second evaluation.Result as expected:

Error in expression <y"]; _array = ["trololol"]; if (false && _array) then {};>

Error position: <&& _array) then {};>

Error &&: Type Array, expected Bool,code

I think it is fair to say lazy evaluation is not working properly.

EDIT: tried the 1st example

Error in expression <y = []; if (count _array > 1 && _array select 1 != "") then {};>

Error position: <select 1 != "") then {};>

Error Zero divisor

Edited by Killzone_Kid

Share this post


Link to post
Share on other sites

Alternative syntax lol. So how long can expression be? 1 boolean and then code {} and thats it?

---------- Post added at 14:27 ---------- Previous post was at 14:03 ----------

OK it seems to take as many conditions as you want. the format is

if (bool && {bool1} && {bool2} && {bool3} .....&& {boolN}) then {} else {};

May I suggest to change the syntax to

if ({} || {} || {} || .... {}) then {} else {};

ie make first condition evaluate in {} as well, this way you can indicate to the engine that you are looking for lazy evaluation from the start.

Thanks for your help Dwarden.

Share this post


Link to post
Share on other sites

This is better than I thought

original example rewritten

private ["_result1","_result2"]; 
_result1 = "0"; 
_result2 = "not ok"; 
a = { 
   _result1 = "1"; 
   true; 
}; 
b = { 
   _result1 = "2"; 
   false; 
}; 
c = { 
   _result1 = "3"; 
   true; 
}; 
if (call a && b && c) then { 
   _result2 = "ok"; 
}; 
hintSilent format ["%1 - %2", _result1, _result2]; 

result: 2 - not ok

So simple. Only if you could also do this for the very first condition...

Share this post


Link to post
Share on other sites

...

if (call a && {b && {c}}) then {

...

Share this post


Link to post
Share on other sites
...

if (call a && {b && {c}}) then {

...

This doesnt work and neither is this:

if (call a && {call b && {call c}}) then {

Share this post


Link to post
Share on other sites

but you do realize these 'features' are merged only into dev version of Arma 3 Alpha ... it's not yet in stable branch

Share this post


Link to post
Share on other sites

It works with ArmA 2 as it is. If you make any changes in Arma 3 I will change my blog post accordingly.

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  

×