sexta-feira, 9 de maio de 2014

Relational Operators and Branchs

The relational operators perform a comparison between two values ​​and return a Boolean value (true or false) as a result of the comparison.
The relational operators are as follows:

Operator Comparison
< Less
<= Less or equal
> Greater
>= Greater or equal
== Equal
!= Not equal

The relational operators are grouped by data type within the category "Call Function -> Math" from the list of actions. The image below shows the relational operators that compare values of integer type.

A "Branch" is a type of action that allows you to control the flow of execution of the blueprint based on a boolean value that receives as input in the "Condition" parameter. You find the "Branch" in the category "Utilities -> Flow Control" of the list of actions.
The example below shows the use of a relational operator and a "Branch". At the end of a game we will compare the current player's score (Score variable) with the highest game score (High Score variable). If the player's score is higher, the value of the "Score" variable will be stored in the "High Score" variable.

Click to enlarge

The "Branch" has two execution lines as output. If the condition is true the top line will be executed, if the condition is false the bottom line will be executed.
The "Branch" can receive the value of a Boolean variable in the "Condition" parameter. The following example checks the boolean variable "Has Key", if true the message "The door opens..." will be written, if false will be written the message "You need the key...".

Click to enlarge