Conditions

Nebula conditions use boolean logic to work. You can add multiple conditions on each file in the conditions parameter list.

Each condition must be placed on a new line as follow :

conditions:

- "condition1"

- "condition2"

- "condition3"

Each condition line has to be verified for the effects to be launched.

For permanent triggers, conditions are unnecessary as permanent effects are active all the time. If conditions are wrote for permanent triggers, they will be ignored.

How boolean logic works ?

Boolean logic is a way to represent and manipulate logical statements using the values of true and false. The most basic elements of Boolean logic are the Boolean variables, which can have one of two values: true or false. These variables can then be combined using logical operators such as "AND", "OR", and "NOT" to form more complex statements.

The AND (&&) operator requires that both of the statements being compared are true for the overall statement to be true. For example, the statement "It is raining AND the streets are wet" would only be true if it is actually raining and the streets are wet.

The OR (||) operator only requires that one of the statements being compared is true for the overall statement to be true. For example, the statement "I am hungry OR I am tired" would be true if either I am hungry or I am tired.

The NOT (!) operator inverts the truth value of the statement. If the original statement is true, the NOT statement will be false and vice versa. For example, the statement "It is not raining" would be true if it is not raining and false if it is raining.

Conditions examples

For these examples, Nebula placeholders will be used.

Using and operator

The parameter conditions in Nebula is a list. Each line is a condition and must be verified, so it can be compared to the and operator.

This :

conditions:

- "%nebula-global_on-horse% && %nebula-global_is-in-water%"

And this

conditions:

- "%nebula-global_on-horse%

- %nebula-global_is-in-water%"

are equivalent, it will be verified if the player is on a horse and in water.

Using or operator

These conditions will be verified either if the player is on a horse or is in water :

conditions:

- "%nebula-global_on-horse% || %nebula-global_is-in-water%"

Using not operator

This condition will be verified if the player is not on a horse :

conditions:

- "!%nebula-global_on-horse%"

Comparisons

How it works ?

You can use comparisons to compare numerical values with these operators :

The "==" operator compares two values and returns true if they are equal, and false if they are not equal. For example, the statement "5 == 5" would return true, while the statement "5 == 6" would return false.

The "!=" operator compares two values and returns true if they are not equal, and false if they are equal. For example, the statement "5 != 6" would return true, while the statement "5 != 5" would return false.

The ">" and "<" operators compare two values and return true if the value on the left is greater or less than the value on the right, respectively. For example, the statement "5 > 4" would return true, while the statement "5 < 4" would return false.

The ">=" and "<=" operators are similar to the ">" and "<" operators, but also take into account the possibility that the two values may be equal. For example, the statement "5 >= 5" would return true, while the statement "5 <= 4" would return false.

Examples

For these examples, ennemy placeholders will be used (see Placeholders)

Using == operator

This condition will be verified if the player has exactly 5 arrows on him :

conditions:

- "%nebula-global_body-arrows%==5"

This condition will be verified is the player has the same health level as the ennemy player :

conditions:

- "%player_health%==@player_health@"

Using != operator

This condition will be verified if the player doesn't have 5 arrows on him (it could be 0,1,2,3,4,6,7 or more) :

conditions:

- "%nebula-global_body-arrows%!=5"

Using > operator

This condition is verified if the player health level is greater than the ennemy's health level :

conditions:

- "%player_health%>@player_health@"

Using <= operator

This condition is verified if the player health level is lower or equal to the ennemy's health level :

conditions:

- "%player_health%<=@player_health@"

Other examples

This condition is verified if the player has the same health level or food level as the ennemy :

conditions:

- "%player_health%==@player_health@ || %player_food_level%==@player_food_level@"

This condition is verified if the player has the same health level as the ennemy and is on horse :

- "%player_health%==@player_health@ && nebula-global_on-horse"

Last updated