Run Equation on Variable
The Run Equation on Variable action when triggered applies a numerical equation to the value of any custom variable. It can be referenced in any action or condition throughout your bot's commands and events. All variables and options can be used in the content of the equation.
This action cannot modify collection variables.
Custom Variable
In this section, you can manage which variable the bot will set. You can select from a dropdown that will display the bot's variables. Variables on this list can be added, edited, and removed using the Data Storage module.
Targets
When using the Run Equation on Variable action on a user or channel variable, a Targets section will be displayed. This will allow you to set the user or channel to reset the variable for.
User Target
User Target only appears for user variables.
The Run Equation on Variable action has three options that change to whom the variable of the action is stored. Below you can find detailed information about each option and how it can be used.
By selecting this option your variable will be stored to the user who used the most recent interaction; for example, the most recent button press, select menu choice, command run or the user who triggered the custom event.
Channel Target
Channel Target only appears for channel variables.
The Run Equation on Variable action has two options that change to which channel the variable of the action is stored. Below you can find detailed information about each option and how it can be used.
By selecting this option your Variable will be stored to a channel specified via its ID.
Channel ID or Variable
Here you can set the ID of the channel to set a variable for. You can do this by pasting an ID directly from Discord (learn how here) or using a variable that returns a channel ID. These can be easily added through the variable selector by clicking the Clipboard button.
Objects
These fields only appear for object variables.
Object type variables in the run equation block function the same as they would in the set variable block. In this case it runs an equation on a specific key that is accessible via dot notation. Once the command / event is triggered, it sets the result / value for that key.
Key
This field targets the key of the object property's value to run the equation on. You can use any existing or new key from the object variable.
Value
The value is the actual equation that the bot should store when the action is triggered. You can use any variable or option in the content of this value. These can be easily added through the variable selector by clicking the Clipboard button.
Round Result
The Run Equation on Variable action has two options that change whether decimals can be stored in the variable of the action. Below you can find detailed information about each option and how it can be used.
By selecting this option your Variable will be stored as the nearest whole number, regardless of whether the equation's solution contains a decimal.
The number will be rounded up if mathematically correct.
Equation
The equation of the action is the actual expression that the bot should calculate and store when the action is triggered. The result can be negative, and the equation will respect order of operations. You can use any variable or option in the content of this reply. These can be easily added through the variable selector by clicking the Clipboard button.
Below is a reference of the signs that can be used in the equation:
Signs | Information |
---|---|
var | Represents the current value of the Custom Variable you selected. |
+ | Represents addition. |
- | Represents subtraction. |
* | Represents multiplication. |
/ | Represents division. |
^ | Represents exponentiation. |
( ) | Represents brackets. Using them will affect the order of operations in your equation. |
Below is a list of some examples for equations:
Equation | Value of "var" | Result |
---|---|---|
var + 5 | 1 | 6 |
var * 2 | 4 | 8 |
var / 2 | 8 | 4 |
var - 5 | 6 | 1 |
var ^ 3 | 2 | 8 |
var^(1/3) | 8 | 2 |
var * (5+2) | -2 | -14 |
Last updated