Molang is a scripting language in which a developer can interact with minecraft. TranClate has an integrated DSL to help the developer write correct and predictable Queries, Variables and Math operations.
animationController("state") {
animStates {
animState("default") {
transitions {
transition("state") {
Query.markVariant eq Math.random(1, 10)
or
!Query.isBaby
}
}
}
}
}
We now want to discuss in detail how this works:
TranCLate will provide all Queries in the class Query
. To access them type
Query.variant
This will return a Query
object with the Molang
interface. That means the
Query
object on its own is valid for any Molang input like in the animation controller transition:
animationController("state") {
animStates {
animState("default") {
transitions {
// < Molang input >
transition("state") { Query.isOnGround }
}
}
}
}
Note: Make sure to import the correct object (import com.tcreative.devtools.tranclate.addon.molang.Math
)
TranClate will also provide all Math operations for Molang. Access them on the Math
object:
Math.abs(-2)
This will also return a Math
object which has again the Molang interface, so it can also
be used on its own in a Molang input field.
To define Variables, access the Variable
object and call
Variable.new("name_of_the_var", Query.variant)
to use the variables in a Query:
Variable.get("name_of_the_var")
//or
Variable["name_of_the_var"]
- TranClate will read and interpret Molang expressions from left to right unless defined otherwise
Query.variant eq 0 or Query.variant eq 1 and Query.variant eq 2
//is the same as
(Query.variant eq 0 or Query.variant eq 1) and Query.variant eq 2
- Connect Molang expressions with operators like
and
,or
, ...
all possibilities:
KeyWord | Result |
---|---|
and | && |
or | ll |
eq | == |
equals | == |
neq | != |
notEquals | != |
sm | < |
smaller | < |
less | < |
lt | < |
seq | <= |
smallerEquals | <= |
lessEquals | <= |
bg | > |
gt | > |
bigger | > |
beq | >= |
biggerEquals | >= |
greaterEquals | >= |