From 58436fc0223728826cb31e6a1e9d4bb9c5ed37df Mon Sep 17 00:00:00 2001 From: BisUmTo <31419791+BisUmTo@users.noreply.github.com> Date: Tue, 13 Apr 2021 13:55:58 +0200 Subject: [PATCH 1/2] More datapack examples (#805) * Update Auxiliary.md * Fixed players() TYPO --- docs/scarpet/api/Auxiliary.md | 64 ++++++++++++++++++- docs/scarpet/api/BlocksAndWorldAccess.md | 6 +- .../language/LoopsAndHigherOrderFunctions.md | 2 +- docs/scarpet/language/Operators.md | 2 +- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/docs/scarpet/api/Auxiliary.md b/docs/scarpet/api/Auxiliary.md index 0b4fad16..363616f1 100644 --- a/docs/scarpet/api/Auxiliary.md +++ b/docs/scarpet/api/Auxiliary.md @@ -442,7 +442,10 @@ script run create_datapack('foo', } } }) + +Custom dimension example: +
 script run create_datapack('funky_world',  {
     'data' -> {
         'minecraft' -> {
@@ -465,7 +468,66 @@ script run create_datapack('funky_world',  {
     }
 });
 check_hidden_dimensions();  => ['funky_world']
-        
+
+ +Loot table example: +
+script run create_datapack('silverfishes_drop_gravel', {
+    'data' -> {
+        'minecraft' -> {
+            'loot_tables' -> {
+                'entities' -> {
+                    'silverfish.json' -> {
+                        'type' -> 'minecraft:entity',
+                        'pools' -> [
+                            {
+                                'rolls' -> {
+                                    'min' -> 0,
+                                    'max' -> 1
+                                },
+                                'entries' -> [
+                                    {
+                                        'type' -> 'minecraft:item',
+                                        'name' -> 'minecraft:gravel'
+                                    }
+                                ]
+                            }
+                        ]
+                    }
+                }
+            }
+        }
+    }
+});
+
+ +Recipe example: +
+script run create_datapack('craftable_cobwebs', {
+    'data' -> {
+        'scarpet' -> {
+            'recipes' -> {
+                'cobweb.json' -> {
+                    'type' -> 'crafting_shaped',
+                    'pattern' -> [
+                        'SSS',
+                        'SSS',
+                        'SSS'
+                    ],
+                    'key' -> {
+                        'S' -> {
+                            'item' -> 'minecraft:string'
+                        }
+                    },
+                    'result' -> {
+                        'item' -> 'minecraft:cobweb',
+                        'count' -> 1
+                    }
+                }
+            }
+        }
+    }
+});
 
### `enable_hidden_dimensions()` diff --git a/docs/scarpet/api/BlocksAndWorldAccess.md b/docs/scarpet/api/BlocksAndWorldAccess.md index 4d4529f8..b9bdb9b6 100644 --- a/docs/scarpet/api/BlocksAndWorldAccess.md +++ b/docs/scarpet/api/BlocksAndWorldAccess.md @@ -59,7 +59,7 @@ set(0,5,0,'bedrock') => bedrock set(l(0,5,0), 'bedrock') => bedrock set(block(0,5,0), 'bedrock') => bedrock scan(0,5,0,0,0,0,set(_,'bedrock')) => 1 -set(pos(players()), 'bedrock') => bedrock +set(pos(player()), 'bedrock') => bedrock set(0,0,0,'bedrock') => 0 // or 1 in overworlds generated in 1.8 and before scan(0,100,0,20,20,20,set(_,'glass')) // filling the area with glass @@ -255,7 +255,7 @@ and the same can be achieved with `query(entity,'pos')`, but for simplicity `pos
 pos(block(0,5,0)) => l(0,5,0)
-pos(players()) => l(12.3, 45.6, 32.05)
+pos(player()) => l(12.3, 45.6, 32.05)
 pos(block('stone')) => Error: Cannot fetch position of an unrealized block
 
@@ -505,7 +505,7 @@ To check if a block is truly loaded, I mean in memory, use `generation_status(x) outside of the playable area, just are not used by any of the game mechanic processes.
-loaded(pos(players()))  => 1
+loaded(pos(player()))  => 1
 loaded(100000,100,1000000)  => 0
 
diff --git a/docs/scarpet/language/LoopsAndHigherOrderFunctions.md b/docs/scarpet/language/LoopsAndHigherOrderFunctions.md index 95d018ed..33d52fa1 100644 --- a/docs/scarpet/language/LoopsAndHigherOrderFunctions.md +++ b/docs/scarpet/language/LoopsAndHigherOrderFunctions.md @@ -92,7 +92,7 @@ place of the resulting map element, otherwise current element is skipped.
 map(range(10), _*_)  => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
-map(players('*'), _+' is stoopid') [gnembon is stoopid, herobrine is stoopid]
+map(player('*'), _+' is stoopid') [gnembon is stoopid, herobrine is stoopid]
 
### `filter(list,expr(_,_i))` diff --git a/docs/scarpet/language/Operators.md b/docs/scarpet/language/Operators.md index 4780124d..0024c4c1 100644 --- a/docs/scarpet/language/Operators.md +++ b/docs/scarpet/language/Operators.md @@ -114,7 +114,7 @@ $ ) $ ); $ lvl $); -/script run global_get_enchantment(players(), 'sharpness') +/script run global_get_enchantment(player(), 'sharpness') ### `Basic Arithmetic Operators + - * /` From 51db8510963d123010440c540d1c220827c5ba37 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 13 Apr 2021 09:03:24 -0300 Subject: [PATCH 2/2] docs --- docs/scarpet/api/Auxiliary.md | 123 ++++++++++++++-------------------- 1 file changed, 50 insertions(+), 73 deletions(-) diff --git a/docs/scarpet/api/Auxiliary.md b/docs/scarpet/api/Auxiliary.md index 363616f1..0d3c2827 100644 --- a/docs/scarpet/api/Auxiliary.md +++ b/docs/scarpet/api/Auxiliary.md @@ -432,40 +432,31 @@ Synopsis:
 script run create_datapack('foo', 
 {
-    'foo' -> {
-        'bar.json' -> {
-            'c' -> true,
-            'd' -> false,
-            'e' -> {'foo' -> [1,2,3]},
-            'a' -> 'foobar',
-            'b' -> 5
-        }
-    }
+    'foo' -> { 'bar.json' -> {
+        'c' -> true,
+        'd' -> false,
+        'e' -> {'foo' -> [1,2,3]},
+        'a' -> 'foobar',
+        'b' -> 5
+    } }
 })
 
Custom dimension example:
 script run create_datapack('funky_world',  {
-    'data' -> {
-        'minecraft' -> {
-            'dimension' -> {
-                'custom_ow.json' -> { 
-                    'type' -> 'minecraft:the_end',
-                    'generator' -> {
-                        'biome_source' -> {
-                             'seed' -> 0,
-                             'large_biomes' -> false,
-                             'type' -> 'minecraft:vanilla_layered'
-                        },
-                        'seed' -> 0,
-                        'settings' -> 'minecraft:nether',
-                        'type' -> 'minecraft:noise'
-                    }
-                }
-            }
-        }
-    }
+    'data' -> { 'minecraft' -> { 'dimension' -> { 'custom_ow.json' -> { 
+        'type' -> 'minecraft:the_end',
+        'generator' -> {
+            'biome_source' -> {
+                 'seed' -> 0,
+                 'large_biomes' -> false,
+                 'type' -> 'minecraft:vanilla_layered'
+            },
+            'seed' -> 0,
+            'settings' -> 'minecraft:nether',
+            'type' -> 'minecraft:noise'
+    } } } } }
 });
 check_hidden_dimensions();  => ['funky_world']
 
@@ -473,60 +464,46 @@ check_hidden_dimensions(); => ['funky_world'] Loot table example:
 script run create_datapack('silverfishes_drop_gravel', {
-    'data' -> {
-        'minecraft' -> {
-            'loot_tables' -> {
-                'entities' -> {
-                    'silverfish.json' -> {
-                        'type' -> 'minecraft:entity',
-                        'pools' -> [
-                            {
-                                'rolls' -> {
-                                    'min' -> 0,
-                                    'max' -> 1
-                                },
-                                'entries' -> [
-                                    {
-                                        'type' -> 'minecraft:item',
-                                        'name' -> 'minecraft:gravel'
-                                    }
-                                ]
-                            }
-                        ]
+    'data' -> { 'minecraft' -> { 'loot_tables' -> { 'entities' -> { 'silverfish.json' -> {
+        'type' -> 'minecraft:entity',
+        'pools' -> [
+            {
+                'rolls' -> {
+                    'min' -> 0,
+                    'max' -> 1
+                },
+                'entries' -> [
+                    {
+                        'type' -> 'minecraft:item',
+                        'name' -> 'minecraft:gravel'
                     }
-                }
+                ]
             }
-        }
-    }
+        ]
+    } } } } }
 });
 
Recipe example:
 script run create_datapack('craftable_cobwebs', {
-    'data' -> {
-        'scarpet' -> {
-            'recipes' -> {
-                'cobweb.json' -> {
-                    'type' -> 'crafting_shaped',
-                    'pattern' -> [
-                        'SSS',
-                        'SSS',
-                        'SSS'
-                    ],
-                    'key' -> {
-                        'S' -> {
-                            'item' -> 'minecraft:string'
-                        }
-                    },
-                    'result' -> {
-                        'item' -> 'minecraft:cobweb',
-                        'count' -> 1
-                    }
-                }
+    'data' -> { 'scarpet' -> { 'recipes' -> { 'cobweb.json' -> {
+        'type' -> 'crafting_shaped',
+        'pattern' -> [
+            'SSS',
+            'SSS',
+            'SSS'
+        ],
+        'key' -> {
+            'S' -> {
+                'item' -> 'minecraft:string'
             }
+        },
+        'result' -> {
+            'item' -> 'minecraft:cobweb',
+            'count' -> 1
         }
-    }
+    } } } }
 });
 
@@ -534,7 +511,7 @@ script run create_datapack('craftable_cobwebs', { The function reads current datapack settings detecting new dimensions defined by these datapacks that have not yet been added to the list of current dimensions and adds them so that they can be used and accessed right away. It doesn't matter how the -datapacks have been added to the game, either with 'create_datapack()' or manually by dropping a datapack file and calling +datapacks have been added to the game, either with `create_datapack()` or manually by dropping a datapack file and calling `/datapack enable` on it. Returns the list of valid dimension names / identifiers that has been added in the process. Fine print: The function should be