Skip to content

Commit 1b9cf99

Browse files
authored
Add built in math functions to molang metadata (#116)
* Add another field to molang metadata * Change files
1 parent 9f8d51a commit 1b9cf99

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Add another field to molang metadata",
4+
"packageName": "@minecraft/api-docs-generator",
5+
"email": "rlanda@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

tools/api-docs-generator-test-snapshots/test/molang_module/input/test-molang-module.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
"name": "engine-molang",
33
"minecraft_version": "1.26.0",
44
"module_type": "molang",
5+
"math_functions": [
6+
{
7+
"description" : "Absolute Value 'math.abs'",
8+
"max_args" : 1,
9+
"min_args" : 1,
10+
"name" : "math.abs"
11+
},
12+
{
13+
"description" : "Arc Cosine 'math.acos'",
14+
"max_args" : 1,
15+
"min_args" : 1,
16+
"name" : "math.acos"
17+
}
18+
],
519
"queries": [
620
{
721
"name": "query.is_sneaking",

tools/api-docs-generator/src/modules/MinecraftMolangModule.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ export const MinecraftMolangQueryRecord = Record({
2929
});
3030
export type MinecraftMolangQuery = Static<typeof MinecraftMolangQueryRecord>;
3131

32+
/**
33+
* A built in molang math function
34+
*/
35+
export const MinecraftMolangMathRecord = Record({
36+
name: String,
37+
description: Optional(String),
38+
min_args: Number,
39+
max_args: Optional(Number),
40+
});
41+
export type MinecraftMolangMath = Static<typeof MinecraftMolangMathRecord>;
42+
3243
/**
3344
* Molang module containing queries, variables, and math functions
3445
*/
@@ -39,6 +50,7 @@ export const MinecraftMolangModuleRecord = Intersect(
3950

4051
// Molang query functions (e.g., query.is_sneaking)
4152
queries: Optional(Array(MinecraftMolangQueryRecord)),
53+
math_functions: Optional(Array(MinecraftMolangMathRecord)),
4254
})
4355
);
4456
export type MinecraftMolangModule = Static<typeof MinecraftMolangModuleRecord>;

0 commit comments

Comments
 (0)