Molang文档
版本: 1.16.200.2(正式版)
为什么要创造MoLang?
MoLang is a simple expression-based language designed for fast, data-driven calculation of values at run-time, and with a direct connection to in-game values and systems. Its focus is solely to enable script-like capabilities in high-performance systems where languages such as JavaScript are not performant at scale. We need scripting capabilities in these low-level systems to support end-user modding capabilities, and custom entities, rendering, and animation.
语法结构
The language structure is largely based on simple 'C' language family style syntax. A script is made of either one expression for simple math calculations, or can be made of several statements where more complicated code is required.
In simple cases, the terminating ;
is omitted and the expression result is returned. In complex cases (where there are multiple statements terminated with ;
s, 0.0
is returned unless there is a return
statement, which will exit the current script scope returning the computed value of that return expression (exactly like C).
区分大小写
All things in molang are case-INsensitive, with the exception of strings, which maintain the case provided
关键词
All identifiers not in a scope listed below are reserved for future use
Keyword | Description |
---|---|
1.23 | Numerical constant value |
! && || = > == != | Logical operators |
\* / + - | Basic math operators |
( ) | Parentheses for expression term evaluation control |
{ } | Braces for execution scope |
?? | Null coalescing operator, for handling missing variables or stale actor references |
geometry.texture\_name | A reference to a geometry named in the entity definition |
material.texture\_name | A reference to a material named in the entity definition |
math.function\_name | Various math functions |
query.function\_name | Access to an entity's properties |
temp.variable\_name | Read/write temporary storage |
texture.texture\_name | A reference to a texture named in the entity definition |
variable.variable\_name | Read/write storage on an actor |
?: | Trinary conditional operator |
? | Binary conditional operator |
this | The current value that this script will ultimately write to (context specific) |
return | For complex expressions, this evaluates the following statement and stops execution of the script, returns the value computed |
-> | (EXPERIMENTAL) Arrow operator, for accessing data from a different entity |
context.variable\_name | (EXPERIMENTAL) Read-only storage provided by the game in certain scenarios |
loop | (EXPERIMENTAL) For repeating one or more commands 'n' times |
for\_each | (EXPERIMENTAL) For iterating over an array of entities |
break | (EXPERIMENTAL) For early exiting a loop/for_each scope |
continue | (EXPERIMENTAL) For skipping the rest of the set of statements of a loop/for_each iteration and moving to the next iteration |
\[ \] | Brackets for array access |
变量
There are three variable lifetimes a variable may belong to: Temporary, Entity, and Context:
- Temporary variables (eg: temp.moo = 1;
) are read/write and valid for the scope they are defined in, as per C rules. For performance reasons their lifetime is global to the current script execution and may return a valid value outside of the outermost scope they are defined in for a script. Be careful in complex scripts. We will be adding content errors for invalid accesses as soon as possible.
- Entity variables (eg: variable.moo = 1;
) are read/write and store their value on the entity for the lifetime of that entity. Note that these are currently not saved, so quitting and reloading the world will re-initialize these. In the same way, if the entity is despawned, any variables on the entity will be lost.
- Context variables (eg: context.moo
) are read-only and valid for the script they are run on. The game defines these, and details on what variables are in each will be available in the documentation of the area where that molang script exists (such as behaviours defining what context variables they expose).
值
- All numerical values are floats.
- Boolean values such as actor flags are converted and stored as a float value of either 0.0 or 1.0 for values of false or true respectively.
- For boolean tests, a float value equivalent to 0.0 is false, and anything not equal to 0.0 is true.
- For array indices, floats are C-style-cast to ints, and clamped at zero for negative values or wrapped by the array size for large values.
- Other supported types are:
Geometry
Texture
Material
Actor Reference
Actor Reference Array
String
Struct (see 'structs' section below)
- Errors (such as divide by zero, missing variables, null references, etc) generally return a value of 0.0.
查询函数
Query functions (eg: query.is\_baby
or query.is\_item\_equipped('main\_hand')
) allow scripts to read game data. If a query function takes no arguments, the parentheses are optional. For a full list of query functions, see below.
缩写名
To reduce typing burden and increase clarity when reading and writing molang, the following keyword aliases can make life a bit easier. Note that left and right sides function identically.
Full Name | Aliased Name |
---|---|
context.moo | c.moo |
query.moo | q.moo |
temp.moo | t.moo |
variable.moo | v.moo |
As an example...
math.cos(query.anim_time * 38) * variable.rotation_scale + variable.x * variable.x * query.life_time;
...can also be written as:
math.cos(q.anim_time * 38) * v.rotation_scale + v.x * v.x * q.life_time
Either syntax will work, and can be intermixed as desired. eg:
math.cos(q.anim_time * 38) * variable.rotation_scale + v.x * variable.x * query.life_time
结构
Structures of data, unlike C, are implicitly defined by usage. Their purpose is to more efficiently pass data around, such as passing v.location
rather than v.x
, v.y
, and v.z
. eg:
v.location.x = 1;
v.location.y = 2;
v.location.z = 3;
v.another_mob_set_elsewhere->v.first_mobs_location = v.location;
For some more usage examples, each of the following scripts return 1.23
v.cowcow.friend = v.pigpig; v.pigpig->v.test.a.b.c = 1.23; return v.cowcow.friend->v.test.a.b.c;
v.cowcow.friend = v.pigpig; v.pigpig->v.test.a.b.c = 1.23; v.moo = v.cowcow.friend->v.test; return v.moo.a.b.c;
v.cowcow.friend = v.pigpig; v.pigpig->v.test.a.b.c = 1.23; v.moo = v.cowcow.friend->v.test.a; return v.moo.b.c;
v.cowcow.friend = v.pigpig; v.pigpig->v.test.a.b.c = 1.23; v.moo = v.cowcow.friend->v.test.a.b; return v.moo.c;
v.cowcow.friend = v.pigpig; v.pigpig->v.test.a.b.c = 1.23; v.moo = v.cowcow.friend->v.test.a.b.c; return v.moo;
Note that structures can be arbitrarily deep in their nesting/recursiveness. That said, it is recommended that you don't copy full structures inside other structures to avoid exploding memory, and not making structures too deep as there is a slight performance cost for each layer.
字符串
Strings in molang are surrounded by single - quotes.Eg: 'minecraft:pig' or 'hello world!'.An empty string is defined as two back - to - back single quotes. String operations only support = =
and ! =
at this time.
Note: strings don't support the ' character as there is no support for escape characters at this time.
数学函数
Function | Description |
---|---|
math.abs(value) | Absolute value of value |
math.acos(value) | arccos of value |
math.asin(value) | arcsin of value |
math.atan(value) | arctan of value |
math.atan2(y, x) | arctan of y/x. NOTE: the order of arguments! |
math.ceil(value) | Round value up to nearest integral number |
math.clamp(value, min, max) | Clamp value to between min and max inclusive |
math.cos(value) | Cosine (in degrees) of value |
math.die\_roll(num, low, high) | returns the sum of 'num' random numbers, each with a value from low to high. Note: the generated random numbers are not integers like normal dice. For that, use math.die_roll_integer`. |
math.die\_roll\_integer(num, low, high) | returns the sum of 'num' random integer numbers, each with a value from low to high`. Note: the generated random numbers are integers like normal dice. |
math.exp(value) | Calculates e to the value'th power |
math.floor(value) | Round value down to nearest integral number |
math.hermite\_blend(value) | Useful for simple smooth curve interpolation using one of the Hermite Basis functions: 3t^2 - 2t^3 . Note that while any valid float is a valid input, this function works best in the range [0,1]. |
math.lerp(start, end, 0\_to\_1) | Lerp from start to end via 0_to_1 |
math.lerprotate(start, end, 0\_to\_1) | Lerp the shortest direction around a circle from start degrees to end degrees via 0_to_1 |
math.ln(value) | Natural logarithm of value |
math.max(A, B) | Return highest value of A or B |
math.min(A, B) | Return lowest value of A or B |
math.mod(value, denominator) | Return the remainder of value / denominator |
math.pi | Returns the float representation of the constant pi. |
math.pow(base, exponent) | Elevates base to the exponent 'th power |
math.random(low, high) | Random value between low and high inclusive |
math.random\_integer(low, high) | Random integer value between low and high inclusive |
math.round(value) | Round value to nearest integral number |
math.sin(value) | Sine (in degrees) of value |
math.sqrt(value) | Square root of value |
math.trunc(value) | Round value towards zero |
-> Arrow Operator
Some return values of query function, or values stored in temp/entity/context variables can be a reference to another entity. The ->
operator allows a script to access variables or run queries on that entity. For example, the example below will find all pigs within four metres of the current entity(including itself if it's a pig), and increment a variable v.x
on itself if the block immediately above each pig is flammable(such as an oak button) :
Note that in the case where the left - hand - side of the - >
operator has an error(value is null, the entity was killed previously, or some other issue), the expression will not evaluate the right - hand - side and will return 0. This implementation style was a choice between performance and not requiring content creators to overly worry about checking for potentially bad values everywhere.
"v.x = 0;
for_each(v.pig, query.get_nearby_entities(4, 'minecraft:pig'), {
v.x = v.x + v.pig->query.get_relative_block_state(0, 1, 0, 'flammable');
});"
Public Variables
In general, variables of a mob are considered private to that mob and cannot be accessed by another. To expose read-only access of a variable to other mobs, you need to set the 'public' setting on that variable in the owning entity's resource definition. It is also recommended to default-initialize the variable.
{
"format_version": "1.10.0",
"minecraft:client_entity": {
"description": {
...
"scripts": {
"variables": {
"variable.oink": "public"
},
"initialize": [
"variable.oink = 0;"
],
...
},
...
}
}
}
{ } Brace Scope Delimiters
One can group a series of statements into a single group by wrapping them in { and } symbols. This is used primarily in loops and conditional statements:
(v.moo > 0) ? {
v.x = math.sin(q.life_time * 45);
v.x = v.x * v.x + 17.3;
t.sin_x = math.sin(v.x);
v.x = t.sin_x * t.sin_x + v.x * v.x;
v.x = math.sqrt(v.x) * v.x * math.pi;
}
loop
Sometimes you want to execute an expression multiple times. Rather than copy-pasting it a bunch, you can use loop(count, expression);
. We have placed some arbitrary restrictions on these for safety for now.The maximum loop counter is(as of this document being written) 1024. Also, note that while you can nest loops inside loops pretty much as deep as you want, be careful you don't make a loop so long it will hang your game.
A Fibonacci Calculator
v.x = 1;
v.y = 1;
loop(10, {
t.x = v.x + v.y;
v.x = v.y;
v.y = t.x;
});
for_each
query.get\_nearby\_entities
(see below) returns an array of entities. In order to iterate through them, you can use the following new built-in function for\_each
. It takes three parameters: for\_each(variable, array, expression);
The variable can be any variable, either a temp.
or variable.
, although I'd recommend using temp.
to not pollute the entity's variable space. The expression is any molang expression you want to execute for each entry in the array)
break
This will exit out of a loop
or for\_each
early. Eg:
v.x = 1;
v.y = 1;
loop(10, {t.x = v.x + v.y; v.x = v.y; v.y = t.x; (v.y > 20) ? break;});
This will immediately exit the inner-most active loop, as per C - style language rules. If you have:
v.x = 0;
loop(10, {loop(10, {v.x = v.x + 1; (v.x > 5) ? break;});});
The break
statement will terminate the inner loop when v.x > 5
, and continue processing the outer loop's script. Note that as v.x is not reset between the outer loops, the second time into the inner loop this will add one more to v.x
and then exit the inner loop again, resulting in a final value of v.x
of 6 + 1 + 1 + 1 + ... + 1
= 15
.)
continue
continue
functions as per C-style language rules. Currently only supported in loops, this will skip to the next iteration of the current loop. See break
above for more details on inner/outer loops. The following example will result in v.x becoming 6.0, as the increment will be skipped once it reaches that value. Note that it is better to break out of the loop in this contrived example, as it would be more performant than continuing to perform all 10 iterations.
v.x = 0;
loop(10, {
(v.x > 5) ? continue;
v.x = v.x + 1;
});
?? Null Coalescing Operator
Similar to how the null-coalescing operator works in C#, one can now reference a variable that may or may not exist without seeing a content error. If it doesn't, you can now provide a default value to use. Previously, if a variable didn't exist you would get a content error. This was to make sure variables were always initialized correctly to avoid uninitialized variable bugs. Unfortunately this then required initialize scripts, or in some cases some complex work-arounds to make sure variables were initialized. Now, if you know a variable won't be initialized in the first run of a script, you can use the following:
variable.x = (variable.x ?? 1.2) + 0.3;
This will use the value of variable.x
if it is valid, or else 1.2 if variable.x
:
- has not yet been initialized
- is a reference to a deleted entity
- is an invalid reference
- holds an error
Note that the ??
operator will work with variable.
s, temp.
s, and context.
s that hold numbers or entity references, but not resources such as materials, textures, or geometries (as those must exist and be valid else it's a content error). If the first argument would result in something that can't be resolved, it will return the second argument.
_Reminder: the standing rule of thumb in molang is that if something would error or be a bad value, it is converted to 0.0 (and generally throw a content error on screen in non-publish builds. Note that content errors may prevent uploading content to the marketplace, so please ensure expressions aren't going to do bad things such as dividing by zero)._
Simple vs Complex Expressions[
A simple expression is a single statement, the value of which is returned to the system that evaluated the expression. eg:
math.sin(query.anim_time * 1.23)
A complex expression is one with multiple statements, each ending in a ';'. Each statement is evaluated in order. In the current implementation, the last statement requires the use of the return keyword and defines the resulting value of the expression. eg:
temp.moo = math.sin(query.anim_time * 1.23);
temp.baa = math.cos(query.life_time + 2.0);
return temp.moo * temp.moo + temp.baa;
Note that in a simple expression, ;
is not allowed, whereas in a complex expression, each statement requires a ;
including the last. Also, note that if you don't return
a value from a complex expression, the expression will evaluate to 0.0.
Domain Examples
In the definition file there is a section for pre-computing values. These are executed immediately before animation and render controllers are processed, and stored in the entity. The purpose is to pre-compute any expensive and complex values you may want to reuse in your scripts, long-living index variable updates, or generally any one-off computation per render tick.
"scripts": {
"pre_animation": [
"variable.my_constant = (Math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed;",
"variable.my_constant2 = Math.exp(1.5);",
]
},
动画于与动画控制器
These are numerical operations to control which animations are playing and how to animate bones. "variable.variable_name" and "query.function_name" refer to the entity currently being rendered. They have access to everything in the language except material, texture, and geometry types.
渲染控制器
There are a few different kinds of expressions here, where context implies what is allowed. As with animations, the entity accessors refer to the current entity, however depending on the context one also has access to materials, textures, and geometries. There are two sections in a render controller:
-Array definitions (optional)
-Resource usage (required)
The array definition section allows you to create arrays of resources by resource type if you so desire. These can then be referenced in the resource usage section.
数组表达式
For each of the three resource types (materials, textures, and geometry), you can define an array of resources. The name of the resource is the nice-name from the definition file. Using materials as an example:
"arrays":
{
"materials": {
"array.my_array_1": ["material.a", "material.b", "material.c"],
"array.my_array_2" : ["material.d", "material.e"],
"array.my_array_3" : ["array.my_array_1", "material.my_array_2"],
"array.my_array_4" : ["array.my_array_2", "material.my_array_3"],
"array.my_array_5" : ["array.my_array_1", "material.my_array_1", "material.my_array_4"],
"array.my_array_6" : ["array.my_array_1", "material.f"],
...
},
Note that all elements of an array must be of the same type. eg: a texture array must only contain textures.
An array can reference any combination of zero or more arrays (including duplicates if desired) and/or zero or more materails (again, including duplicates if you like), and you can have as many arrays as you like, each with as many elements as you like. If an array includes arrays in its members, they do not need to be the same length. When indexing into an array in the resource usage section, you use numerical expressions. If the resulting number is negative, it will use zero as the index. Any non - negative index will converted to an integer, and will wrap based on the size of the array:
index = max(0, expression_result) % array_size
资源表达式
A resource expression must return a single resource of a specific type depending on the context.
For example, in the "geometry" section, you must produce an expression that will result in a single geometry. Some examples:
Cycle through an array of geometries at a rate of one per second
"geometry": "array.my_geometries[query.anim_time]"
Pick a geo based on an entity flag
"geometry": "query.is_sheared ? geometry.sheared : geometry.woolly"
Use a specific geometry
"geometry": "geometry.my_geo"
Use specific geo when sleeping, otherwise flip through an array based on a cosine curve, using index zero for almost half the time while the cosine curve is negative
"geometry": "query.is_sleeping ? geometry.my_sleeping_geo : array.my_geos[math.cos(query.anim_time * 12.3 + 41.9) * 10 + 0.6]"
Resource Sections
模型
The geometry section specifies which geometry to use when rendering. As you can specify as many render controllers as you like in the definition file, a single render controller is only concerned with how to render a single geometry. Note that a geometry can be arbitrarily complex using any number of bones and polygons.
材料
The materials section specifies how to map what material to what bone of the geometry. A single material is mapped to a whole bone. Material expressions are evaluated in the order listed. The first part of each statement is the name of the model part to apply the material to, and the second part is the material to use. The model part name can use * for wild - card matching of characters. For example :
"materials": [
{ "*": "Material.default" },
{ "TailA": "array.hair_colors[variable.hair_color]" },
{ "Mane": "array.hair_colors[variable.hair_color]" },
{ "*Saddle*": "variable.is_leather_saddle ? material.leather_saddle : material.iron_saddle" }
],
- This will start by applying Material.default to all model parts.
- Next, it will set the material on a model part named "TailA" to the result of the expression "Array.hairColors[variable.hair_color]". This will look up some previously created variable on the entity named hair_color and use that to index into a material array called "array.hair_colors" defined in this render controller. This will overwrite the Material.default material set in the line above.
- Third, it will look up the same material as the expression is identical, and apply it to the "Mane" model part.
- Lastly, if will find any model part starting with, ending with, or containing "Saddle" (case sensitive) and change its material to either material.leather_saddle or material.iron_saddle depending on the previously set entity variable variable.is_leather_saddle.
查询函数
Query Functions are boolean expressions that allow you to query for values owned by the engine under different circumstances. They can be used in MoLang expressionsUseful for controlling things like changing positions, textures, animations, etc if a mob is a baby. For example:
"position": [ 0.0, "query.is_baby ? -8.0 : 0.0", "query.is_baby ? 4.0 : 0.0" ]
List of Entity Queries
名称 | 描述 |
---|---|
query.all_animations_finished | 仅在动画控制器中有效。如果当前动画控制器状态下的所有动画至少播放了一次,则返回1.0,否则返回0.0。 |
query.anim_time | 返回自当前动画开始以来的时间(以秒为单位),否则返回0.0(如果未在动画中调用) |
query.any_animation_finished | 仅在动画控制器中有效。如果当前动画控制器状态下的任何动画至少播放了一次,则返回1.0,否则返回0.0。 |
query.armor_color_slot | 将装甲插槽索引作为参数,并返回请求的插槽中装甲的颜色 |
query.armor_material_slot | 将装甲插槽索引作为参数,并在请求的装甲插槽中返回装甲材料类型 |
query.armor_texture_slot | 将装甲插槽索引作为参数,并返回所请求插槽的纹理类型 |
query.blocking | 如果实体正在阻止,则返回1.0,否则返回0.0 |
query.body_y_rotation | 如果在actor上调用,则返回身体偏航旋转,否则返回0.0 |
query.can_climb | 如果实体可以爬升,则返回1.0,否则返回0.0 |
query.can_fly | 如果实体可以飞行,则返回1.0,否则返回0.0 |
query.can_power_jump | 如果实体可以跳跃,则返回1.0,否则返回0.0 |
query.can_swim | 如果实体可以游泳则返回1.0,否则返回0.0 |
query.can_walk | 如果实体可以行走,则返回1.0,否则返回0.0 |
query.current_squish_value | 返回当前实体的压缩值,如果没有意义,则返回0.0 |
query.delta_time | 返回自上一帧以来的时间(以秒为单位) |
query.frame_alpha | 返回正在渲染此帧的AI刻度之间的比率(从0到1) |
query.ground_speed | 以米/秒为单位返回实体的地面速度 |
query.has_armor_slot | 将装甲插槽索引作为参数,如果实体在请求的插槽中有装甲,则返回1.0,否则返回0.0 |
query.has_collision | 如果实体启用了碰撞,则返回1.0,否则返回0.0 |
query.has_gravity | 如果实体受重力影响,则返回1.0,否则返回0.0 |
query.has_owner | 如果实体具有所有者ID,则返回true,否则返回false |
query.has_rider | 如果实体有骑手,则返回1.0,否则返回0.0 |
query.has_target | 如果实体具有目标,则返回1.0,否则返回0.0 |
query.head_roll_angle | 返回狼实体头部的侧倾角 |
query.head_x_rotation | 将一个参数作为参数。如果有意义,则返回该实体的第n个头部x旋转,否则返回0.0 |
query.head_y_rotation | 将一个参数作为参数。如果有意义,则返回实体的第n个头y旋转,否则返回0.0 |
query.invulnerable_ticks | 如果有意义的话,返回实体剩余的无痕数,否则返回0.0 |
query.is_angry | 如果实体生气则返回1.0,否则返回0.0 |
query.is_avoiding_mobs | 如果实体逃离暴民则返回1.0,否则返回0.0 |
query.is_baby | 如果实体是婴儿,则返回1.0,否则返回0.0 |
query.is_breathing | 如果实体呼吸,则返回1.0,否则返回0.0 |
query.is_bribed | 如果实体已经贿赂,则返回1.0,否则返回0.0 |
query.is_carrying_block | 如果实体携带一个块,则返回1.0,否则返回0.0 |
query.is_casting | 如果实体正在投射,则返回1.0,否则返回0.0 |
query.is_charged | 如果实体已收费,则返回1.0,否则返回0.0 |
query.is_charging | 如果实体正在收费,则返回1.0,否则返回0.0 |
query.is_chested | 如果实体已连接箱子,则返回1.0,否则返回0.0 |
query.is_critical | 如果实体是关键的,则返回1.0,否则返回0.0 |
query.is_dancing | 如果实体在跳舞,则返回1.0,否则返回0.0 |
query.is_delayed_attacking | 如果实体使用延迟攻击进行攻击,则返回1.0,否则返回0.0 |
query.is_eating | 如果实体正在吃饭,则返回1.0,否则返回0.0 |
query.is_elder | 如果实体是旧版本,则返回1.0,否则返回0.0 |
query.is_enchanted | 如果附魔该实体,则返回1.0,否则返回0.0 |
query.is_fire_immune | 如果该实体不受射击,则返回1.0,否则返回0.0 |
query.is_first_person | 如果实体以第一人称模式渲染,则返回1.0,否则返回0.0 |
query.is_gliding | 如果实体滑动,则返回1.0,否则返回0.0 |
query.is_grazing | 如果实体在放牧,则返回1.0;否则,则返回0.0 |
query.is_idling | 如果实体闲置,则返回1.0,否则返回0.0 |
query.is_ignited | 如果实体被点燃,则返回1.0,否则返回0.0 |
query.is_illager_captain | 如果实体是前卫队长,则返回1.0,否则返回0.0 |
query.is_in_love | 如果实体恋爱,则返回1.0,否则返回0.0 |
query.is_in_water | 如果实体在水中,则返回1.0,否则返回0.0 |
query.is_in_water_or_rain | 如果实体在水或雨中,则返回1.0,否则返回0.0 |
query.is_interested | 如果该实体感兴趣,则返回1.0,否则返回0.0 |
query.is_invisible | 如果实体不可见,则返回1.0,否则返回0.0 |
query.is_jumping | 如果实体在跳跃,则返回1.0,否则返回0.0 |
query.is_laying_down | 如果实体放下则返回1.0,否则返回0.0 |
query.is_laying_egg | 如果实体下蛋,则返回1.0,否则返回0.0 |
query.is_leashed | 如果实体被释放,则返回1.0,否则返回0.0 |
query.is_lingering | 如果实体徘徊,则返回1.0,否则返回0.0 |
query.is_moving | 如果实体正在移动,则返回1.0,否则返回0.0 |
query.is_on_ground | 如果实体在地面上,则返回1.0,否则返回0.0 |
query.is_onfire | 如果实体着火则返回1.0,否则返回0.0 |
query.is_orphaned | 如果该实体是孤立的,则返回1.0,否则返回0.0 |
query.is_powered | 如果实体已通电,则返回1.0,否则返回0.0 |
query.is_pregnant | 如果实体已怀孕,则返回1.0,否则返回0.0 |
query.is_resting | 如果实体处于静止状态,则返回1.0,否则返回0.0 |
query.is_riding | 如果实体在骑行,则返回1.0,否则返回0.0 |
query.is_roaring | 如果实体当前正在咆哮,则返回1.0,否则返回0.0 |
query.is_rolling | 如果实体正在滚动,则返回1.0,否则返回0.0 |
query.is_saddled | 如果实体有鞍,则返回1.0,否则返回0.0 |
query.is_scared | 如果该实体感到害怕,则返回1.0,否则返回0.0 |
query.is_shaking | 如果实体正在投射,则返回1.0,否则返回0.0 |
query.is_shaking_wetness | 如果实体正在甩水,则返回true |
query.is_sheared | 如果实体能够被剪切并被剪切,则返回1.0,否则返回0.0 |
query.is_shield_powered | 如果该实体有意义,则返回1.0f(如果该实体具有活动的有源屏蔽),否则返回0.0 |
query.is_silent | 如果实体为静默则返回1.0,否则返回0.0 |
query.is_sitting | 如果实体坐着,则返回1.0,否则返回0.0 |
query.is_sleeping | 如果实体正在睡眠,则返回1.0,否则返回0.0 |
query.is_sneaking | 如果实体正在潜行,则返回1.0,否则返回0.0 |
query.is_sneezing | 如果实体在打喷嚏,则返回1.0,否则返回0.0 |
query.is_sprinting | 如果实体正在冲刺,则返回1.0,否则返回0.0 |
query.is_stackable | 如果实体是可堆叠的,则返回1.0,否则返回0.0 |
query.is_standing | 如果实体站立,则返回1.0,否则返回0.0 |
query.is_stunned | 如果该实体当前处于眩晕状态,则返回1.0,否则返回0.0 |
query.is_swimming | 如果实体正在游泳,则返回1.0,否则返回0.0 |
query.is_tamed | 如果已驯服实体,则返回1.0,否则返回0.0 |
query.is_transforming | 如果实体正在变换,则返回1.0,否则返回0.0 |
query.is_using_item | 如果实体正在使用项目,则返回1.0,否则返回0.0 |
query.is_wall_climbing | 如果实体正在爬墙,则返回1.0,否则返回0.0 |
query.item_in_use_duration | 以秒为单位返回商品的使用时间(最长持续时间),否则返回0.0。 |
query.item_max_use_duration | 返回该项目可以使用的最长时间,否则返回0.0。 |
query.item_remaining_use_duration | 返回项目剩余可使用的时间(以秒为单位),否则返回0.0。 |
query.key_frame_lerp_time | 返回上一个和下一个关键帧之间的比率 |
query.lie_amount | 返回实体的躺下数量 |
query.life_span | 返回实体的有限寿命,如果实体永久存在,则返回0.0 |
query.life_time | 返回自当前动画开始以来的时间(以秒为单位),否则返回0.0(如果未在动画中调用) |
query.log | 调试日志值 |
query.mark_variant | 返回实体的mark变体 |
query.max_trade_tier | 如果有意义,则返回实体的最大交易层,否则返回0.0 |
query.model_scale | 返回当前实体的比例 |
query.modified_distance_moved | 返回实体在水平方向上移动的总距离(以米为单位)(自从上次加载以来,不一定是最初创建实体以来),该状态由状态标记(例如is_baby或on_fire)修改 |
query.modified_move_speed | 返回由状态标志(例如is_baby或on_fire)修改的实体的当前行走速度 |
query.overlay_alpha | 请勿使用-此功能已弃用,将被删除 |
query.previous_squish_value | 返回当前实体的前一个压缩值,如果没有意义,则返回0.0 |
query.roll_counter | 返回实体的滚动计数器 |
query.shake_angle | 返回狼实体的摇动角度 |
query.sit_amount | 返回实体的当前坐席量 |
query.skin_id | 返回实体的皮肤ID |
query.sneeze_counter | 返回实体的打喷嚏计数器 |
query.spellcolor.b | 如果有意义,则返回当前实体拼写颜色的蓝色通道,否则返回0.0 |
query.spellcolor.g | 如果可行,则返回当前实体拼写颜色的绿色通道,否则返回0.0 |
query.spellcolor.r | 如果有意义,则返回当前实体拼写颜色的红色通道,否则返回0.0 |
query.standing_scale | 返回实体的站立程度 |
query.swell_amount | 返回实体的肿胀程度 |
query.swelling_dir | 如果有意义,则返回实体的膨胀方向,否则返回0.0 |
query.tail_angle | 返回狼实体尾巴的角度,否则返回0.0 |
query.target_x_rotation | 如果有一个,则返回瞄准当前目标的x旋转,否则返回0.0 |
query.target_y_rotation | 如果有一个,则返回瞄准实体当前目标所需的y旋转,否则返回0.0 |
query.time_stamp | 返回级别的当前时间戳 |
query.trade_experience | 返回有意义的实体当前交易经验,否则返回0.0 |
query.trade_tier | 如果有意义,则返回实体的贸易层,否则返回0.0 |
query.unhappy_counter | 返回实体的不满意程度 |
query.variant | 返回实体的变种值 |
query.wing_flap_position | 返回实体的襟翼位置,如果没有意义,则返回0.0 |
query.wing_flap_speed | 返回实体的机翼襟翼速度;如果没有意义,则返回0.0 |
query.yaw_speed | 返回实体的偏航速度 |
实验操作人员
Some operators are under Experimental MoLang Features
atm (see list below). We are hoping people will experiment with them and give us feedback, so we can move them into general usage.
- ContextVariable
- Loop
- ForEach
- Break
- Continue
- Pointer