Jump to content

Recommended Posts

First time im attempting an or condition and following the wiki page instruction the best i can make out is it looks something like this...

 

Trigger5_Con or Trigger9_Con  && ["Tsk"] call BIS_fnc_taskState == "SUCCEEDED"

The above is the condition im trying to achieve but it wont work...

 

this works..

 

Trigger5_Con && ["Tsk"] call BIS_fnc_taskState == "SUCCEEDED"

Where am i going wrong with the "or" condition.

For backround what im attempting to do is create a condition for a task to fire,in this case trigger5_con "or" trigger9_con can be the condition to grant the task to player.

Any help appreciated.

 

EDIT i get no errors upon writing the syntax in the trigger condition field but the task simply fail to show when the 1st example in my post is used

  • Like 1

Share this post


Link to post
Share on other sites

I did not understand what u r doing but i guess u want the result true if taskstate is succeded and one of both trigger conditions is true.

There you need some brackets:

(Trigger5_Con or Trigger9_Con)  && ["Tsk"] call BIS_fnc_taskState == "SUCCEEDED"

 

  • Like 1

Share this post


Link to post
Share on other sites
19 minutes ago, sarogahtyp said:

I did not understand what u r doing but i guess u want the result true if taskstate is succeded and one of both trigger conditions is true.

There you need some brackets:


(Trigger5_Con or Trigger9_Con)  && ["Tsk"] call BIS_fnc_taskState == "SUCCEEDED"

 

Yeah you got my meaning. But the method you gave is also not working.

 

I tested each trigger condition(trigger5 and trigger9) individually and they both work fine.But my syntax and the one you wrote dont work

Share this post


Link to post
Share on other sites
6 minutes ago, target_practice said:

By all indications that statement should work, what does it return when you run it?

Can you explain what exactly you mean by return? When i run it nothing is happening,no error,nothing.

 

Looking at the "or' and " | | " conditions around many forums and seeing alot of people in the past not getting this to work

Share this post


Link to post
Share on other sites

The value that the statement produces. Run it in the debug console: it displays the return value of any expression executed in it underneath the text field.

  • Like 1

Share this post


Link to post
Share on other sites
13 minutes ago, target_practice said:

The value that the statement produces. Run it in the debug console: it displays the return value of any expression executed in it underneath the text field.

the extended debug console when pausing game? 

 

Ok i tried,copy pasted the code in,hit enter,got no text returned.

 

Hit local exec and also no text was returned

Share this post


Link to post
Share on other sites

Enter every single statement alone in debug console and tell what its returning

  • Like 1

Share this post


Link to post
Share on other sites
22 minutes ago, sarogahtyp said:

Enter every single statement alone in debug console and tell what its returning

Running each statement alone is returning the following

 

Trigger5 = Trigger5

Trigger9 = Trigger9

["Tsk"] call BIS_fnc_taskState == "SUCCEEDED"  = true.  (false is returned before this task is complete)

 

So it seems everything is fine but it is not giving the task to player

 

 

Share this post


Link to post
Share on other sites

Its not fine. every statement in a condition should return true or false.

  • Like 1

Share this post


Link to post
Share on other sites
32 minutes ago, sarogahtyp said:

Its not fine. every statement in a condition should return true or false.

oh i see.

 

Possibly its something to do with how its set up? Because as i said the triggers fire correctly when told to do so individually.

 

Trigger5 and trigger9 are activated through an add action that i have placed on 2 terminals(one add action calls trigger5 the other calls trigger9).So i start the mission,activate the terminal(i choose one,either 5 or 9) and proceed to complete task "tsk",which is one of the conditions for another trigger to activate to grant the player a new task...Thats where it will not work,no new task is granted if the syntax had the "(Trigger5_Con or Trigger9_Con)".......only works if it had :

 

Trigger5_Con && ["Tsk"] call BIS_fnc_taskState == "SUCCEEDED"

or

 

Trigger9_Con && ["Tsk"] call BIS_fnc_taskState == "SUCCEEDED"

Really strange. It absolutely should be working.I have tried everything i can think of for past 4 hours and am going to give up on this .

Share this post


Link to post
Share on other sites

Can you explain exactly how/where you are setting Trigger5_Con & Trigger9_Con to boolean (true/false)?  Within Trigger5 & Trigger9 On Activation?

 

I suppose another option would be using triggerActivated.  No need for the other variables.  See the note for triggerActivated on the page linked.

((triggerActivated Trigger5 || triggerActivated Trigger9) && ["Tsk"] call BIS_fnc_taskState == "SUCCEEDED")

 

Not tested myself, but without knowing where this boolean statement above is being checked.  I.E. if () then {} statement?

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
7 minutes ago, panther42 said:

Can you explain exactly how/where you are setting Trigger5_Con & Trigger9_Con to boolean (true/false)?  Within Trigger5 & Trigger9 On Activation?

Sure,heres exactly how its being done.

 

So i have 2  terminal objects,in their init i have written

 

this addaction ["infantry mission",{Trigger5_Con = true; publicVariable "Trigger_Con";}];

then i have a trigger called "Trigger5"

 

In its condition

 

Trigger5_Con

I have the same set up(albeit from a different trigger and object) for Trigger9.

 

this addaction ["recon mission",{Trigger9_Con = true; publicVariable "Trigger_Con";}];

Trigger for this one

 

Trigger9_Con

And thats it.By using the add action attached to the object,Trigger5 or trigger9 is activated(which is part of the first post i made about "or" condition)and should pass the condition check in a different trigger which checks that (a) a task named "tsk" is complete(which it is) and (b) either Trigger5 or Trigger9 was activated(via add action on terminal),which they were.

Share this post


Link to post
Share on other sites

The problem as I see it is that the two variables don't exist until their relative actions create them. 

Trigger5_con OR Trigger9_con

isn't evaluating because one of the two doesn't exist. You should initialize them (set them to "false") at mission start.

 

@panther42 's solution is nice because it doesn't require this initialization, but it's handy to understand the issue.

  • Like 1

Share this post


Link to post
Share on other sites
19 minutes ago, Harzach said:

The problem as I see it is that the two variables don't exist until their relative actions create them. 


Trigger5_con OR Trigger9_con

isn't evaluating because one of the two doesn't exist. You should initialize them (set them to "false") at mission start.

 

@panther42 's solution is nice because it doesn't require this initialization, but it's handy to understand the issue.

so one doesnt exist technically untill its activated and setting to false is a kind of way to "register" them. Yeah i had no idea about the evaluation as i just expected them to behave like a normal placed trigger.

 

Quite complicated but i understand your meaning and is quite fun to have sorted this with help and have learned something.

  • Like 2

Share this post


Link to post
Share on other sites

1 - are you sure you need triggers? The addAction already "triggers" a code.

 

2 - if you want to activate a trigger by variable (say var), why not, just set this variable to TRUE, somewhere:   var = TRUE;

then checking inside the trigger condition is simple as : var   // undefined friendly in this case because there is no operators (trigger condition context)

But as Harzach wrote, the condition: var1 or var2 (so a condition implying a logical operator: or ) will return an error due to one or more undefined variable, failing on operator result.

But.. that can be done by checking:  (!isNil "var1" or !isNil "var2") or even

(missionNameSpace getVariable ["var1",false] or missionNameSpace getVariable ["var2",false]) // returns false if a variable is not defined, so no error in case of non-existent variable.

 

3 - if you need to check if triggers are activated, use triggerActivated command as panther42 wrote.

  • Like 4

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

1 - are you sure you need triggers? The addAction already "triggers" a code.

 

2 - if you want to activate a trigger by variable (say var), why not, just set this variable to TRUE, somewhere:   var = TRUE;

then checking inside the trigger condition is simple as : var   // undefined friendly in this case because there is no operators

But as Harzach wrote, the condition: var1 or var2 (so a condition implying a logical operator: or ) will return an error due to one or more undefined variable, failing on operator result.

But.. that can be done by checking:  (!isNil "var1" or !isNil "var2") or even

(missionNameSpace getVariable ["var1",false] or missionNameSpace getVariable ["var2",false]) // returns false if a variable is not defined, so no error in case of non-existent variable.

 

3 - if you need to check if triggers are activated, use triggerActivated command as panther42 wrote.

Yeah i need the triggers because they contain important info in the "on act",which change alot depending on which is selected.In this case deleting units that arent part of the mission type the user will engage in.

 

2. I had to re read that a few times its all a bit over my head im still learning the more complex aspects of scripting,but i appreciate any info that can help me delve deeper.

  • Like 1

Share this post


Link to post
Share on other sites
18 hours ago, redarmy said:

 

Where am I going wrong with the "or" condition.

 

 

 

Place 2 cars on the map. Name them

car1

car2

 

Place a trigger on the map. In the condition field:

 

!(alive car1)  ||  !(alive car2)

 

This means the trigger will fire if either car1 or car 2 is destroyed.

 

Enter the map with a rocket launcher and fire at one car or the other. As soon as either car is destroyed, the trigger will fire.

.

 

 

 

 

 

  • Confused 1

Share this post


Link to post
Share on other sites

Guys please, how to combine trigger conditions? Example:

 

cond:

triggerActivated tg1 || triggerActivated tg2 || triggerActivated tg3 || triggerActivated tg4 || triggerActivated tg5 , but only 3 of them to be enough to satisfy trigger cond and fire it?

For example if tg3, tg1 and tg4 are triggered?

 

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

×