TwitchSpawn
Minecraft 1.16.x
Search…
⌃K
📜

TSL Comparators

Which comparation operators does TSL support?
Comparators are part of the predicates. They basically compare left-hand (which are properties) with right-hand (which are literal values).

Comparator: Arithmetical

Arithmetical comparators are classical operators comparing values by their magnitudes. These kind of comparators require numeric values or string words as right-hand values.
For numeric values, anything accepted by Java is also accepted by arithmetical comparators. (E.g 1, 1.0, 1.0f, 1.0d)

Equals ( = )

example
...
WITH amount = 9.11

Greater than ( > )

example
...
WITH amount > 10.0

Less than ( < )

example
...
WITH viewers < 100

Equal or Greater than ( >= )

example
...
WITH raiders >= 2000

Equal or Less than ( <= )

example
...
WITH donation_amount <= 2000

Comparator: IS

IS comparator checks if left-hand value is equal to the right-hand value char by char.
example
..
WITH actor IS %iGoodie%
WITH currency IS USD
WITH gifted IS true
WITH message IS %I heard you say, hey hey!%

Comparator: PREFIX

PREFIX comparator checks if left-hand value starts with given right-hand value.
example
...
WITH message PREFIX %Hello it's me,%

Comparator: POSTFIX

POSTFIX comparator checks if left-hand value ends with given right-hand value.
example
...
WITH message POSTFIX %, good sir.%

Comparator: IN RANGE

IN RANGE comparator checks if left-hand value is in a certain number range. Right-hand value must be a valid range expression, which is basically two numeric values seperated by a comma inside square brackets.
Any right-hand value not matching mentioned format counts as malformed, and interpreted as a syntax error by the mod. Moreover, since right-hand value MUST be only one word, SPACE character put inbetween also counts as malformed. Exemplar values:
100,200 # Missing square brackets
[100, 200] # Containing SPACE character inbetween
[100,200] # One word, perfect!
example
...
WITH donation_amount IN RANGE [100,200]

Comparator: CONTAINS

CONTAINS comparator checks if left-hand value contains given value
example
...
WITH badges CONTAINS moderator
WITH badges CONTAINS broadcaster
WITH badges CONTAINS vip
WITH badges CONTAINS turbo
WITH badges CONTAINS glhf-pledge
WITH badges CONTAINS bits
WITH message CONTAINS %creeper%