Comparison (compile-time)
Comparison is the backbone of logic in both runtime and compile-time code. This page will focus on the compile-time side of comparison.
Simple Comparison
Comparison is formatted universally the same. The primary way of performing a comparison is using $if
, but the $assert
command also shares the same syntax. Comparison compares the left and right side using one of six different operators:
Checks if the left and right sides are equal to each other.
Checks if the left and right sides are not equal to each other.
Checks if the left side is less than the right side.
Checks if the left side is less or equal to the right side.
Checks if the left side is more (greater) than the right side.
Checks if the left side is more (greater) or equal to the right side.
Using If
The $if
command runs a comparison and performs the next statement/block only if it evaluates true.
The example below shows a macro which runs effect @s clear
if the input effect is equal to "clear."
Using Else
The $else
command looks at the result of the last $if
command that was run in the same block, and only performs the next statement/block if that $if
command didn't result with true. It's essentially the inverse.
This example expands and finishes the above example by adding $else
to cover cases where the effect is not "clear."