diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index e805859..19e3320 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -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", diff --git a/Minecraft Datapacking/When Two Macros are Faster than One.md b/Minecraft Datapacking/When Two Macros are Faster than One.md index bbe92e5..88ff81c 100644 --- a/Minecraft Datapacking/When Two Macros are Faster than One.md +++ b/Minecraft Datapacking/When Two Macros are Faster than One.md @@ -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)] ``` \ No newline at end of file