redscript-mc 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/.github/workflows/ci.yml +1 -0
  2. package/README.md +119 -313
  3. package/README.zh.md +118 -314
  4. package/ROADMAP.md +5 -5
  5. package/dist/data/impl_test/function/counter/get.mcfunction +5 -0
  6. package/dist/data/impl_test/function/counter/inc.mcfunction +7 -0
  7. package/dist/data/impl_test/function/counter/new.mcfunction +4 -0
  8. package/dist/data/impl_test/function/load.mcfunction +1 -0
  9. package/dist/data/impl_test/function/test_impl.mcfunction +10 -0
  10. package/dist/data/minecraft/tags/function/load.json +5 -0
  11. package/dist/data/playground/function/load.mcfunction +1 -0
  12. package/dist/data/playground/function/start.mcfunction +4 -0
  13. package/dist/data/playground/function/start__say_macro_t1.mcfunction +1 -0
  14. package/dist/data/playground/function/stop.mcfunction +5 -0
  15. package/dist/data/playground/function/stop__say_macro_t0.mcfunction +1 -0
  16. package/dist/data/stdlib_queue8_test/function/__queue_append_apply.mcfunction +4 -0
  17. package/dist/data/stdlib_queue8_test/function/__queue_peek_apply.mcfunction +4 -0
  18. package/dist/data/stdlib_queue8_test/function/__queue_size_raw_apply.mcfunction +4 -0
  19. package/dist/data/stdlib_queue8_test/function/load.mcfunction +1 -0
  20. package/dist/data/stdlib_queue8_test/function/queue_clear.mcfunction +6 -0
  21. package/dist/data/stdlib_queue8_test/function/queue_empty__merge_1.mcfunction +5 -0
  22. package/dist/data/stdlib_queue8_test/function/queue_empty__then_0.mcfunction +5 -0
  23. package/dist/data/stdlib_queue8_test/function/queue_peek__merge_1.mcfunction +13 -0
  24. package/dist/data/stdlib_queue8_test/function/queue_peek__then_0.mcfunction +5 -0
  25. package/dist/data/stdlib_queue8_test/function/queue_pop__merge_1.mcfunction +15 -0
  26. package/dist/data/stdlib_queue8_test/function/queue_pop__then_0.mcfunction +5 -0
  27. package/dist/data/stdlib_queue8_test/function/queue_push__const_11.mcfunction +6 -0
  28. package/dist/data/stdlib_queue8_test/function/queue_push__const_22.mcfunction +6 -0
  29. package/dist/data/stdlib_queue8_test/function/queue_size.mcfunction +13 -0
  30. package/dist/data/stdlib_queue8_test/function/test_queue_push_and_size.mcfunction +13 -0
  31. package/dist/data/test/function/load.mcfunction +1 -0
  32. package/dist/data/test/function/say_at.mcfunction +6 -0
  33. package/dist/data/test/function/test.mcfunction +4 -0
  34. package/dist/pack.mcmeta +6 -0
  35. package/dist/package.json +1 -1
  36. package/dist/src/__tests__/formatter-extra.test.d.ts +7 -0
  37. package/dist/src/__tests__/formatter-extra.test.js +123 -0
  38. package/dist/src/__tests__/global-vars.test.d.ts +13 -0
  39. package/dist/src/__tests__/global-vars.test.js +156 -0
  40. package/dist/src/__tests__/lint/new-rules.test.d.ts +9 -0
  41. package/dist/src/__tests__/lint/new-rules.test.js +402 -0
  42. package/dist/src/__tests__/lsp-rename.test.d.ts +8 -0
  43. package/dist/src/__tests__/lsp-rename.test.js +157 -0
  44. package/dist/src/__tests__/mc-integration/say-fstring.test.d.ts +11 -0
  45. package/dist/src/__tests__/mc-integration/say-fstring.test.js +220 -0
  46. package/dist/src/__tests__/mc-integration/stdlib-coverage-2.test.js +1 -1
  47. package/dist/src/__tests__/mc-integration/stdlib-coverage-3.test.js +1 -1
  48. package/dist/src/__tests__/mc-integration/stdlib-coverage-4.test.js +1 -1
  49. package/dist/src/__tests__/mc-integration/stdlib-coverage-5.test.js +1 -1
  50. package/dist/src/__tests__/mc-integration/stdlib-coverage-6.test.js +1 -1
  51. package/dist/src/__tests__/mc-integration/stdlib-coverage-7.test.js +1 -1
  52. package/dist/src/__tests__/mc-integration/stdlib-coverage-8.test.js +1 -1
  53. package/dist/src/__tests__/mc-syntax.test.js +4 -1
  54. package/dist/src/__tests__/monomorphize-coverage.test.d.ts +9 -0
  55. package/dist/src/__tests__/monomorphize-coverage.test.js +204 -0
  56. package/dist/src/__tests__/optimizer-cse.test.d.ts +7 -0
  57. package/dist/src/__tests__/optimizer-cse.test.js +226 -0
  58. package/dist/src/__tests__/parser.test.js +4 -13
  59. package/dist/src/__tests__/repl-server-extra.test.js +6 -7
  60. package/dist/src/__tests__/repl-server.test.js +5 -7
  61. package/dist/src/__tests__/stdlib/queue.test.js +6 -6
  62. package/dist/src/cli.js +0 -0
  63. package/dist/src/lexer/index.js +2 -1
  64. package/dist/src/lint/index.d.ts +12 -5
  65. package/dist/src/lint/index.js +730 -5
  66. package/dist/src/lsp/main.js +0 -0
  67. package/dist/src/mc-test/client.d.ts +21 -0
  68. package/dist/src/mc-test/client.js +34 -0
  69. package/dist/src/mir/lower.js +108 -6
  70. package/dist/src/optimizer/interprocedural.js +37 -2
  71. package/dist/src/parser/decl-parser.d.ts +19 -0
  72. package/dist/src/parser/decl-parser.js +323 -0
  73. package/dist/src/parser/expr-parser.d.ts +46 -0
  74. package/dist/src/parser/expr-parser.js +759 -0
  75. package/dist/src/parser/index.d.ts +8 -129
  76. package/dist/src/parser/index.js +13 -2262
  77. package/dist/src/parser/stmt-parser.d.ts +28 -0
  78. package/dist/src/parser/stmt-parser.js +577 -0
  79. package/dist/src/parser/type-parser.d.ts +20 -0
  80. package/dist/src/parser/type-parser.js +257 -0
  81. package/dist/src/parser/utils.d.ts +34 -0
  82. package/dist/src/parser/utils.js +141 -0
  83. package/docs/dev/README-mc-integration-tests.md +141 -0
  84. package/docs/lint-rules.md +162 -0
  85. package/docs/stdlib/bigint.md +2 -0
  86. package/editors/vscode/README.md +63 -41
  87. package/editors/vscode/out/extension.js +1881 -1776
  88. package/editors/vscode/out/lsp-server.js +4257 -3651
  89. package/editors/vscode/package-lock.json +3 -3
  90. package/editors/vscode/package.json +1 -1
  91. package/examples/loops-demo.mcrs +87 -0
  92. package/package.json +1 -1
  93. package/redscript-docs/docs/en/stdlib/advanced.md +629 -0
  94. package/redscript-docs/docs/en/stdlib/bigint.md +316 -0
  95. package/redscript-docs/docs/en/stdlib/bits.md +292 -0
  96. package/redscript-docs/docs/en/stdlib/bossbar.md +177 -0
  97. package/redscript-docs/docs/en/stdlib/calculus.md +289 -0
  98. package/redscript-docs/docs/en/stdlib/color.md +353 -0
  99. package/redscript-docs/docs/en/stdlib/combat.md +88 -0
  100. package/redscript-docs/docs/en/stdlib/cooldown.md +82 -0
  101. package/redscript-docs/docs/en/stdlib/dialog.md +155 -0
  102. package/redscript-docs/docs/en/stdlib/easing.md +558 -0
  103. package/redscript-docs/docs/en/stdlib/ecs.md +475 -0
  104. package/redscript-docs/docs/en/stdlib/effects.md +324 -0
  105. package/redscript-docs/docs/en/stdlib/events.md +3 -0
  106. package/redscript-docs/docs/en/stdlib/expr.md +45 -0
  107. package/redscript-docs/docs/en/stdlib/fft.md +141 -0
  108. package/redscript-docs/docs/en/stdlib/geometry.md +430 -0
  109. package/redscript-docs/docs/en/stdlib/graph.md +259 -0
  110. package/redscript-docs/docs/en/stdlib/heap.md +185 -0
  111. package/redscript-docs/docs/en/stdlib/interactions.md +179 -0
  112. package/redscript-docs/docs/en/stdlib/inventory.md +97 -0
  113. package/redscript-docs/docs/en/stdlib/linalg.md +557 -0
  114. package/redscript-docs/docs/en/stdlib/list.md +559 -0
  115. package/redscript-docs/docs/en/stdlib/map.md +140 -0
  116. package/redscript-docs/docs/en/stdlib/math.md +193 -0
  117. package/redscript-docs/docs/en/stdlib/math_hp.md +149 -0
  118. package/redscript-docs/docs/en/stdlib/matrix.md +403 -0
  119. package/redscript-docs/docs/en/stdlib/mobs.md +965 -0
  120. package/redscript-docs/docs/en/stdlib/noise.md +244 -0
  121. package/redscript-docs/docs/en/stdlib/ode.md +253 -0
  122. package/redscript-docs/docs/en/stdlib/parabola.md +342 -0
  123. package/redscript-docs/docs/en/stdlib/particles.md +311 -0
  124. package/redscript-docs/docs/en/stdlib/pathfind.md +255 -0
  125. package/redscript-docs/docs/en/stdlib/physics.md +493 -0
  126. package/redscript-docs/docs/en/stdlib/player.md +78 -0
  127. package/redscript-docs/docs/en/stdlib/quaternion.md +673 -0
  128. package/redscript-docs/docs/en/stdlib/queue.md +134 -0
  129. package/redscript-docs/docs/en/stdlib/random.md +223 -0
  130. package/redscript-docs/docs/en/stdlib/result.md +143 -0
  131. package/redscript-docs/docs/en/stdlib/scheduler.md +183 -0
  132. package/redscript-docs/docs/en/stdlib/set_int.md +190 -0
  133. package/redscript-docs/docs/en/stdlib/sets.md +101 -0
  134. package/redscript-docs/docs/en/stdlib/signal.md +400 -0
  135. package/redscript-docs/docs/en/stdlib/sort.md +104 -0
  136. package/redscript-docs/docs/en/stdlib/spawn.md +147 -0
  137. package/redscript-docs/docs/en/stdlib/state.md +142 -0
  138. package/redscript-docs/docs/en/stdlib/strings.md +154 -0
  139. package/redscript-docs/docs/en/stdlib/tags.md +3451 -0
  140. package/redscript-docs/docs/en/stdlib/teams.md +153 -0
  141. package/redscript-docs/docs/en/stdlib/timer.md +246 -0
  142. package/redscript-docs/docs/en/stdlib/vec.md +158 -0
  143. package/redscript-docs/docs/en/stdlib/world.md +298 -0
  144. package/redscript-docs/docs/zh/stdlib/advanced.md +615 -0
  145. package/redscript-docs/docs/zh/stdlib/bigint.md +316 -0
  146. package/redscript-docs/docs/zh/stdlib/bits.md +292 -0
  147. package/redscript-docs/docs/zh/stdlib/bossbar.md +170 -0
  148. package/redscript-docs/docs/zh/stdlib/calculus.md +287 -0
  149. package/redscript-docs/docs/zh/stdlib/color.md +353 -0
  150. package/redscript-docs/docs/zh/stdlib/combat.md +88 -0
  151. package/redscript-docs/docs/zh/stdlib/cooldown.md +84 -0
  152. package/redscript-docs/docs/zh/stdlib/dialog.md +152 -0
  153. package/redscript-docs/docs/zh/stdlib/easing.md +558 -0
  154. package/redscript-docs/docs/zh/stdlib/ecs.md +472 -0
  155. package/redscript-docs/docs/zh/stdlib/effects.md +324 -0
  156. package/redscript-docs/docs/zh/stdlib/events.md +3 -0
  157. package/redscript-docs/docs/zh/stdlib/expr.md +37 -0
  158. package/redscript-docs/docs/zh/stdlib/fft.md +128 -0
  159. package/redscript-docs/docs/zh/stdlib/geometry.md +430 -0
  160. package/redscript-docs/docs/zh/stdlib/graph.md +259 -0
  161. package/redscript-docs/docs/zh/stdlib/heap.md +185 -0
  162. package/redscript-docs/docs/zh/stdlib/interactions.md +160 -0
  163. package/redscript-docs/docs/zh/stdlib/inventory.md +94 -0
  164. package/redscript-docs/docs/zh/stdlib/linalg.md +543 -0
  165. package/redscript-docs/docs/zh/stdlib/list.md +561 -0
  166. package/redscript-docs/docs/zh/stdlib/map.md +132 -0
  167. package/redscript-docs/docs/zh/stdlib/math.md +193 -0
  168. package/redscript-docs/docs/zh/stdlib/math_hp.md +143 -0
  169. package/redscript-docs/docs/zh/stdlib/matrix.md +396 -0
  170. package/redscript-docs/docs/zh/stdlib/mobs.md +965 -0
  171. package/redscript-docs/docs/zh/stdlib/noise.md +244 -0
  172. package/redscript-docs/docs/zh/stdlib/ode.md +243 -0
  173. package/redscript-docs/docs/zh/stdlib/parabola.md +337 -0
  174. package/redscript-docs/docs/zh/stdlib/particles.md +307 -0
  175. package/redscript-docs/docs/zh/stdlib/pathfind.md +255 -0
  176. package/redscript-docs/docs/zh/stdlib/physics.md +493 -0
  177. package/redscript-docs/docs/zh/stdlib/player.md +78 -0
  178. package/redscript-docs/docs/zh/stdlib/quaternion.md +669 -0
  179. package/redscript-docs/docs/zh/stdlib/queue.md +124 -0
  180. package/redscript-docs/docs/zh/stdlib/random.md +222 -0
  181. package/redscript-docs/docs/zh/stdlib/result.md +147 -0
  182. package/redscript-docs/docs/zh/stdlib/scheduler.md +173 -0
  183. package/redscript-docs/docs/zh/stdlib/set_int.md +180 -0
  184. package/redscript-docs/docs/zh/stdlib/sets.md +107 -0
  185. package/redscript-docs/docs/zh/stdlib/signal.md +373 -0
  186. package/redscript-docs/docs/zh/stdlib/sort.md +104 -0
  187. package/redscript-docs/docs/zh/stdlib/spawn.md +142 -0
  188. package/redscript-docs/docs/zh/stdlib/state.md +134 -0
  189. package/redscript-docs/docs/zh/stdlib/strings.md +107 -0
  190. package/redscript-docs/docs/zh/stdlib/tags.md +3451 -0
  191. package/redscript-docs/docs/zh/stdlib/teams.md +150 -0
  192. package/redscript-docs/docs/zh/stdlib/timer.md +254 -0
  193. package/redscript-docs/docs/zh/stdlib/vec.md +158 -0
  194. package/redscript-docs/docs/zh/stdlib/world.md +289 -0
  195. package/src/__tests__/formatter-extra.test.ts +139 -0
  196. package/src/__tests__/global-vars.test.ts +171 -0
  197. package/src/__tests__/lint/new-rules.test.ts +437 -0
  198. package/src/__tests__/lsp-rename.test.ts +171 -0
  199. package/src/__tests__/mc-integration/say-fstring.test.ts +211 -0
  200. package/src/__tests__/mc-integration/stdlib-coverage-2.test.ts +1 -1
  201. package/src/__tests__/mc-integration/stdlib-coverage-3.test.ts +1 -1
  202. package/src/__tests__/mc-integration/stdlib-coverage-4.test.ts +1 -1
  203. package/src/__tests__/mc-integration/stdlib-coverage-5.test.ts +1 -1
  204. package/src/__tests__/mc-integration/stdlib-coverage-6.test.ts +1 -1
  205. package/src/__tests__/mc-integration/stdlib-coverage-7.test.ts +1 -1
  206. package/src/__tests__/mc-integration/stdlib-coverage-8.test.ts +1 -1
  207. package/src/__tests__/mc-syntax.test.ts +3 -0
  208. package/src/__tests__/monomorphize-coverage.test.ts +220 -0
  209. package/src/__tests__/optimizer-cse.test.ts +250 -0
  210. package/src/__tests__/parser.test.ts +4 -13
  211. package/src/__tests__/repl-server-extra.test.ts +6 -6
  212. package/src/__tests__/repl-server.test.ts +5 -6
  213. package/src/__tests__/stdlib/queue.test.ts +6 -6
  214. package/src/lexer/index.ts +2 -1
  215. package/src/lint/index.ts +713 -5
  216. package/src/mc-test/client.ts +40 -0
  217. package/src/mir/lower.ts +111 -2
  218. package/src/optimizer/interprocedural.ts +40 -2
  219. package/src/parser/decl-parser.ts +349 -0
  220. package/src/parser/expr-parser.ts +838 -0
  221. package/src/parser/index.ts +17 -2558
  222. package/src/parser/stmt-parser.ts +585 -0
  223. package/src/parser/type-parser.ts +276 -0
  224. package/src/parser/utils.ts +173 -0
  225. package/src/stdlib/queue.mcrs +19 -6
@@ -0,0 +1,162 @@
1
+ # RedScript Lint Rules
2
+
3
+ The lint engine runs after HIR lowering and reports warnings before code generation.
4
+
5
+ ## Existing Rules
6
+
7
+ ### `unused-variable`
8
+ Warns when a `let` binding is declared but never read.
9
+
10
+ ```redscript
11
+ fn foo(): void {
12
+ let x: int = 5; // warning: "x" is declared but never used
13
+ }
14
+ ```
15
+
16
+ ### `unused-import`
17
+ Warns when an imported symbol is never called in the module.
18
+
19
+ ```redscript
20
+ import mylib::helper; // warning: "helper" is never used
21
+
22
+ fn main(): void {
23
+ say("hello");
24
+ }
25
+ ```
26
+
27
+ ### `magic-number`
28
+ Warns when a literal number with absolute value greater than 1 is used directly outside a `const` declaration.
29
+
30
+ ```redscript
31
+ fn foo(): void {
32
+ let x: int = 1000; // warning: avoid magic number 1000
33
+ }
34
+
35
+ const MAX: int = 1000; // OK — const declarations are exempt
36
+ ```
37
+
38
+ ### `dead-branch`
39
+ Warns when an `if` condition is a compile-time constant (always true or always false).
40
+
41
+ ```redscript
42
+ fn foo(): void {
43
+ if 1 == 2 { // warning: condition is always false
44
+ say("never");
45
+ }
46
+ }
47
+ ```
48
+
49
+ ### `function-too-long`
50
+ Warns when a function body exceeds the line limit (default: 50 lines). Configurable via `LintOptions.maxFunctionLines`.
51
+
52
+ ---
53
+
54
+ ## New Rules
55
+
56
+ ### `no-dead-assignment`
57
+ Warns when a variable is assigned a value that is immediately overwritten before being read. The initial write is "dead" — it has no effect on program behavior.
58
+
59
+ ```redscript
60
+ fn foo(): void {
61
+ let x: int = 0; // warning: assignment to "x" is never read before being overwritten
62
+ x = 42;
63
+ say("done");
64
+ }
65
+ ```
66
+
67
+ No warning when each assigned value is read:
68
+
69
+ ```redscript
70
+ fn foo(): int {
71
+ let x: int = 5;
72
+ let y: int = x; // reads x — clears pending write
73
+ x = 10;
74
+ return x + y; // reads x again
75
+ }
76
+ ```
77
+
78
+ ### `prefer-match-exhaustive`
79
+ Warns when a `match` expression uses Option patterns (`Some`/`None`) but is missing one of the arms and has no wildcard `_` catch-all.
80
+
81
+ ```redscript
82
+ fn foo(x: Option<int>): void {
83
+ match x {
84
+ Some(v) => { say("got value"); }
85
+ // warning: match on Option is missing a None arm
86
+ }
87
+ }
88
+ ```
89
+
90
+ No warning when both arms are present, or when a wildcard covers the rest:
91
+
92
+ ```redscript
93
+ fn foo(x: Option<int>): void {
94
+ match x {
95
+ Some(v) => { say("got value"); }
96
+ None => { say("nothing"); }
97
+ }
98
+ }
99
+ ```
100
+
101
+ ### `no-empty-catch`
102
+ Warns about silent failure patterns — specifically:
103
+ - An `if let Some` with an empty `else {}` block (silently ignores the None case)
104
+ - A `match` arm with an empty body
105
+
106
+ ```redscript
107
+ fn foo(x: Option<int>): void {
108
+ if let Some(v) = x {
109
+ say("ok");
110
+ } else {} // warning: None case is silently ignored
111
+ }
112
+
113
+ fn bar(x: Option<int>): void {
114
+ match x {
115
+ Some(v) => { say("ok"); }
116
+ None => {} // warning: empty match arm body
117
+ }
118
+ }
119
+ ```
120
+
121
+ ### `naming-convention`
122
+ Enforces naming conventions:
123
+ - Variables (let bindings, foreach bindings, if-let / while-let bindings) must use **camelCase**
124
+ - Struct and enum type names must use **PascalCase**
125
+
126
+ A leading underscore is allowed (e.g. `_unused` is valid camelCase).
127
+
128
+ ```redscript
129
+ fn foo(): void {
130
+ let my_var: int = 5; // warning: "my_var" should use camelCase — use myVar
131
+ }
132
+
133
+ struct myPoint { x: int, y: int } // warning: "myPoint" should use PascalCase — use MyPoint
134
+ ```
135
+
136
+ No warning for:
137
+
138
+ ```redscript
139
+ fn foo(): void {
140
+ let myVar: int = 5;
141
+ let _ignored: int = 0;
142
+ }
143
+
144
+ struct MyPoint { x: int, y: int }
145
+ ```
146
+
147
+ ### `no-magic-numbers`
148
+ Similar to `magic-number` but checks against a configurable allow-list (default: `[0, 1]`) instead of a threshold. Numbers outside the allow-list that appear in expressions outside `const` declarations are flagged.
149
+
150
+ ```redscript
151
+ fn foo(): void {
152
+ let x: int = 42; // warning: Magic number 42 — extract to a named const
153
+ }
154
+
155
+ const ANSWER: int = 42; // OK — const declarations are exempt
156
+ ```
157
+
158
+ Configurable via `LintOptions.allowedNumbers`:
159
+
160
+ ```typescript
161
+ lintString(source, file, ns, { allowedNumbers: [0, 1, 42, 100] })
162
+ ```
@@ -2,6 +2,8 @@
2
2
 
3
3
  Import: `import bigint;`
4
4
 
5
+ > **Attribution:** Parts of this module's multi-precision arithmetic approach were inspired by [kaer-3058/large_number](https://github.com/kaer-3058/large_number).
6
+
5
7
  Arbitrary-precision integers represented as base-10000 (万進制) `int` arrays in NBT storage. Arrays are big-endian (index 0 = most significant chunk). Provides 3-chunk (96-bit) helpers and arbitrary-length operations for addition, subtraction, multiplication, division, comparison, and utility functions. Full bigint×bigint multiplication and squaring included.
6
8
 
7
9
  ## Functions
@@ -1,47 +1,67 @@
1
1
  # RedScript VSCode Extension
2
2
 
3
- Syntax highlighting and snippets for [RedScript](https://github.com/bkmashiro/redscript) — a compiler targeting Minecraft Java Edition datapacks.
3
+ > Version 1.3.80 | [RedScript 3.0](https://github.com/bkmashiro/redscript)
4
+
5
+ Full language support for [RedScript](https://github.com/bkmashiro/redscript) — a compiler targeting Minecraft Java Edition datapacks.
4
6
 
5
7
  ## Features
6
8
 
7
- - **RedScript syntax highlighting** (`.rs` files)
8
- - Keywords: `fn`, `let`, `struct`, `if`, `while`, `for`, `foreach`, `as`, `at`
9
- - Entity selectors: `@a`, `@e[type=zombie, distance=..5]`, etc.
9
+ ### Syntax Highlighting
10
+
11
+ - **RedScript** (`.mcrs`, `.rs` files)
12
+ - Keywords, types, decorators, operators
13
+ - Entity selectors: `@a`, `@e[type=zombie, distance=..5]`
10
14
  - Range literals: `..5`, `1..`, `1..10`
11
- - Decorators: `@tick`, `@tick(rate=20)`, `@on_trigger("name")`
12
- - Built-in functions: `say`, `kill`, `give`, `effect`, `raw`, `random`, `spawn_object`
13
- - Types: `int`, `float`, `bool`, `string`, `void`
14
-
15
- - **mcfunction syntax highlighting** (`.mcfunction` files)
16
- - Full command syntax from [MinecraftCommands/syntax-mcfunction](https://github.com/MinecraftCommands/syntax-mcfunction)
17
- - Entity selectors, NBT, coordinates, resource locations
18
-
19
- - **Code snippets**
20
- - `fn` function declaration
21
- - `tickfn` `@tick` function
22
- - `tickratefn` `@tick(rate=N)` function
23
- - `trigfn` `@on_trigger` handler
24
- - `foreach` entity foreach loop
25
- - `struct` → struct declaration
26
- - `for` → C-style for loop
27
- - `spawn` → spawn_object call
28
- - And more...
15
+ - Format strings: `f"Hello {name}!"`
16
+ - All 50 stdlib modules
17
+
18
+ - **mcfunction** (`.mcfunction` files)
19
+ - Full command syntax highlighting
20
+ - Entity selectors, NBT, coordinates
21
+
22
+ ### Language Server (LSP)
23
+
24
+ - **Diagnostics** Real-time error checking
25
+ - **Hover** Type info and `///` doc comments
26
+ - **Go to Definition** — Jump to function/struct declarations
27
+ - **Auto-complete** Functions, types, stdlib modules
28
+ - **Lint warnings** 5 built-in lint rules
29
+
30
+ ### Code Snippets
31
+
32
+ | Trigger | Result |
33
+ |---------|--------|
34
+ | `fn` | Function declaration |
35
+ | `tickfn` | `@tick` function |
36
+ | `struct` | Struct declaration |
37
+ | `match` | Match expression |
38
+ | `foreach` | Entity foreach loop |
39
+ | `result` | Result<T> handling |
29
40
 
30
41
  ## Install
31
42
 
32
- ### From VSIX (manual)
43
+ ### VS Code Marketplace
44
+
45
+ Search for "RedScript" in the Extensions panel, or:
46
+ ```
47
+ ext install bkmashiro.redscript-vscode
48
+ ```
49
+
50
+ ### Manual (VSIX)
33
51
 
34
52
  ```bash
35
53
  cd editors/vscode
36
54
  npm install -g @vscode/vsce
37
55
  vsce package
38
- code --install-extension redscript-vscode-0.1.0.vsix
56
+ code --install-extension redscript-vscode-1.3.80.vsix
39
57
  ```
40
58
 
41
- ### Note on `.rs` extension
59
+ ## File Extensions
42
60
 
43
- RedScript uses `.rs` files, same as Rust. If you have the Rust extension installed, you may need to associate `.rs` files with RedScript manually:
61
+ - `.mcrs` Recommended (no conflict with Rust)
62
+ - `.rs` — Supported, but may conflict with Rust extension
44
63
 
64
+ To force `.rs` as RedScript:
45
65
  ```json
46
66
  // settings.json
47
67
  {
@@ -51,28 +71,30 @@ RedScript uses `.rs` files, same as Rust. If you have the Rust extension install
51
71
  }
52
72
  ```
53
73
 
54
- Or use `.mcrs` extension (we may switch to this in future).
55
-
56
74
  ## Usage
57
75
 
58
- Write RedScript code with full syntax highlighting:
76
+ ```redscript
77
+ import math;
78
+ import player;
59
79
 
60
- ```
61
80
  @tick(rate=20)
62
- fn check_zombies() {
63
- foreach (z in @e[type=zombie, distance=..10]) {
64
- kill(z);
81
+ fn gravity_check() {
82
+ foreach (p in @a[tag=flying]) {
83
+ let y = player::get_y(p);
84
+ if y > 100 {
85
+ effect::give(p, "slow_falling", 5);
86
+ }
65
87
  }
66
88
  }
67
-
68
- @on_trigger("claim_reward")
69
- fn handle_claim() {
70
- give(@s, "minecraft:diamond", 1);
71
- }
72
89
  ```
73
90
 
74
- Compile with the CLI:
75
-
91
+ Compile:
76
92
  ```bash
77
- redscript compile src/main.rs -o dist/mypack/
93
+ redscript build src/ -o dist/mypack/
78
94
  ```
95
+
96
+ ## Links
97
+
98
+ - [RedScript Documentation](https://redscript-docs.pages.dev)
99
+ - [Online Playground](https://redscript.pages.dev)
100
+ - [GitHub](https://github.com/bkmashiro/redscript)