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...

Image 141


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

Image 143


3. Select "Add If/Then Node"

Image 145



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


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

Image 147


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

Image 148


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.

Image 150


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.

Image 152


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

Image 153


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

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

Image 154


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.

Image 155


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?