Alpha: this compiler is under active development and updates will break your projects. Not recommended for real use yet.
Skip to content

helix / math

Function: math() โ€‹

math(strings, ...holes): MathExpr

Defined in: core/frontend/nodes/math/math.ts:54

Score arithmetic written as a formula, e.g. math`${a} + ${b} * 2`.into(out). It becomes one /compute on 26.3+ and a scoreboard players operation chain below that.

ts
math`-${dot} + min((${distSq} - ${ropeLenSq}) / ${BAUM_DIV}, ${BAUM_MAX})`.into(coef);
math`vec(${i} ยท ${g}, ${j} ยท ${g}, ${k} ยท ${g}) / 100000`.into(local);

Holes are Score, ScoreVec3, numbers or other math expressions.

Everywhere: + - * / %, unary -, min, max, abs, dot, cross, len2, vec. / and % floor like the scoreboard. Vector holes apply per axis.

26.3+ only (throws on older targets): sqrt, sin, cos, pow, avg, round, floor, ceil, len, fractional literals, and ContextInt/ContextFloat providers:

ts
math`round(${ContextFloat.uniform(0, 1)} * ${spread}) + ${base}`.into(out);

These are float and truncate once at the destination, so sqrt(${x}) / 2 halves the real root. Careful: % is truncated on the float side, so -5 % 2 is 1 as int but -1 as float.

Scaled slots (score.scaled(1000)) are read and written as real values, and literals are real too: math\${vel} * 0.995 - 0.049`.into(vel). Same-scale + - min max abs` stays integer; anything else goes through floats and rounds at the destination, so it needs 26.3. Float32 keeps millimetres exact to about 4,000 blocks from 0.

Parameters โ€‹

strings โ€‹

TemplateStringsArray

holes โ€‹

...Operand[]

Returns โ€‹

MathExpr

Released under the MIT License ยท Credits
These docs were written with AI; the layout and every page have been reviewed by a human.