vault backup: 2025-03-24 20:33:23
All checks were successful
Update pages on webserver / Update (push) Successful in 6s

This commit is contained in:
themodernhakr 2025-03-24 20:33:23 -05:00
parent 1806d44ce3
commit 503c2481f3
2 changed files with 12 additions and 11 deletions

View File

@ -13,12 +13,12 @@
"state": {
"type": "markdown",
"state": {
"file": "Minecraft Server Administration/Tips for Minecraft Server Administration.md",
"mode": "preview",
"file": "Minecraft Datapacking/When Two Macros are Faster than One.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "Tips for Minecraft Server Administration"
"title": "When Two Macros are Faster than One"
}
}
]
@ -181,8 +181,8 @@
},
"active": "246e3fe4155bbefd",
"lastOpenFiles": [
"Minecraft Server Administration/index.md",
"Minecraft Server Administration/Tips for Minecraft Server Administration.md",
"Minecraft Server Administration/index.md",
"Minecraft Datapacking/When Two Macros are Faster than One.md",
"Minecraft Datapacking/Arrays",
"Minecraft Datapacking",

View File

@ -5,6 +5,11 @@ draft: "false"
While working on my Database datapack (still WIP), I knew I'd want to find
# One Macro
Macros allow us to reach into our array and pick out an entry that matching value in the `string` property.
```ts
... one_macro.array[string:$(keyword)]
```
```ts
// one_macro/run.mcfunction
@ -13,17 +18,15 @@ data modify storage test_namespace:test_namespace temp.keyword set value 'entry5
function test_namespace:one_macro/_searcharray with storage test_namespace:test_namespace temp
data remove storage test_namespace:test_namespace temp.keyword
data remove storage test_namespace:test_namespace temp.result
```
```ts
// one_macro/_searcharray.mcfunction
$data modify storage test_namespace:test_namespace temp.result set from storage`` test_namespace:test_namespace database.test.arrayTest3.array[string:$(keyword)]
$data modify storage test_namespace:test_namespace temp.result set from storage test_namespace:test_namespace one_macro.array[string:$(keyword)]
```
# Two Macro
```ts
// two_macro/run.mcfunction
@ -34,20 +37,18 @@ function test_namespace:two_macro/_searchindex with storage test_namespace:test_
function test_namespace:two_macro/_searcharray with storage test_namespace:test_namespace temp
data remove storage test_namespace:test_namespace temp.keyword
data remove storage test_namespace:test_namespace temp.index
data remove storage test_namespace:test_namespace temp.result
```
```ts
// two_macro/_searchindex.mcfunction
$data modify storage test_namespace:test_namespace temp.index set from storage test_namespace:test_namespace database.test.arrayTest2.index.$(keyword)
$data modify storage test_namespace:test_namespace temp.index set from storage test_namespace:test_namespace two_macro.index.$(keyword)
```
```ts
// two_macro/_searcharray.mcfunction
$data modify storage test_namespace:test_namespace temp.result set from storage test_namespace:test_namespace database.test.arrayTest2.array[$(index)]
$data modify storage test_namespace:test_namespace temp.result set from storage test_namespace:test_namespace two_macro.array[$(index)]
```