diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..d0b7dbe --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +onlyBuiltDependencies: + - esbuild + - sharp diff --git a/src/content/docs/guides/syntax.md b/src/content/docs/guides/syntax.md index 7b73991..531062e 100644 --- a/src/content/docs/guides/syntax.md +++ b/src/content/docs/guides/syntax.md @@ -330,6 +330,35 @@ arr[1] = 2; Read more in the [reference](../../reference/variables). +## Loops +!since[0.2.0] + +While loops can be used to execute commands multiple times. +The entire loop takes place within a single game-tick. +For running commands every tick, the `#[tick]` annotation should be used on a function. + +```shulkerscript +while ("entity @p") { + /say @p +} +``` + +Compile-time conditions will be expanded at compile-time into a list of commands without requiring logic in Minecraft. + +```shulkerscript +val x = 0; +while (x < 3) { + run `say $(x)`; + x = x + 1; +} +``` +This will become +```mcfunction +say 0 +say 1 +say 2 +``` + ## Run The `run` keyword is used to evaluate the following expression and include the resulting command in the output. ```shulkerscript @@ -347,4 +376,12 @@ run lua() { -- Lua code goes here return "Hello, Lua!"; }; -``` \ No newline at end of file +``` + +## Member Access +!since[0.2.0] + +Additional properties of values can be accessed via member access (or dot notation). +For example, `.length` gets the length of a string. +Additional information about variable member access can be found in the [variable reference](../../reference/variables). +If you need the actual name of the macro used in a function, you can get it with `.name`. \ No newline at end of file diff --git a/src/content/docs/reference/variables.md b/src/content/docs/reference/variables.md index 7fea365..879e53d 100644 --- a/src/content/docs/reference/variables.md +++ b/src/content/docs/reference/variables.md @@ -26,6 +26,8 @@ int myScore[]; myScore["@p"] = 42; ``` +The scoreboard objective can be accessed with `myInt.objective` and the target/targets with `myInt.target`/`myInts.targets`. + ### Operations You can perform operations on integer variables, such as addition, subtraction, multiplication, and division. @@ -53,4 +55,6 @@ bool manyBools[5] = [true, false, true, false, true]; // Create an entity-boolean map/tag and set the value of the nearest player to true at the same time bool myScore["@p"] = true; -``` \ No newline at end of file +``` + +The tag or storage name can be accessed with `myBool.name` and the storage path with `myBools.path`. diff --git a/src/utils/shulkerscript.tmLanguage.json b/src/utils/shulkerscript.tmLanguage.json index 3507df5..79c3d65 100644 --- a/src/utils/shulkerscript.tmLanguage.json +++ b/src/utils/shulkerscript.tmLanguage.json @@ -51,7 +51,7 @@ "patterns": [ { "name": "keyword.control.flow.shulkerscript", - "match": "\\b(if|else|return|group)\\b" + "match": "\\b(if|else|return|group|while)\\b" } ] }, @@ -184,7 +184,7 @@ "match": "^\\s*(/\\w+)(.*)$", "captures": { "1": { - "name": "keyword.other.commandliteral.shulkerscript" + "name": "entity.name.function.commandliteral.shulkerscript" }, "2": { "name": "string.command.shulkerscript"