Jump to content
Sign in to follow this  
SkogUlv

IF THEN logic ( ArmA )

Recommended Posts

Its late but I dont really know what I am doing wrong with IF THEN logic in ArmA.

Example:

_test = 2;

_work = 2;

If ( _work==1 ) then { hint "work ok" } else { hint "work not ok" };

If ( _test==2 ) then

{

hint "2";

} else

{

hint "not 2";

};

First IF with _work proceeds ok, second with _test fails and gives error :

'|#|};'

Error missing {

No matter how I try stack / add { } I run into same error message.

Anyone able to help out with a proper working example ?

Thanks in advance,

Share this post


Link to post
Share on other sites

I think you'd have better luck on the armed assault mission editing and scripting board:

http://www.flashpoint1985.com/cgi-bin....SF;f=71

Just a polite suggestion. I know that this board doesn't specify the game it's for.

Quick question first, is this in a script or a function?

Second, every example I see of else in arma is using a single line format. Example:

if (_a>_b) then {_a} else {_b}

While theoretically, it shouldn't make a difference, it may. Humor me and try a one liner without the semicolons at the end like this.

If ( _test==2 ) then {hint "2"} else {hint "not 2"}

if that works, try this

If ( _test==2 ) then

{

hint "2"

}

else

{

hint "not 2"

}

Try this too

If ( _test==2 ) then {hint "2";} else {hint "not 2";}

Then tell us which one is breaking it. Or tell us how you fixed it, or how none of that worked.

I would try this stuff myself, but don't have arma yet (german version has shipped to me, but waiting on it to cross the atlantic).

Share this post


Link to post
Share on other sites

If OFP scripting end-of-line is used to mark end of statement so you can't use them like that.

Share this post


Link to post
Share on other sites
I think you'd have better luck on the armed assault mission editing and scripting board:

http://www.flashpoint1985.com/cgi-bin....SF;f=71

Just a polite suggestion.  I know that this board doesn't specify the game it's for.

Quick question first, is this in a script or a function?

Second, every example I see of else in arma is using a single line format.  Example:

if (_a>_b) then {_a} else {_b}

While theoretically, it shouldn't make a difference, it may.  Humor me and try a one liner without the semicolons at the end like this.

If ( _test==2 ) then {hint "2"} else {hint "not 2"}

if that works, try this

If ( _test==2 ) then

{

  hint "2"

}

else

{

  hint "not 2"

}

Try this too

If ( _test==2 ) then {hint "2";} else {hint "not 2";}

Then tell us which one is breaking it.  Or tell us how you fixed it, or how none of that worked.

I would try this stuff myself, but don't have arma yet (german version has shipped to me, but waiting on it to cross the atlantic).

This is from a script that I call using [ this ] exex "testscript.sqs" from the initalize field of a spawning unit (player).

Doing it that way for an easy "debugging" at the moment, until I get the "IFs" right theres no point in advancing with other stuff :-)

Regarding AA own script board, could be I am about to go blind as I didnt see that section but thanks for the tip. ;-)

Your first one liner example works, last one liner example works. However the second example spread out over multiple lines does not work and returns the same error message I started this thread with.

Guess it takes a tad longer over the atlantic, your way... I gotta love what a visa can solve, delivery in 24h etc ;-)

Share this post


Link to post
Share on other sites
If OFP scripting end-of-line is used to mark end of statement so you can't use them like that.

What do you mean ? Shouldnt I terminate the lines using a ; ?

Share this post


Link to post
Share on other sites

I mean that line change is equal to ;. So you are basicly trying to do this:

If ( _test==2 ) then;

{;

hint "2";

} else;

{;

hint "not 2";

};

...which doesn't work.

Share this post


Link to post
Share on other sites

Please continue the discussion here.

@SkogUlv: Don't post a thread twice, next time PM a mod to move the thread.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×