TagScriptEngine Blocks
Core Blocks
Core pythonic TagScriptEngine blocks.
Assignment Block
Variables are useful for choosing a value and referencing it later in a tag. Variables can be referenced using blackets as any other block.
- usage:
{=(<name>):<value>}
- aliases:
assign
,let
andvar
- payload: value
- parameter: name
Random Block
Pick a random item from a list of strings, split by either ~
or ,
.
An optional seed can be provided to the parameter to always choose the same item when
using that seed.
- usage:
{random([seed]):<list>}
- aliases:
#
andrand
- pyload: list
- parameter: seed, None
Math Block Experimental
Evaluate mathematical expressions using the Math Block.
- usage:
{math:expression}
- aliases:
m
,+
andcalc
- payload: math expression
- parameter: None
Range Block
The range block picks a random number from a range of numbers seperated by -
.
The number range is inclusive, so it can pick the starting/ending number as well.
Using the rangef block will pick a number to the tenth decimal place.
An optional seed can be provided to the parameter to always choose the same item when using that seed.
- usage:
{range([seed]):<lowest-highest>}
- aliases:
rangef
- payload: number
- parameter: seed, None
Control Blocks
Control and do more with your tags using the control blocks.
If Block
The if block returns a message based on the passed expression to the parameter. An expression is respresented by two values compare with an operator.
The payload is a required message that must be split by |
. If the expression
evaluates true, then the message before the |
is returned, else the message after
is returned.
- usage:
{if(<expression>):<message>}
- payload: message
- parameter: expression
- operators:
Operator | Check | Example | Description |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Break Block
The break block will force the tag output to only be the payload of this block, if the passed expresssion evaluates true. If no message is provided to the payload, the tag output will be empty.
This differs from the StopBlock
as the stop block stops all tagscript processing
and returns its message while the break block continues to process blocks.
If command blocks exist after the break block, they will still execute.
- usage:
{break(<expression>):[message]}
- aliases:
short
andshortcircuit
- payload: message
- parameter: expression
All Block
The all block checks that all of the passed expressions are true.
Multiple expressions can be passed to the parameter by splitting them with |
.
The payload is a required message that must be split by |
. If the expression evaluates
true, then the message before the |
is returned, else the message after is returned.
- usage:
{all(<expression|expression|...>):<message>}
- aliases:
and
- payload: message
- parameter: expression
Fifty-fifty Block
The fifty-fifty block has a 50% change of returning the payload, and 50% chance of returning null.
- usage:
{50:<message>}
- aliases:
5050
and?
- payload: message
- parameter: None
Stop Block
The stop block stops tag processing if the given parameter is true. If a message is passed to the payload it will return that message.
- usage:
{stop(<bool>):[string]}
- aliases:
halt
anderror
- payload: string, None
- parameter: bool
String Blocks
Manipulate strings in tags using the string blocks.
Replace Block
The replace block will replace specific characters in a string.
The parameter should split by a ,
, containing the characters to find before the
command and the replacements after.
- usage:
{replace(<original,new>):<message>}
- aliases: None
- payload: message
- parameter: original, new
URLEncode Block
This block will encode a given string into a properly formatted url with non-url
compliant characters replaced. Using +
as the parameter will replace spaces
with +
rather than %20
.
- usage:
{urlencode(["+"]):<string>}
- aliases: None
- payload: string
- parameter:
+
, None
Miscellaneous Blocks
Miscellaneous/Utility blocks for tags.
Strftime Block
The strf block converts and formats timestamps based on strftime formatting spec. Two types of timestamps are supported: ISO and epoch. If a timestamp isn’t passed, the current UTC time is used.
Invoking this block with unix
will return the current Unix timestamp.
- usage:
{strf([timestamp]):<format>}
- aliases:
unix
- payload: format, None
- parameter: timestamp