Events: none
Actions:
1. Set/get global variables (integer only):
Math( "SET", "<Variable>", <Value>
)
Math( "GET", "<Variable>" )
Example:
Math1 = Hook( "KEY", "Ctrl+1", true, false ){
Math( "SET", "Var1", 5 )
}
...
Math2 = Hook( "KEY", "Ctrl+2", true, false ){
v = Math( "GET", "Var1" )
OSD( "Var1=%d", v )
}
2. Return Variable/Constant value
Math( <Value> )
Example:
a = Math( 123 )
b = Math( a )
3. Calculation of any mathematical expression
Math( "<expression>" [, <xValue> [, <yValue>
[, <zValue>]]] )
Place result to @1 as string
Place result (2 decimal places) to @2 as string
Allowable symbols:
+ - plus
- - minus
* - multiplication
/ - division
^ - exponentation
| - bitwise OR
& - bitwise AND
( ) - brackets
1..9 - numbers
. or , - a divider of a fractional part
x,y,z - variables
Functions:
sin()
cos()
tan()
exp()
ln()
log2()
log10()
sqrt()
arctan()
Example:
Math3 = Hook( "KEY", "Ctrl+3", true, false ){
Math( "SET", "Var2", -4 )
z = Math( "GET", "Var2" )
v = Math( "(x^2+cos(y))*z / 3", 3, "3.14", z )
# (3^2+cos(3.14))* (-4) / 3 = -10.666666
OSD( "%d", v ) # Display "-10"
Timer( 2000 )
OSD( @1 ) # Display "-10.666666"
Timer( 2000 )
OSD( @2 ) # Display "-10.67"
}
|
|