Editing Expressions
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
You can use expressions as input parameter to reduce the amount of logic entities used. Expressions in input parameter start with $$= | You can use expressions as input parameter to reduce the amount of logic entities used. Expressions in input parameter start with $$= | ||
For example, using this as input parameter: $$='Health: ('..!activator.m_iHealth..'/'..!activator.m_iMaxHealth..')' will set health information as input parameter | For example, using this as input parameter: $$='Health: ('..!activator.m_iHealth..'/'..!activator.m_iMaxHealth..')' will set health information as input parameter | ||
Expressions are calculated during input execution. | Expressions are calculated during input execution . | ||
Do not put double quote | Do not put double quote " inside expression, but you are allowed to use comma , . | ||
== Syntax == | == Syntax == | ||
Line 29: | Line 27: | ||
|- | |- | ||
|entityname.variable | |entityname.variable | ||
|access entity | |access entity sendprop, datamap, or custom variable | ||
|!activator.m_iHealth + 41 | |!activator.m_iHealth + 41 | ||
|- | |- | ||
Line 42: | Line 40: | ||
|> >= < <= == != | |> >= < <= == != | ||
|comparison operators | |comparison operators | ||
| | |7 > 3 | ||
|- | |- | ||
|() | |() | ||
Line 62: | Line 60: | ||
|>> << | |>> << | ||
|right bit shift, left bit shift | |right bit shift, left bit shift | ||
| | | | ||
|} | |} | ||
Values are automatically converted when types of left and right sides of operators differ. | Values are automatically converted when types of left and right sides of operators differ. | ||
For example, [1 4 5] + 4 will automatically convert 4 to [4 4 4] vector | For example, [1 4 5] + 4 will automatically convert 4 to [4 4 4] vector | ||
== Functions == | |||
=== Logic === | === Logic === | ||
<syntaxhighlight> | <syntaxhighlight> | ||
test( test expression, if true, if false ) | test( test expression, if true, if false ) | ||
?( test expression, if true, if false ) | ?( test expression, if true, if false ) | ||
exists( value ) | exists( value ) | ||
min( value 1, value 2 ) | min( value 1, value 2 ) | ||
max( value 1, value 2 ) | max( value 1, value 2 ) | ||
length( vector ) | |||
distance( vector 1, vector 2 ) | |||
dotproduct( vector 1, vector 2 ) | |||
crossproduct( vector 1, vector 2 ) | |||
rotate( input vector, rotation angles ) | |||
normalize( vector ) | |||
toangles( vector ) | |||
toforwardvector( vector ) | |||
clamp( input value, minimum value, maximum value ) | clamp( input value, minimum value, maximum value ) | ||
remap( input value, from min, from max, to min, to max ) | remap( input value, from min, from max, to min, to max ) | ||
remapclamped( input value, from min, from max, to min, to max ) | remapclamped( input value, from min, from max, to min, to max ) | ||
int( value ) | |||
float( value ) | |||
string( value ) | |||
stringpad( value, min digits, num digits after decimal point ) | |||
vector( string or X coordinate ) | |||
x( vector ) | |||
y( vector ) | |||
z( vector ) | |||
not( value ) | |||
!( value ) | |||
~( value ) | |||
sqrt( value ) | sqrt( value ) | ||
pow( base, exponent ) | pow( base, exponent ) | ||
Line 126: | Line 103: | ||
randomint( minimum value, maximum value ) | randomint( minimum value, maximum value ) | ||
randomfloat( minimum value, maximum value ) | randomfloat( minimum value, maximum value ) | ||
case( test value, default, case1 ) | |||
sin( angle in radians ) | sin( angle in radians ) | ||
cos( angle in radians ) | cos( angle in radians ) | ||
Line 134: | Line 110: | ||
atan2( x, y ) | atan2( x, y ) | ||
abs( value ) | abs( value ) | ||
playeratindex( index ) | |||
entityindex( entity ) | |||
playeritematslot( entity, slot ) | |||
attribute( player or item, attribute name ) | |||
type( value ) | |||
charat( string, pos ) | charat( string, pos ) | ||
substr( string, pos, length ) | substr( string, pos, length ) | ||
Line 163: | Line 122: | ||
find( haystack, needle ) | find( haystack, needle ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||