minecraft-datapack-language 17.0.10__py3-none-any.whl → 17.0.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- minecraft_datapack_language/_embedded/docs/404.html +42 -0
- minecraft_datapack_language/_embedded/docs/Gemfile +26 -0
- minecraft_datapack_language/_embedded/docs/README.md +84 -0
- minecraft_datapack_language/_embedded/docs/_config.yml +74 -0
- minecraft_datapack_language/_embedded/docs/_data/version.yml +3 -0
- minecraft_datapack_language/_embedded/docs/_docs/cli-reference.md +506 -0
- minecraft_datapack_language/_embedded/docs/_docs/contributing.md +352 -0
- minecraft_datapack_language/_embedded/docs/_docs/docs-hub.md +266 -0
- minecraft_datapack_language/_embedded/docs/_docs/documentation.md +135 -0
- minecraft_datapack_language/_embedded/docs/_docs/examples.md +194 -0
- minecraft_datapack_language/_embedded/docs/_docs/getting-started.md +230 -0
- minecraft_datapack_language/_embedded/docs/_docs/language-reference.md +1637 -0
- minecraft_datapack_language/_embedded/docs/_docs/multi-file-projects.md +221 -0
- minecraft_datapack_language/_embedded/docs/_docs/python-bindings.md +446 -0
- minecraft_datapack_language/_embedded/docs/_docs/vscode-extension.md +381 -0
- minecraft_datapack_language/_embedded/docs/_includes/head-custom.html +983 -0
- minecraft_datapack_language/_embedded/docs/_includes/navigation.html +362 -0
- minecraft_datapack_language/_embedded/docs/_layouts/default.html +27 -0
- minecraft_datapack_language/_embedded/docs/_layouts/page.html +281 -0
- minecraft_datapack_language/_embedded/docs/_plugins/test_version.rb +13 -0
- minecraft_datapack_language/_embedded/docs/_plugins/version_reader.rb +37 -0
- minecraft_datapack_language/_embedded/docs/assets/css/style.css +211 -0
- minecraft_datapack_language/_embedded/docs/docs.md +134 -0
- minecraft_datapack_language/_embedded/docs/downloads.md +444 -0
- minecraft_datapack_language/_embedded/docs/icons/favicon-16.png +0 -0
- minecraft_datapack_language/_embedded/docs/icons/favicon-32.png +0 -0
- minecraft_datapack_language/_embedded/docs/icons/favicon-48.png +0 -0
- minecraft_datapack_language/_embedded/docs/icons/favicon-64.png +0 -0
- minecraft_datapack_language/_embedded/docs/icons/icon-1024.png +0 -0
- minecraft_datapack_language/_embedded/docs/icons/icon-128.png +0 -0
- minecraft_datapack_language/_embedded/docs/icons/icon-256.png +0 -0
- minecraft_datapack_language/_embedded/docs/icons/icon-512.png +0 -0
- minecraft_datapack_language/_embedded/docs/icons/icon-64.png +0 -0
- minecraft_datapack_language/_embedded/docs/index.md +378 -0
- minecraft_datapack_language/_version.py +2 -2
- minecraft_datapack_language/cli.py +5 -1
- {minecraft_datapack_language-17.0.10.dist-info → minecraft_datapack_language-17.0.12.dist-info}/METADATA +1 -1
- minecraft_datapack_language-17.0.12.dist-info/RECORD +56 -0
- minecraft_datapack_language-17.0.10.dist-info/RECORD +0 -22
- {minecraft_datapack_language-17.0.10.dist-info → minecraft_datapack_language-17.0.12.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-17.0.10.dist-info → minecraft_datapack_language-17.0.12.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-17.0.10.dist-info → minecraft_datapack_language-17.0.12.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-17.0.10.dist-info → minecraft_datapack_language-17.0.12.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: Documentation
|
4
|
+
permalink: /docs/documentation/
|
5
|
+
description: Complete documentation for the Minecraft Datapack Language (MDL)
|
6
|
+
---
|
7
|
+
|
8
|
+
Welcome to the complete documentation for the Minecraft Datapack Language (MDL). This guide will help you get started and master all aspects of MDL development.
|
9
|
+
|
10
|
+
## Getting Started
|
11
|
+
|
12
|
+
{% assign getting_started = site.nav | where: "title", "Getting Started" | first %}
|
13
|
+
- **[Getting Started]({{ getting_started.url }})** - Learn the basics of MDL and set up your development environment
|
14
|
+
|
15
|
+
## Core Documentation
|
16
|
+
|
17
|
+
{% assign language_ref = site.nav | where: "title", "Language Reference" | first %}
|
18
|
+
{% assign multi_file = site.nav | where: "title", "Multi-file Projects" | first %}
|
19
|
+
{% assign cli_ref = site.nav | where: "title", "CLI Reference" | first %}
|
20
|
+
{% assign python_api = site.nav | where: "title", "Python Bindings" | first %}
|
21
|
+
|
22
|
+
- **[Language Reference]({{ language_ref.url }})** - Complete syntax and language features
|
23
|
+
- **[Multi-file Projects]({{ multi_file.url }})** - How to organize and structure larger MDL projects
|
24
|
+
- **[CLI Reference]({{ cli_ref.url }})** - Command-line interface usage and options
|
25
|
+
- **[Python Bindings]({{ python_api.url }})** - Programmatic access to MDL functionality
|
26
|
+
|
27
|
+
## Tools and Extensions
|
28
|
+
|
29
|
+
{% assign vscode = site.nav | where: "title", "VS Code Extension" | first %}
|
30
|
+
|
31
|
+
- **[VS Code Extension]({{ vscode.url }})** - Enhanced development experience with syntax highlighting and IntelliSense
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
{% assign contributing = site.nav | where: "title", "Contributing" | first %}
|
36
|
+
|
37
|
+
- **[Contributing]({{ contributing.url }})** - How to contribute to the MDL project
|
38
|
+
|
39
|
+
## Quick Navigation
|
40
|
+
|
41
|
+
<div class="doc-grid">
|
42
|
+
<div class="doc-card">
|
43
|
+
<h3>🚀 Getting Started</h3>
|
44
|
+
<p>New to MDL? Start here to learn the fundamentals and set up your environment.</p>
|
45
|
+
<a href="{{ getting_started.url }}" class="doc-link">Get Started →</a>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<div class="doc-card">
|
49
|
+
<h3>📚 Language Reference</h3>
|
50
|
+
<p>Complete syntax reference, data types, functions, and language features.</p>
|
51
|
+
<a href="{{ language_ref.url }}" class="doc-link">View Reference →</a>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<div class="doc-card">
|
55
|
+
<h3>🔧 CLI Tools</h3>
|
56
|
+
<p>Command-line interface for building, testing, and managing MDL projects.</p>
|
57
|
+
<a href="{{ cli_ref.url }}" class="doc-link">CLI Guide →</a>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div class="doc-card">
|
61
|
+
<h3>📁 Multi-file Projects</h3>
|
62
|
+
<p>Learn how to organize and structure larger, more complex MDL projects.</p>
|
63
|
+
<a href="{{ multi_file.url }}" class="doc-link">Project Structure →</a>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div class="doc-card">
|
67
|
+
<h3>🐍 Python Bindings</h3>
|
68
|
+
<p>Programmatic access to MDL functionality for automation and integration.</p>
|
69
|
+
<a href="{{ python_api.url }}" class="doc-link">API Reference →</a>
|
70
|
+
</div>
|
71
|
+
|
72
|
+
<div class="doc-card">
|
73
|
+
<h3>💻 VS Code Extension</h3>
|
74
|
+
<p>Enhanced development experience with syntax highlighting and IntelliSense.</p>
|
75
|
+
<a href="{{ vscode.url }}" class="doc-link">Extension Guide →</a>
|
76
|
+
</div>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
<style>
|
80
|
+
.doc-grid {
|
81
|
+
display: grid;
|
82
|
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
83
|
+
gap: 1.5rem;
|
84
|
+
margin: 2rem 0;
|
85
|
+
}
|
86
|
+
|
87
|
+
.doc-card {
|
88
|
+
background: #ffffff;
|
89
|
+
border: 1px solid #e1e4e8;
|
90
|
+
border-radius: 8px;
|
91
|
+
padding: 1.5rem;
|
92
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
93
|
+
transition: transform 0.2s, box-shadow 0.2s;
|
94
|
+
}
|
95
|
+
|
96
|
+
.doc-card:hover {
|
97
|
+
transform: translateY(-2px);
|
98
|
+
box-shadow: 0 6px 20px rgba(0,0,0,0.2);
|
99
|
+
}
|
100
|
+
|
101
|
+
.doc-card h3 {
|
102
|
+
margin: 0 0 0.5rem 0;
|
103
|
+
color: #24292e;
|
104
|
+
font-size: 1.1rem;
|
105
|
+
}
|
106
|
+
|
107
|
+
.doc-card p {
|
108
|
+
margin: 0 0 1rem 0;
|
109
|
+
color: #586069;
|
110
|
+
line-height: 1.5;
|
111
|
+
}
|
112
|
+
|
113
|
+
.doc-link {
|
114
|
+
display: inline-block;
|
115
|
+
color: #0366d6;
|
116
|
+
text-decoration: none;
|
117
|
+
font-weight: 500;
|
118
|
+
padding: 0.5rem 1rem;
|
119
|
+
border: 1px solid #0366d6;
|
120
|
+
border-radius: 6px;
|
121
|
+
transition: background-color 0.2s, color 0.2s;
|
122
|
+
}
|
123
|
+
|
124
|
+
.doc-link:hover {
|
125
|
+
background: #0366d6;
|
126
|
+
color: #ffffff;
|
127
|
+
text-decoration: none;
|
128
|
+
}
|
129
|
+
|
130
|
+
@media (max-width: 768px) {
|
131
|
+
.doc-grid {
|
132
|
+
grid-template-columns: 1fr;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
</style>
|
@@ -0,0 +1,194 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: MDL Examples
|
4
|
+
permalink: /docs/examples/
|
5
|
+
---
|
6
|
+
|
7
|
+
This page contains working examples of MDL features.
|
8
|
+
|
9
|
+
## Basic Hello World
|
10
|
+
|
11
|
+
A simple datapack that says hello when loaded:
|
12
|
+
|
13
|
+
```mdl
|
14
|
+
pack "hello" "A simple hello world datapack" 82;
|
15
|
+
namespace "hello";
|
16
|
+
|
17
|
+
function hello:main {
|
18
|
+
say "Hello, Minecraft!";
|
19
|
+
tellraw @a {"text":"Welcome to my datapack!","color":"green"};
|
20
|
+
}
|
21
|
+
|
22
|
+
on_load hello:main;
|
23
|
+
```
|
24
|
+
|
25
|
+
## Logical Operators and Precedence
|
26
|
+
|
27
|
+
```mdl
|
28
|
+
pack "logicalops" "Generated by MDL CLI" 82;
|
29
|
+
namespace "logicalops";
|
30
|
+
|
31
|
+
// Variables (default scope @s)
|
32
|
+
var num a = 0;
|
33
|
+
var num b = 0;
|
34
|
+
|
35
|
+
// Main function
|
36
|
+
function logicalops:main {
|
37
|
+
say "Hello from logicalops!";
|
38
|
+
exec logicalops:add<@a>;
|
39
|
+
}
|
40
|
+
|
41
|
+
function logicalops:init {
|
42
|
+
a = 1;
|
43
|
+
b = 2;
|
44
|
+
}
|
45
|
+
|
46
|
+
function logicalops:add {
|
47
|
+
var result = $a$ + $b$;
|
48
|
+
say "Result: $result$";
|
49
|
+
}
|
50
|
+
|
51
|
+
function logicalops:subtract {
|
52
|
+
var result = $a$ - $b$;
|
53
|
+
say "Result: $result$";
|
54
|
+
}
|
55
|
+
|
56
|
+
function logicalops:multiply {
|
57
|
+
var result = $a$ * $b$;
|
58
|
+
say "Result: $result$";
|
59
|
+
}
|
60
|
+
|
61
|
+
function logicalops:divide {
|
62
|
+
var result = $a$ / $b$;
|
63
|
+
say "Result: $result$";
|
64
|
+
}
|
65
|
+
|
66
|
+
function logicalops:andop {
|
67
|
+
if $a$ > 0 && $b$ > 0 {
|
68
|
+
say "Both are greater than 0";
|
69
|
+
} else {
|
70
|
+
say "At least one is not greater than 0";
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
function logicalops:orop {
|
75
|
+
if $a$ > 0 || $b$ > 0 {
|
76
|
+
say "At least one is greater than 0";
|
77
|
+
} else {
|
78
|
+
say "Both are not greater than 0";
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
function logicalops:notop {
|
83
|
+
if !$a$ > 0 {
|
84
|
+
say "a is not greater than 0";
|
85
|
+
} else {
|
86
|
+
say "a is greater than 0";
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
function logicalops:whileloop {
|
91
|
+
a = 0;
|
92
|
+
while $a$ < 10 {
|
93
|
+
say "a is less than 10";
|
94
|
+
a = $a$ + 1;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
function logicalops:scheduledwhileloop {
|
99
|
+
// the scheduledwhile is just like the while loop, but it is scheduled to run every tick. This is useful for large calculations that would exceed the command recursion limit.
|
100
|
+
a = 0;
|
101
|
+
scheduledwhile $a$ < 10 {
|
102
|
+
say "a is less than 10";
|
103
|
+
a = $a$ + 1;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
function logicalops:complexops {
|
108
|
+
var c = 5;
|
109
|
+
var d = 10;
|
110
|
+
var e = 15;
|
111
|
+
var f = 20;
|
112
|
+
var g = 2;
|
113
|
+
var h = 0;
|
114
|
+
h = $h$ - 1;
|
115
|
+
|
116
|
+
var result = ($c$ + $d$ - $e$ * $f$ / $g$) * $h$;
|
117
|
+
|
118
|
+
if !$result$ == 135 {
|
119
|
+
say "Result is not 135, there is an issue!";
|
120
|
+
} else {
|
121
|
+
say "Result is -135, everything is good!";
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
on_load logicalops:main;
|
126
|
+
```
|
127
|
+
|
128
|
+
<!-- Trimmed non-core examples to focus on core language concepts -->
|
129
|
+
|
130
|
+
## Raw Commands
|
131
|
+
|
132
|
+
Using raw Minecraft commands:
|
133
|
+
|
134
|
+
```mdl
|
135
|
+
pack "raw" "Raw command example" 82;
|
136
|
+
namespace "raw";
|
137
|
+
|
138
|
+
function raw:custom {
|
139
|
+
// Use raw Minecraft commands via single-line raw blocks
|
140
|
+
$!raw effect give @s minecraft:speed 10 1 raw!$
|
141
|
+
$!raw particle minecraft:explosion ~ ~ ~ 1 1 1 0 10 raw!$
|
142
|
+
$!raw playsound minecraft:entity.player.levelup player @s ~ ~ ~ 1 1 raw!$
|
143
|
+
}
|
144
|
+
|
145
|
+
on_load raw:custom;
|
146
|
+
```
|
147
|
+
|
148
|
+
## Function Macros
|
149
|
+
|
150
|
+
Demonstrates macro lines and passing macro data to functions:
|
151
|
+
|
152
|
+
```mdl
|
153
|
+
pack "macros" "Function macro examples" 82;
|
154
|
+
namespace "macros";
|
155
|
+
|
156
|
+
// Target function using a macro line with $(name)
|
157
|
+
function macros:greeter {
|
158
|
+
$say "Hello $(name)"
|
159
|
+
say "Done";
|
160
|
+
}
|
161
|
+
|
162
|
+
// Callers using inline JSON and with-clause
|
163
|
+
function macros:callers {
|
164
|
+
// Inline JSON compound (prefer single quotes outside)
|
165
|
+
exec macros:greeter '{name:"Alex"}';
|
166
|
+
|
167
|
+
// Pull compound from a data source via with-clause
|
168
|
+
exec macros:greeter with storage macros:ctx player.info;
|
169
|
+
}
|
170
|
+
|
171
|
+
on_load macros:callers;
|
172
|
+
```
|
173
|
+
|
174
|
+
## Fan-out Execution Pattern
|
175
|
+
|
176
|
+
Run a function once per matching entity using an outer exec scope, then use default `@s` inside:
|
177
|
+
|
178
|
+
```mdl
|
179
|
+
pack "fanout" "Fan-out example" 82;
|
180
|
+
namespace "fanout";
|
181
|
+
|
182
|
+
var num visits<@s> = 0;
|
183
|
+
|
184
|
+
function fanout:increment {
|
185
|
+
// Runs per-entity; scope defaults to @s inside
|
186
|
+
visits = $visits$ + 1;
|
187
|
+
say "Visits: $visits$";
|
188
|
+
}
|
189
|
+
|
190
|
+
// Fan out to all players on load
|
191
|
+
on_load fanout:increment<@a>;
|
192
|
+
```
|
193
|
+
|
194
|
+
|
@@ -0,0 +1,230 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: Getting Started
|
4
|
+
permalink: /docs/getting-started/
|
5
|
+
---
|
6
|
+
|
7
|
+
MDL (Minecraft Datapack Language) is a simple language that compiles to Minecraft datapack `.mcfunction` files.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install MDL using pipx:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
pipx install minecraft-datapack-language
|
15
|
+
```
|
16
|
+
|
17
|
+
## Quick Start
|
18
|
+
|
19
|
+
Create your first MDL file:
|
20
|
+
|
21
|
+
```mdl
|
22
|
+
// hello.mdl
|
23
|
+
pack "hello" "My first datapack" 82;
|
24
|
+
namespace "hello";
|
25
|
+
|
26
|
+
function hello:main {
|
27
|
+
say "Hello, Minecraft!";
|
28
|
+
tellraw @a {"text":"Welcome to my datapack!","color":"green"};
|
29
|
+
}
|
30
|
+
|
31
|
+
on_load hello:main;
|
32
|
+
```
|
33
|
+
|
34
|
+
Compile it:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
mdl build
|
38
|
+
```
|
39
|
+
|
40
|
+
The compiled datapack will be in the `dist` folder. Copy it to your Minecraft world's `datapacks` folder and run `/reload` in-game.
|
41
|
+
|
42
|
+
## Basic Concepts
|
43
|
+
|
44
|
+
### Variables
|
45
|
+
|
46
|
+
Variables store numbers and can be scoped to different entities. MDL uses an **explicit scope system** where scopes can be specified explicitly, but are optional; when omitted, the scope defaults to `@s` (current entity):
|
47
|
+
|
48
|
+
```mdl
|
49
|
+
// Player-specific variable (default @s)
|
50
|
+
var num playerScore = 0;
|
51
|
+
|
52
|
+
// Server-wide/global variable (singleton armor stand)
|
53
|
+
var num globalCounter<global> = 0;
|
54
|
+
|
55
|
+
// Team-specific variable
|
56
|
+
var num teamScore<@a[team=red]> = 0;
|
57
|
+
|
58
|
+
// Access variables (explicit or default scopes)
|
59
|
+
playerScore = 42; // Defaults to @s
|
60
|
+
globalCounter<global> = 100; // Global scope
|
61
|
+
teamScore<@a[team=red]> = 5; // Team scope
|
62
|
+
```
|
63
|
+
|
64
|
+
### Variable Substitution
|
65
|
+
|
66
|
+
Use `$variable$` or `$variable<scope>$` to read variable values. If the scope is omitted, it defaults to `@s`:
|
67
|
+
|
68
|
+
```mdl
|
69
|
+
say "Your score: $playerScore$";
|
70
|
+
tellraw @a {"text":"Global counter: $globalCounter<global>$","color":"gold"};
|
71
|
+
|
72
|
+
if $playerScore$ > 100 {
|
73
|
+
say "High score!";
|
74
|
+
}
|
75
|
+
```
|
76
|
+
|
77
|
+
### Functions
|
78
|
+
|
79
|
+
Functions contain Minecraft commands:
|
80
|
+
|
81
|
+
```mdl
|
82
|
+
function hello:my_function {
|
83
|
+
say "This is my function!";
|
84
|
+
effect give @s minecraft:speed 10 1;
|
85
|
+
}
|
86
|
+
|
87
|
+
// Call a function
|
88
|
+
exec hello:my_function<@s>;
|
89
|
+
|
90
|
+
// Call a function for all players
|
91
|
+
exec hello:my_function<@a>;
|
92
|
+
```
|
93
|
+
|
94
|
+
### Control Structures
|
95
|
+
|
96
|
+
MDL supports real if/else statements and while loops:
|
97
|
+
|
98
|
+
```mdl
|
99
|
+
// If statement
|
100
|
+
if $playerScore$ > 50 {
|
101
|
+
say "Great job!";
|
102
|
+
} else {
|
103
|
+
say "Keep trying!";
|
104
|
+
}
|
105
|
+
|
106
|
+
// While loop
|
107
|
+
while $counter$ < 5 {
|
108
|
+
say "Counter: $counter$";
|
109
|
+
counter = counter + 1;
|
110
|
+
}
|
111
|
+
```
|
112
|
+
|
113
|
+
### Reading with Explicit Selectors
|
114
|
+
|
115
|
+
You can read variables using explicit selectors in conditions without affecting how they were declared:
|
116
|
+
|
117
|
+
```mdl
|
118
|
+
// Check current player's score
|
119
|
+
if $playerScore<@s>$ > 50 {
|
120
|
+
say "Your score is high!";
|
121
|
+
}
|
122
|
+
|
123
|
+
// Check global counter
|
124
|
+
if $globalCounter<global>$ > 100 {
|
125
|
+
say "Global milestone reached!";
|
126
|
+
}
|
127
|
+
|
128
|
+
// Check another player's score
|
129
|
+
if $playerScore<@p[name=Steve]>$ > 20 {
|
130
|
+
say "Steve has a good score!";
|
131
|
+
}
|
132
|
+
|
133
|
+
// Check team score
|
134
|
+
if $teamScore<@a[team=red]>$ > 50 {
|
135
|
+
say "Red team is winning!";
|
136
|
+
}
|
137
|
+
```
|
138
|
+
|
139
|
+
This allows you to read variables at different selectors without any special linkage to where they were declared.
|
140
|
+
|
141
|
+
### Hooks
|
142
|
+
|
143
|
+
Automatically run functions:
|
144
|
+
|
145
|
+
```mdl
|
146
|
+
on_load hello:init; // Runs when datapack loads
|
147
|
+
on_tick hello:update; // Runs every tick
|
148
|
+
```
|
149
|
+
|
150
|
+
## Complete Example
|
151
|
+
|
152
|
+
Here's a complete example that demonstrates all the basic features:
|
153
|
+
|
154
|
+
```mdl
|
155
|
+
pack "example" "Complete example" 82;
|
156
|
+
namespace "example";
|
157
|
+
|
158
|
+
// Variables
|
159
|
+
var num playerScore = 0; // Defaults to player-specific scope (@s)
|
160
|
+
var num globalTimer<global> = 0;
|
161
|
+
|
162
|
+
// Initialize function
|
163
|
+
function "init" {
|
164
|
+
playerScore = 0;
|
165
|
+
globalTimer<global> = 0;
|
166
|
+
say "Game initialized!";
|
167
|
+
}
|
168
|
+
|
169
|
+
// Update function
|
170
|
+
function "update" {
|
171
|
+
globalTimer<global> = globalTimer<global> + 1;
|
172
|
+
|
173
|
+
if $playerScore$ > 100 {
|
174
|
+
say "High score!";
|
175
|
+
tellraw @a {"text":"Player has a high score!","color":"gold"};
|
176
|
+
}
|
177
|
+
|
178
|
+
if $globalTimer<global>$ >= 1200 { // 60 seconds
|
179
|
+
globalTimer<global> = 0;
|
180
|
+
say "Time's up!";
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
// Score function
|
185
|
+
function "add_score" {
|
186
|
+
playerScore = playerScore + 10;
|
187
|
+
say "Score: $playerScore$";
|
188
|
+
}
|
189
|
+
|
190
|
+
// Hooks
|
191
|
+
on_load example:init;
|
192
|
+
on_tick example:update;
|
193
|
+
```
|
194
|
+
|
195
|
+
## Building and Testing
|
196
|
+
|
197
|
+
### Single File
|
198
|
+
```bash
|
199
|
+
mdl build --mdl myfile.mdl
|
200
|
+
```
|
201
|
+
|
202
|
+
### Build a directory (multiple files)
|
203
|
+
```bash
|
204
|
+
mdl build
|
205
|
+
```
|
206
|
+
|
207
|
+
### Directory (explicit path)
|
208
|
+
```bash
|
209
|
+
mdl build --mdl myproject/
|
210
|
+
```
|
211
|
+
|
212
|
+
### Checking
|
213
|
+
```bash
|
214
|
+
# Check current directory
|
215
|
+
mdl check
|
216
|
+
|
217
|
+
# Check a specific directory
|
218
|
+
mdl check myproject/
|
219
|
+
```
|
220
|
+
|
221
|
+
### Testing
|
222
|
+
1. Copy the `dist` folder to your Minecraft world's `datapacks` folder
|
223
|
+
2. Run `/reload` in-game
|
224
|
+
3. Test your functions with `/function namespace:function_name`
|
225
|
+
|
226
|
+
## Next Steps
|
227
|
+
|
228
|
+
- Read the [Language Reference](https://www.mcmdl.com/docs/language-reference/) for complete syntax
|
229
|
+
- Check out [Examples](https://www.mcmdl.com/docs/examples/) for more complex examples
|
230
|
+
- Learn about [Multi-file Projects](https://www.mcmdl.com/docs/multi-file-projects/) for larger datapacks
|