Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions ExtendedExpressions/Help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
ExtendedExpressions

ExtendedExpressions extends the built-in expression syntax to allow multiple
references to a single roll within an expression, advanced bitwise, logical, and
arithmetic operations, and more. Expressions are evaluated internally where
necessary, but care is taken to pass as much of each expression as possible
along to the builtin expression evaluator in order to make inline roll tooltips
as complete as possible.

It is recommended that this script be used in conjunction with the CommandShell
module, which will improve output formatting and command discovery.


Commands:

ExtendedExpressions adds two commands:

!exroll command
Acts like "/roll command", but allows extended expression syntax.

!extend command
Replaces expressions enclosed in backticks (`) with inline rolls using
the extended expression syntax.

Both commands can be passed -h or --help as their only argument to get a help
message for quick reference.


Operators:

The following operators are supported, in decreasing precedence order:

x ** y Exponentiation

!x Logical NOT
~x Bitwise NOT
-x Negation

x * y Multiplication
x / y Division
x % y Modulus

x + y Addition
x - y Subtraction

x << y Left shift
x >> y Right shift

x >= y Comparison (greater than or equal)
x > y Comparison (strictly greater than)
x < y Comparison (strictly less than)
x <= y Comparison (less than or equal)

x = y Equality
x != y Inequality

x & y Bitwise AND

x ^ y Bitwise XOR

x | y Bitwise OR

x && y Logical AND

x || y Logical OR

x ? y : z Conditional evaluation


Additional Syntax:

"string" String literal. Expressions which evaluate to strings will be
placed inline directly rather than as inline rolls.

exp[label] Apply label to the preceeding expression for later reference.
Precedence is higher than every operator except "d" (the dice
operator). Use parentheses to label the size of a die rather
than the result of the roll (e.g. "1d(4[diesize])").

${label} Substitute in the value of the referenced expression. Label can
be either an identifier or a string expression.


Examples:

!exroll 1t["table-number-" + 1d6] weather
Internally rolls 1d6, concatenates it with the string "table-number-", and
submits a command of the form "/roll 1t[table-number-3] weather".

!extend Attack: `(1d20+7)[tohit]`, `(${tohit}>=15 ? "hit for [[1d6]]" : "miss")`
Internally rolls 1d20+7, compares the result against 15, and submits a
command like "Attack: [[12]], miss" or "Attack: [[19]], hit for [[1d6]]".

!extend `1d6[foo]+1d6[bar]+${(1d2-1 ? "foo" : "bar")}`
Internally rolls 1d2-1, then submits a command like "[[3+1d6[bar]+3]]" or
"[[1d6[foo]+2+2]]".
Loading