minecraft-datapack-language 15.4.20__py3-none-any.whl → 15.4.22__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/_version.py +2 -2
- minecraft_datapack_language/cli_build.py +0 -2
- minecraft_datapack_language/cli_help.py +26 -0
- minecraft_datapack_language/cli_utils.py +1 -5
- {minecraft_datapack_language-15.4.20.dist-info → minecraft_datapack_language-15.4.22.dist-info}/METADATA +85 -1
- {minecraft_datapack_language-15.4.20.dist-info → minecraft_datapack_language-15.4.22.dist-info}/RECORD +10 -10
- {minecraft_datapack_language-15.4.20.dist-info → minecraft_datapack_language-15.4.22.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-15.4.20.dist-info → minecraft_datapack_language-15.4.22.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-15.4.20.dist-info → minecraft_datapack_language-15.4.22.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-15.4.20.dist-info → minecraft_datapack_language-15.4.22.dist-info}/top_level.txt +0 -0
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
28
28
|
commit_id: COMMIT_ID
|
29
29
|
__commit_id__: COMMIT_ID
|
30
30
|
|
31
|
-
__version__ = version = '15.4.
|
32
|
-
__version_tuple__ = version_tuple = (15, 4,
|
31
|
+
__version__ = version = '15.4.22'
|
32
|
+
__version_tuple__ = version_tuple = (15, 4, 22)
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
@@ -401,8 +401,6 @@ def _process_statement(statement: Any, namespace: str, function_name: str, state
|
|
401
401
|
then_body = statement['then_body']
|
402
402
|
else_body = statement.get('else_body', [])
|
403
403
|
|
404
|
-
print(f"DEBUG: If statement condition from AST: {repr(condition)}")
|
405
|
-
|
406
404
|
# Convert condition to Minecraft syntax
|
407
405
|
minecraft_condition = _convert_condition_to_minecraft_syntax(condition, selector, variable_scopes)
|
408
406
|
|
@@ -142,6 +142,32 @@ def show_build_help():
|
|
142
142
|
print(f"5. Build multiple files in a directory:")
|
143
143
|
print(f" {color.code('mdl build --mdl examples/ -o output --verbose')}")
|
144
144
|
print()
|
145
|
+
|
146
|
+
# Advanced Features
|
147
|
+
print_section("Advanced Features")
|
148
|
+
print()
|
149
|
+
print(color.info("MDL supports advanced features including explicit scopes in conditions:"))
|
150
|
+
print()
|
151
|
+
print(f" {color.code('// Variables with different scopes')}")
|
152
|
+
print(f" {color.code('var num playerScore = 0; // Defaults to @s')}")
|
153
|
+
print(f" {color.code('var num globalCounter scope<global> = 0; // Global scope')}")
|
154
|
+
print(f" {color.code('var num teamScore scope<@a[team=red]> = 0; // Team scope')}")
|
155
|
+
print()
|
156
|
+
print(f" {color.code('// Use explicit scopes in conditions')}")
|
157
|
+
print(f" {color.code('if \"$playerScore<@s>$ > 10\" {{')}")
|
158
|
+
print(f" {color.code(' say \"Current player score is high!\";')}")
|
159
|
+
print(f" {color.code('}')}")
|
160
|
+
print()
|
161
|
+
print(f" {color.code('if \"$globalCounter<global>$ > 100\" {{')}")
|
162
|
+
print(f" {color.code(' say \"Global counter reached milestone!\";')}")
|
163
|
+
print(f" {color.code('}')}")
|
164
|
+
print()
|
165
|
+
print(f" {color.code('if \"$teamScore<@a[team=red]>$ > 50\" {{')}")
|
166
|
+
print(f" {color.code(' say \"Red team is winning!\";')}")
|
167
|
+
print(f" {color.code('}')}")
|
168
|
+
print()
|
169
|
+
print(color.info("This allows you to check variables across different scopes without changing their declared scope."))
|
170
|
+
print()
|
145
171
|
|
146
172
|
# Output Structure
|
147
173
|
print_section("Output Structure")
|
@@ -130,19 +130,15 @@ def _convert_condition_to_minecraft_syntax(condition: str, selector: str = "@s",
|
|
130
130
|
# Replace variable references with proper scoreboard syntax
|
131
131
|
def replace_var(match):
|
132
132
|
var_name = match.group(1)
|
133
|
-
print(f"DEBUG: Processing variable in condition: '{var_name}'")
|
134
133
|
# Check if variable has explicit scope selector
|
135
134
|
if '<' in var_name and var_name.endswith('>'):
|
136
135
|
var_parts = var_name.split('<', 1)
|
137
136
|
base_var = var_parts[0]
|
138
137
|
scope_selector = var_parts[1][:-1] # Remove trailing >
|
139
|
-
print(f"DEBUG: Found explicit scope: base_var='{base_var}', scope_selector='{scope_selector}'")
|
140
138
|
# Resolve special selectors
|
141
139
|
if scope_selector == "global":
|
142
140
|
scope_selector = "@e[type=armor_stand,tag=mdl_server,limit=1]"
|
143
|
-
|
144
|
-
print(f"DEBUG: Returning scoped result: '{result}'")
|
145
|
-
return result
|
141
|
+
return f"{scope_selector} {base_var}"
|
146
142
|
else:
|
147
143
|
# Use declared scope if available, otherwise default to current selector
|
148
144
|
if variable_scopes and var_name in variable_scopes:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: minecraft-datapack-language
|
3
|
-
Version: 15.4.
|
3
|
+
Version: 15.4.22
|
4
4
|
Summary: Compile JavaScript-style MDL language or Python API into a Minecraft datapack (1.21+ ready). Features variables, control flow, error handling, and VS Code extension.
|
5
5
|
Project-URL: Homepage, https://www.mcmdl.com
|
6
6
|
Project-URL: Documentation, https://www.mcmdl.com/docs
|
@@ -477,6 +477,90 @@ This will create a datapack with:
|
|
477
477
|
|
478
478
|
---
|
479
479
|
|
480
|
+
## 🎯 **Explicit Scope System**
|
481
|
+
|
482
|
+
MDL features a powerful **explicit scope system** that makes variable access clear and unambiguous. Each variable access must specify its scope, eliminating hidden state and making code more readable.
|
483
|
+
|
484
|
+
### **Variable Declaration Scopes**
|
485
|
+
|
486
|
+
```mdl
|
487
|
+
// Player-specific variable (defaults to @s in execution context)
|
488
|
+
var num playerScore = 0;
|
489
|
+
|
490
|
+
// Server-wide variable (stored on server armor stand)
|
491
|
+
var num globalCounter scope<global> = 0;
|
492
|
+
|
493
|
+
// Team-specific variable
|
494
|
+
var num teamScore scope<@a[team=red]> = 0;
|
495
|
+
|
496
|
+
// Custom entity variable
|
497
|
+
var num entityData scope<@e[type=armor_stand,tag=special,limit=1]> = 0;
|
498
|
+
```
|
499
|
+
|
500
|
+
### **Variable Access with Explicit Scopes**
|
501
|
+
|
502
|
+
```mdl
|
503
|
+
// Each variable access must specify the scope
|
504
|
+
playerScore<@s> = 42; // Player scope
|
505
|
+
globalCounter<global> = 100; // Global scope
|
506
|
+
teamScore<@a[team=red]> = 5; // Team scope
|
507
|
+
entityData<@e[type=armor_stand,tag=special,limit=1]> = 10; // Custom entity
|
508
|
+
```
|
509
|
+
|
510
|
+
### **Explicit Scopes in Conditions**
|
511
|
+
|
512
|
+
**NEW!** MDL now supports explicit scope selectors in if/while conditions, allowing you to override declared variable scopes:
|
513
|
+
|
514
|
+
```mdl
|
515
|
+
function "check_scores" {
|
516
|
+
// Check current player's score
|
517
|
+
if "$playerScore<@s>$ > 10" {
|
518
|
+
say "Your score is high!";
|
519
|
+
}
|
520
|
+
|
521
|
+
// Check global counter
|
522
|
+
if "$globalCounter<global>$ > 100" {
|
523
|
+
say "Global milestone reached!";
|
524
|
+
}
|
525
|
+
|
526
|
+
// Check another player's score
|
527
|
+
if "$playerScore<@p[name=Steve]>$ > 20" {
|
528
|
+
say "Steve has a good score!";
|
529
|
+
}
|
530
|
+
|
531
|
+
// Check team score
|
532
|
+
if "$teamScore<@a[team=red]>$ > 50" {
|
533
|
+
say "Red team is winning!";
|
534
|
+
}
|
535
|
+
|
536
|
+
// Use explicit scopes in while loops too
|
537
|
+
while "$globalCounter<global>$ < 10" {
|
538
|
+
globalCounter<global> = globalCounter<global> + 1;
|
539
|
+
say "Counter: $globalCounter$";
|
540
|
+
}
|
541
|
+
}
|
542
|
+
```
|
543
|
+
|
544
|
+
**Benefits:**
|
545
|
+
- **Override declared scopes**: Use different scopes than what was declared
|
546
|
+
- **Check other entities**: Compare scores across different players/teams
|
547
|
+
- **Flexible conditions**: Mix and match scopes as needed
|
548
|
+
- **Clear intent**: Explicit scope makes code more readable and debuggable
|
549
|
+
|
550
|
+
### **Scope Mapping**
|
551
|
+
|
552
|
+
MDL maps scopes to Minecraft selectors:
|
553
|
+
|
554
|
+
| MDL Scope | Minecraft Selector | Description |
|
555
|
+
|-----------|-------------------|-------------|
|
556
|
+
| `scope<global>` | `@e[type=armor_stand,tag=mdl_server,limit=1]` | Server-wide storage |
|
557
|
+
| `scope<@s>` | `@s` | Current player |
|
558
|
+
| `scope<@a>` | `@a` | All players |
|
559
|
+
| `scope<@a[team=red]>` | `@a[team=red]` | Red team players |
|
560
|
+
| `scope<@e[type=armor_stand,tag=something,limit=1]>` | `@e[type=armor_stand,tag=something,limit=1]` | Custom entity |
|
561
|
+
|
562
|
+
---
|
563
|
+
|
480
564
|
## 🎯 **Advanced Multi-File Examples with Namespaces**
|
481
565
|
|
482
566
|
### **Modern Namespace System**
|
@@ -1,13 +1,13 @@
|
|
1
1
|
minecraft_datapack_language/__init__.py,sha256=i-qCchbe5b2Fshgc6yCU9mddOLs2UBt9SAcLqfUIrT0,606
|
2
|
-
minecraft_datapack_language/_version.py,sha256=
|
2
|
+
minecraft_datapack_language/_version.py,sha256=I5Cwge3f4scENDCmJvK0lfCv7rpZtkezUcsloKsVRQo,708
|
3
3
|
minecraft_datapack_language/ast_nodes.py,sha256=pgjI2Nlap3ixFPgWqGSkqncG9zB91h5BKgRjtcJqMew,2118
|
4
4
|
minecraft_datapack_language/cli.py,sha256=p5A_tEEXugN2NhQFbbgfwi4FxbWYD91RWeKR_A3Vuec,6263
|
5
|
-
minecraft_datapack_language/cli_build.py,sha256=
|
5
|
+
minecraft_datapack_language/cli_build.py,sha256=u0XIOH_zTARPC6dvWf-411OqrF7RjT7Z9Hkp6hTeZsI,47990
|
6
6
|
minecraft_datapack_language/cli_check.py,sha256=bPq9gHsxQ1CIiftkrAtRCifWkVAyjp5c8Oay2NNQ1qs,6277
|
7
7
|
minecraft_datapack_language/cli_colors.py,sha256=Hr8awY966bGSnVdXL3WnmRhSP1wH56vTQKGt5z-kIQM,7878
|
8
|
-
minecraft_datapack_language/cli_help.py,sha256=
|
8
|
+
minecraft_datapack_language/cli_help.py,sha256=Rc-v9E2kctsdN_lMunqdKuZ8EZ8rcZIjBCOPrXLBQeE,21363
|
9
9
|
minecraft_datapack_language/cli_new.py,sha256=_pj5EeXESAG00C80_os9jONIXAMcsu2eoR8xVJWDw6g,9347
|
10
|
-
minecraft_datapack_language/cli_utils.py,sha256=
|
10
|
+
minecraft_datapack_language/cli_utils.py,sha256=qzba7BRHFK9AliSgSLGtxA0p2_Y-Rm20ysDzLLz_KD4,10632
|
11
11
|
minecraft_datapack_language/dir_map.py,sha256=HmxFkuvWGkzHF8o_GFb4BpuMCRc6QMw8UbmcAI8JVdY,1788
|
12
12
|
minecraft_datapack_language/expression_processor.py,sha256=GN6cuRNvgI8TrV6YnEHrA9P0X-ACTT7rCBh4WlOPjSI,20140
|
13
13
|
minecraft_datapack_language/linter.py,sha256=7UqbygC5JPCGg-BSOq65NB2xEJBu_OUOYIIgmHItO2M,16567
|
@@ -17,9 +17,9 @@ minecraft_datapack_language/mdl_linter.py,sha256=z85xoAglENurCh30bR7kEHZ_JeMxcYa
|
|
17
17
|
minecraft_datapack_language/mdl_parser_js.py,sha256=SQzc67pKls3NVnQaT0xIILGqpZYAmcZn78TQ0KIM4TE,40216
|
18
18
|
minecraft_datapack_language/pack.py,sha256=nYiXQ3jgJlDfc4m-65f7C2LFhDRioaUU_XVy6Na4SJI,34625
|
19
19
|
minecraft_datapack_language/utils.py,sha256=Aq0HAGlXqj9BUTEjaEilpvzEW0EtZYYMMwOqG9db6dE,684
|
20
|
-
minecraft_datapack_language-15.4.
|
21
|
-
minecraft_datapack_language-15.4.
|
22
|
-
minecraft_datapack_language-15.4.
|
23
|
-
minecraft_datapack_language-15.4.
|
24
|
-
minecraft_datapack_language-15.4.
|
25
|
-
minecraft_datapack_language-15.4.
|
20
|
+
minecraft_datapack_language-15.4.22.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
21
|
+
minecraft_datapack_language-15.4.22.dist-info/METADATA,sha256=elLshh43YF1-sNZck0fCVtlNNckjMrLWalSD4X4etYE,37917
|
22
|
+
minecraft_datapack_language-15.4.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
minecraft_datapack_language-15.4.22.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
|
24
|
+
minecraft_datapack_language-15.4.22.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
|
25
|
+
minecraft_datapack_language-15.4.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|