How do I use the IF/THEN NODE feature?

Conditional constructs are features which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false. Apart from the case of branch predication, this is always achieved by selectively altering the control flow based on some condition. (Well, that pretty much sums it up, don't it? :-P)

The If/Then Node (also known as the If/Else Node) is a simple way to check if a Variable is set to one thing or not. IF it is, then go one way. IF it isn't, then go the other way.

1. Let's use the Variable Node example (see the Variable Node FAQ) where we set the Variable {spell} to be either the "Forceful" spell or the "Levicorpus" spell. Click on the (+) icon under the Message Node...

2. Click on the [More} icon to open the Advanced Nodes menu...

3. Select "Add If/Then Node"

4. Viola! Brand new If/Then nodes appear:

5. Click on the left-side If/Then Node to open the pop-up.

6. Select a Variable Label (that you specified previously). In this example, choose {spell}...

7. Type in the value you want to look for. In this case, I want to look for Dumbledore's "Forceful" spell. Click OK to exit.

8. I set the If Node to look for the {spell} = Forceful.

If indeed, {spell} = Forceful (because Dumbledore was previously chosen), then you proceed down the left-side branch, and Dumbledore talks to you. ELSE-wise you go down the right-side branch.

Here is the ELSE side (with Snape eventually talking to Harry.)

If you use numbers as values, you can check for various states.

E.g.: X=1, X>1, Y< 3.14, etc.

If you're really feeling intrepid, you can even set up additional and/or checks.

E.g.: Check if X=1 AND Y=1, otherwise go down the ELSE branch.

Note that deleting an If/Then node is a multi-step process. You have to delete the "If/Then" overlay, and then delete the underlying Decision nodes.

This article was helpful for 17 people. Is this article helpful for you?