🪛Conditions
Display tooltips based on conditions
Reminder
The best tool when working with conditions is the eval command, which allows you to evaluate single conditions very easily. Command usage is seen here.
Introduction
Conditions are defined per preset and allow to control when a preset is displayed to the player. For a preset to be shown, all of its conditions must be evaluated to true.
When conditions are checked, they are checked line by line. The above example would first check if the players gamemode is either creative or survival after which it would check if the player is also looking at a grass block.
Structure
The structure of a singular condition is really simple. It consists of just two parts; the conditions name and its possible arguments inside of curly brackets ( {} ):
All argument types are covered here:
pageArgument TypesIf a condition does not have any required arguments, it can be defined without the curly brackets like so:
All conditions are covered here:
pageCondition listOutcomes
An important part of optimizing conditions, is the ability to stop reading conditions early if some condition is false. For example, all operations that start with "lookingat" are expensive to perform, so it's imperative that they aren't checked often. This can be done using outcomes.
Outcomes are optional and defined at the end of a full condition like so:
Supported outcomes
Outcome | Description |
---|---|
required (or true) | The current line must be true. If it isn't, further conditions won't be checked. |
cancel (or false) | If the current line is true, further conditions won't be checked. |
Examples
If we wanted to check if player is looking at furniture inside of a WorldGuard region called "shop", we'd put the region condition first and give it the "required" outcome:
This way, the region condition will be performed first and only when it is true, will the "lookingatfurniture" run.
Composite conditions
Composite conditions allow you to do more complex logical checks in a single line using operators.
Supported operators
Operator | Description |
---|---|
AND ( also && ) | Left and right part must both be true |
OR ( also || ) | Left or right part must be true |
Examples
Even more extreme example, when operators are combined with parenthesis:
Last updated