I am trying to set 2 conditions that have to be checked inside the Condition
field of selectOutput
. If the entirety of the first line is false, I want the entirety of the second to be checked. However, using the code below, I am returned the error that only shows for the first instance of ==
of the second statement:
Syntax error on token “==”, invalid AssignmentOperator
agent.isMorning == true && doctorMorning.idle() == 0; agent.isMorning == false && doctorAfternoon.idle() == 0;
Advertisement
Answer
You can package conditions into nested conditions as below:
Now the agent will continue on the “true” exit if the entire first line is true
, else it will check the third line and follow whatever boolean that returns.
NOTE: You cannot use ;
in these 1-line condition code boxes. If you want to write longer code, you must create a function that returns a boolean and call that instead. Especially for complex nested statements like yours, it is often much easier to create a specific function