diff --git a/src/content/docs/de/reference/cli.md b/src/content/docs/de/reference/cli.md index e71ac97..8c7aa9e 100644 --- a/src/content/docs/de/reference/cli.md +++ b/src/content/docs/de/reference/cli.md @@ -33,5 +33,5 @@ shulkerscript build [PATH] ## package Baut und verpackt das Projekt im angegebenen Pfad in eine `.zip`-Datei. ```bash -shulkerscript package [PATH] +shulkerscript build --zip [PATH] ``` \ No newline at end of file diff --git a/src/content/docs/guides/getting-started.mdx b/src/content/docs/guides/getting-started.mdx index a81d88d..2fa9857 100644 --- a/src/content/docs/guides/getting-started.mdx +++ b/src/content/docs/guides/getting-started.mdx @@ -97,7 +97,7 @@ Only functions annotated with `#[tick]`, `#[load]`, `#[deobfuscate]` or called f 1. Navigate into the project directory. 2. Run ```bash - shulkerscript package + shulkerscript build --zip ``` This will create a ZIP archive containing the compiled project. 3. You can now distribute the archive to your users. diff --git a/src/content/docs/guides/syntax.md b/src/content/docs/guides/syntax.md index 19ef4a9..3bcdf85 100644 --- a/src/content/docs/guides/syntax.md +++ b/src/content/docs/guides/syntax.md @@ -111,6 +111,41 @@ Multiple functions can be imported by separating them with a comma. from "./foo" import bar, baz; ``` +## Tags +In Minecraft, tags are used to group multiple items, blocks, entities, etc. together. +In ShulkerScript, tags can be defined right in the code, where they are needed. +```shulkerscript +tag "foo" of "block" [ + "minecraft:stone", + "minecraft:dirt" +] +``` + +This will result in a tag of type `block` with the name `foo` containing the blocks `minecraft:stone` and `minecraft:dirt`. + +If you want the tag to replace, instead of append to the existing tag, you can use the `replace` keyword. +```shulkerscript +tag "foo" of "block" replace [ + "minecraft:stone", + "minecraft:dirt" +] +``` + +The type has to be the name of the subfolder in the `tags` folder of the data pack. Most often you will use tags with +the types: +- `function` +- `block` +- `item` +- `entity_type` +- `fluid` +- `game_event` + +But you can also use custom types, refer to [this page](https://minecraft.wiki/w/Tag) for more information. + +:::tip +`of "[type]"` can be omitted and will default to `"function"`. +::: + ## Conditional Statements Conditional statements are used to execute code based on a condition. They start with `if` followed by a condition in parenthesis and a block of code. diff --git a/src/content/docs/roadmap.mdx b/src/content/docs/roadmap.mdx index 123207b..806bd41 100644 --- a/src/content/docs/roadmap.mdx +++ b/src/content/docs/roadmap.mdx @@ -20,13 +20,11 @@ import { Steps } from '@astrojs/starlight/components'; ```shulkerscript from "path/to/file.shu" import *; ``` -2. **Better Error Reports**\ - Improve the error reports to be more helpful and easier to understand. -3. **Tag support**\ - Add a way to define tags in the project and use them in the code. - This will eliminate the need for providing tags in the asset directory. -4. **Variables & Constants**\ +2. **Variables & Constants**\ Add support for variables and constants. Constants can be any type (string, number, etc.) and can be passed from function to function. They will be processed by the compiler. Variables will be mutable and can be changed at any time, and are stored as entries in minecraft scoreboards. +3. **Your Ideas**\ + Do you have an idea for a feature that should be added to ShulkerScript? + Let us know by opening an issue on GitHub or writing a mail! Links can be found in the upper right corner of the page. \ No newline at end of file diff --git a/src/utils/shulkerscript-grammar.ts b/src/utils/shulkerscript-grammar.ts index 409a7d8..0577a3a 100644 --- a/src/utils/shulkerscript-grammar.ts +++ b/src/utils/shulkerscript-grammar.ts @@ -21,11 +21,14 @@ export const shulkerscriptGrammar: LanguageInput = { }, { include: "#importStatement", - } + }, + { + include: "#tagDeclaration", + }, ], repository: { - "$base": {}, - "$self": {}, + $base: {}, + $self: {}, // Groupings functionContents: { patterns: [ @@ -67,7 +70,7 @@ export const shulkerscriptGrammar: LanguageInput = { end: "}", captures: { 1: { - name: "keyword.control.public.shulkerscript" + name: "keyword.control.public.shulkerscript", }, 2: { name: "keyword.control.function.shulkerscript", @@ -99,7 +102,29 @@ export const shulkerscriptGrammar: LanguageInput = { 1: { name: "entity.name.function.shulkerscript", }, - } + }, + }, + tagDeclaration: { + begin: '^\\s*(tag)\\s+("\\w+")\\s+(?:(of)\\s+("\\w+")\\s+)?(?:(replace)\\s+)?\\[', + end: "]", + patterns: [{ include: "#stringLiteral" }], + captures: { + 1: { + name: "keyword.control.tag.shulkerscript", + }, + 2: { + name: "string.quoted.double.shulkerscript", + }, + 3: { + name: "keyword.control.of.shulkerscript", + }, + 4: { + name: "string.quoted.double.shulkerscript", + }, + 5: { + name: "keyword.control.replace.shulkerscript", + }, + }, }, binaryOperator: { name: "punctuation.operator.binary.shulkerscript", @@ -171,10 +196,10 @@ export const shulkerscriptGrammar: LanguageInput = { end: "import\\s(\\w+(?:\\s?,\\s?(?:\\w+))*)\\s?,?\\s?", captures: { 1: { - name: "entity.name.function.shulkerscript" + name: "entity.name.function.shulkerscript", }, }, - patterns: [{ include: "#stringLiteral" }] - } + patterns: [{ include: "#stringLiteral" }], + }, }, -}; \ No newline at end of file +};