Math formula resolving
- Last UpdatedSep 17, 2025
- 2 minute read
With the #mathFormula# or [#mathFormula] syntax, you can include a math formula inside a parameter value assignment. The math formula can contain operators, functions, numeric constants, and parameter values.
Syntax
Nested parameter values assignment is supported.
Scenario example
For example, inside a math operation you can use a numeric value stored inside a DSTRING by retrieving it with a nested value assignment, such as: [#[@myDSTRING.value.elementAt([@myKey.value])]+1]
In this example, a numeric value stored in the dictionary "myDSTRING" at the key corresponding to the value of an SSTRING variable called "myKey" is increased by 1.
Code examples
An example that shows including a math formula.
value="#@start_sel.value@+1#" time="#@tasktimer_timer.duration@*(1-@tasktimer_timer.alpha@)#
value="#@localAvatar.position.x@+@dist.value@*cos(@localAvatar.orientation.x@)# @localAvatar.position.y@ #@localAvatar.position.z@-@dist.value@*sin(@localAvatar.orientation.x@)#"/>
Operators
These are operators that can be used in the math formula.
|
Operator |
Description |
Example |
|---|---|---|
|
+ |
Sums two values. |
#@field.value@+1# |
|
- |
Subtract two values. |
#@field.value@-7# |
|
* |
Multiplies two values. |
#@field.value@*@field2.value@# |
|
/ |
Divide two values. |
#@field.value@/2# |
|
% |
Returns the rest of the division. |
#@field.value@%5# |
Functions
These are functions that can be used in the math formula.
|
Function |
Description |
Example |
|---|---|---|
|
abs |
Returns the absolute of the argument. |
#abs(2)# |
|
acos |
Returns the arc cosine of the argument. |
#acos(0.4343)# |
|
asin |
Returns the arc sine of the argument. |
#asin(-0.53)# |
|
atan |
Returns the atan of the argument. |
#atan(3.14)# |
|
atan2 |
Returns the arc tangent of the angle for the given 2D vector. |
#atan2(0.17,0.81)# |
|
cos |
Returns the cosine of the argument. |
#cos(2)# |
|
cosh |
Returns the hyperbolic cosine of the argument. |
#cosh(2)# |
|
deg |
Converts radiant to degrees. |
#deg(3.14)# |
|
e |
Returns the natural number. |
#e()# |
|
floor |
Returns the floor of the value. |
#floor(2.4)# |
|
log |
Returns the logarithm of a specified number (first parameter) in a specified base (second parameter). |
#log(1000,10)# |
|
max |
Returns the maximum between two numbers. |
#max(2,5)# |
|
min |
Returns the minimum between two numbers. |
#min(2,5)# |
|
pi |
Returns the PI greek. |
#pi()# |
|
pow |
Returns a specified number (first parameter) raised to the specified power (second parameter). |
#pow(13.25,3)# |
|
rad |
Converts degrees to radiant. |
#rad(45)# |
|
rgb |
Converts 0-255 values to 0-1 normalized space. |
#rgb(126)# |
|
round |
Returns the round of the value (first parameter) with a specific number of digits (second parameter) after the decimal point. |
#round(3.1415,2) |
|
sign |
Return the sign of the argument: 1 if it is positive, 0 if it is zero or -1 if it is negative. |
#sign(3.1415)# |
|
sin |
Returns the sine of the argument. |
#sin(0)# |
|
sinh |
Return the hyperbolic sine of the argument. |
#sinh(0)# |
|
sqrt |
Returns the square root. |
#sqrt(2)# |
|
tan |
Returns the tangent of the argument. |
#tan(1.507)# |
|
tanh |
Return the hyperbolic tangent of the argument. |
#tanh(1.507)# |