Class MolangExpr
java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.armature.molang.MolangExpr
A compiled Molang expression or script, the language Bedrock and Blockbench write animation values in. Keyframes,
anim_time_update, blend_weight and timeline instructions are all read as these, and mods can compile
their own.
MolangExpr bob = MolangExpr.parse("math.sin(q.anim_time * 360) * 2");
double value = bob.eval(context);
MolangExpr.parse("v.charge = math.min(v.charge + q.delta_time, 1); return v.charge;");
What is understood: numbers, + - * /, comparisons, && || !, ?: and ??, parentheses,
math.* (trigonometry in degrees, as in Bedrock), query./q. values from ArmatureQueries,
variable./v. and temp./t. variables, assignments, return, and several
statements split by ;. Names are not case sensitive. Anything else fails to parse.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA piece of a compiled expression. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic MolangExprconstant(double value) An expression that is always this number.doubleThe value of a constant expression; 0 for any other.doubleeval(ArmatureContext context) The value in this context.floatevalFloat(ArmatureContext context) booleanWhether the value never changes, so it can be read once without a context.static MolangExprof(MolangExpr.Node node, String source) Wraps a node the parser built.static MolangExprCompiles Molang source.source()toString()
-
Field Details
-
ZERO
-
ONE
-
-
Method Details
-
constant
An expression that is always this number. -
parse
Compiles Molang source. A plain number gives a constant.- Throws:
IllegalArgumentException- if the source can't be read; the message says where
-
of
Wraps a node the parser built. -
eval
The value in this context. Never throws: a broken query or division by zero gives 0 or infinity, not an error. -
evalFloat
-
isConstant
public boolean isConstant()Whether the value never changes, so it can be read once without a context. -
constantValue
public double constantValue()The value of a constant expression; 0 for any other. -
source
-
toString
-