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,244 @@
1
+ # Noise
2
+
3
+ > Auto-generated from `src/stdlib/noise.mcrs` — do not edit manually.
4
+
5
+ ## API
6
+
7
+ - [hash_1d](#hash-1d)
8
+ - [hash_2d](#hash-2d)
9
+ - [hash_1d_pos](#hash-1d-pos)
10
+ - [hash_2d_pos](#hash-2d-pos)
11
+ - [value_noise_1d](#value-noise-1d)
12
+ - [value_noise_2d](#value-noise-2d)
13
+ - [fbm_1d](#fbm-1d)
14
+ - [fbm_2d](#fbm-2d)
15
+ - [terrain_height](#terrain-height)
16
+
17
+ ---
18
+
19
+ ## `hash_1d` <Badge type="info" text="v1.0.0" />
20
+
21
+ Generate a pseudo-random integer from a 1D integer coordinate.
22
+
23
+ ```redscript
24
+ fn hash_1d(x: int): int
25
+ ```
26
+
27
+ **Parameters**
28
+
29
+ | Parameter | Description |
30
+ |-----------|-------------|
31
+ | `x` | Input coordinate (any integer) |
32
+
33
+ **Returns:** Pseudo-random integer (any value; use % to restrict range)
34
+
35
+ **Example**
36
+
37
+ ```redscript
38
+ let h: int = hash_1d(42) // deterministic hash of coordinate 42
39
+ ```
40
+
41
+ ---
42
+
43
+ ## `hash_2d` <Badge type="info" text="v1.0.0" />
44
+
45
+ Generate a pseudo-random integer from a 2D integer coordinate pair.
46
+
47
+ ```redscript
48
+ fn hash_2d(x: int, z: int): int
49
+ ```
50
+
51
+ **Parameters**
52
+
53
+ | Parameter | Description |
54
+ |-----------|-------------|
55
+ | `x` | First coordinate (any integer) |
56
+ | `z` | Second coordinate (any integer) |
57
+
58
+ **Returns:** Pseudo-random integer combining both inputs deterministically
59
+
60
+ **Example**
61
+
62
+ ```redscript
63
+ let h: int = hash_2d(10, 20) // deterministic hash of (10, 20)
64
+ ```
65
+
66
+ ---
67
+
68
+ ## `hash_1d_pos` <Badge type="info" text="v1.0.0" />
69
+
70
+ Generate a non-negative hash in [0, 10000] from a 1D coordinate.
71
+
72
+ ```redscript
73
+ fn hash_1d_pos(x: int): int
74
+ ```
75
+
76
+ **Parameters**
77
+
78
+ | Parameter | Description |
79
+ |-----------|-------------|
80
+ | `x` | Input coordinate |
81
+
82
+ **Returns:** Integer in [0, 10000]
83
+
84
+ **Example**
85
+
86
+ ```redscript
87
+ let v: int = hash_1d_pos(5) // value between 0 and 10000
88
+ ```
89
+
90
+ ---
91
+
92
+ ## `hash_2d_pos` <Badge type="info" text="v1.0.0" />
93
+
94
+ Generate a non-negative hash in [0, 10000] from a 2D coordinate pair.
95
+
96
+ ```redscript
97
+ fn hash_2d_pos(x: int, z: int): int
98
+ ```
99
+
100
+ **Parameters**
101
+
102
+ | Parameter | Description |
103
+ |-----------|-------------|
104
+ | `x` | First coordinate |
105
+ | `z` | Second coordinate |
106
+
107
+ **Returns:** Integer in [0, 10000]
108
+
109
+ **Example**
110
+
111
+ ```redscript
112
+ let v: int = hash_2d_pos(3, 7) // value between 0 and 10000
113
+ ```
114
+
115
+ ---
116
+
117
+ ## `value_noise_1d` <Badge type="info" text="v1.0.0" />
118
+
119
+ Smooth 1D value noise at a fixed-point position.
120
+
121
+ ```redscript
122
+ fn value_noise_1d(x_fx: int): int
123
+ ```
124
+
125
+ **Parameters**
126
+
127
+ | Parameter | Description |
128
+ |-----------|-------------|
129
+ | `x_fx` | Position ×10000 (e.g. 10000 = coordinate 1.0) |
130
+
131
+ **Returns:** Noise value in [0, 10000] with smooth interpolation between integer coords
132
+
133
+ **Example**
134
+
135
+ ```redscript
136
+ let n: int = value_noise_1d(15000) // smooth noise at x=1.5
137
+ ```
138
+
139
+ ---
140
+
141
+ ## `value_noise_2d` <Badge type="info" text="v1.0.0" />
142
+
143
+ Smooth 2D value noise at a fixed-point position.
144
+
145
+ ```redscript
146
+ fn value_noise_2d(x_fx: int, z_fx: int): int
147
+ ```
148
+
149
+ **Parameters**
150
+
151
+ | Parameter | Description |
152
+ |-----------|-------------|
153
+ | `x_fx` | X position ×10000 |
154
+ | `z_fx` | Z position ×10000 |
155
+
156
+ **Returns:** Noise value in [0, 10000] with bilinear smooth interpolation
157
+
158
+ **Example**
159
+
160
+ ```redscript
161
+ let n: int = value_noise_2d(15000, 23000) // noise at (1.5, 2.3)
162
+ ```
163
+
164
+ ---
165
+
166
+ ## `fbm_1d` <Badge type="info" text="v1.0.0" />
167
+
168
+ 1D Fractal Brownian Motion — stacks multiple octaves of value noise.
169
+
170
+ ```redscript
171
+ fn fbm_1d(x_fx: int, octaves: int, persistence_fx: int): int
172
+ ```
173
+
174
+ **Parameters**
175
+
176
+ | Parameter | Description |
177
+ |-----------|-------------|
178
+ | `x_fx` | Position ×10000 |
179
+ | `octaves` | Number of noise layers (1–6; more = more detail but slower) |
180
+ | `persistence_fx` | Amplitude decay per octave ×10000 (5000 = 0.5 recommended) |
181
+
182
+ **Returns:** Normalized noise value in approximately [0, 10000]
183
+
184
+ **Example**
185
+
186
+ ```redscript
187
+ let h: int = fbm_1d(50000, 4, 5000) // 4 octave noise at x=5.0
188
+ ```
189
+
190
+ ---
191
+
192
+ ## `fbm_2d` <Badge type="info" text="v1.0.0" />
193
+
194
+ 2D Fractal Brownian Motion — stacks multiple octaves of 2D value noise.
195
+
196
+ ```redscript
197
+ fn fbm_2d(x_fx: int, z_fx: int, octaves: int, persistence_fx: int): int
198
+ ```
199
+
200
+ **Parameters**
201
+
202
+ | Parameter | Description |
203
+ |-----------|-------------|
204
+ | `x_fx` | X position ×10000 |
205
+ | `z_fx` | Z position ×10000 |
206
+ | `octaves` | Number of noise layers (1–6) |
207
+ | `persistence_fx` | Amplitude decay per octave ×10000 (5000 = 0.5) |
208
+
209
+ **Returns:** Normalized noise value in approximately [0, 10000]
210
+
211
+ **Example**
212
+
213
+ ```redscript
214
+ let h: int = fbm_2d(30000, 50000, 3, 5000) // 3 octave 2D noise
215
+ ```
216
+
217
+ ---
218
+
219
+ ## `terrain_height` <Badge type="info" text="v1.0.0" />
220
+
221
+ Generate a terrain height using 3-octave FBM noise.
222
+
223
+ ```redscript
224
+ fn terrain_height(x: int, z: int, base_y: int, amplitude: int): int
225
+ ```
226
+
227
+ **Parameters**
228
+
229
+ | Parameter | Description |
230
+ |-----------|-------------|
231
+ | `x` | Block X coordinate (integer, not fixed-point) |
232
+ | `z` | Block Z coordinate (integer, not fixed-point) |
233
+ | `base_y` | Baseline height in blocks |
234
+ | `amplitude` | Maximum height variation above/below base_y in blocks |
235
+
236
+ **Returns:** Block height at (x, z): base_y + noise * amplitude / 10000
237
+
238
+ **Example**
239
+
240
+ ```redscript
241
+ let h: int = terrain_height(100, 200, 64, 16) // terrain at (100, 200) near y=64
242
+ ```
243
+
244
+ ---
@@ -0,0 +1,253 @@
1
+ # Ode
2
+
3
+ > Auto-generated from `src/stdlib/ode.mcrs` — do not edit manually.
4
+
5
+ ## API
6
+
7
+ - [ode_mul_fx](#ode-mul-fx)
8
+ - [ode_weighted_increment](#ode-weighted-increment)
9
+ - [ode_reset](#ode-reset)
10
+ - [ode_get_system](#ode-get-system)
11
+ - [ode_get_t](#ode-get-t)
12
+ - [ode_get_y](#ode-get-y)
13
+ - [ode_get_y2](#ode-get-y2)
14
+ - [ode_get_k](#ode-get-k)
15
+ - [ode_get_extra](#ode-get-extra)
16
+ - [ode_get_steps](#ode-get-steps)
17
+ - [ode_step](#ode-step)
18
+ - [ode_run](#ode-run)
19
+ - [ode_run2](#ode-run2)
20
+
21
+ ---
22
+
23
+ ## `ode_mul_fx` <Badge type="info" text="v2.0.0" />
24
+
25
+ Fixed-point multiplication: `a_fx * b_fx / 10000`.
26
+
27
+ ```redscript
28
+ fn ode_mul_fx(a_fx: int, b_fx: int): int
29
+ ```
30
+
31
+ **Parameters**
32
+
33
+ | Parameter | Description |
34
+ |-----------|-------------|
35
+ | `a_fx` | First operand ×10000 |
36
+ | `b_fx` | Second operand ×10000 |
37
+
38
+ **Returns:** Product in ×10000 scale
39
+
40
+ ---
41
+
42
+ ## `ode_weighted_increment` <Badge type="info" text="v2.0.0" />
43
+
44
+ Compute the RK4 weighted increment: `h * (k1 + 2k2 + 2k3 + k4) / 6`.
45
+
46
+ All values are ×10000. The divisor 60000 = 6 × 10000.
47
+
48
+ ```redscript
49
+ fn ode_weighted_increment(h_fx: int, deriv_sum_fx: int): int
50
+ ```
51
+
52
+ **Parameters**
53
+
54
+ | Parameter | Description |
55
+ |-----------|-------------|
56
+ | `h_fx` | Step size ×10000 |
57
+ | `deriv_sum_fx` | `k1 + 2k2 + 2k3 + k4` in ×10000 |
58
+
59
+ **Returns:** Weighted increment in ×10000
60
+
61
+ ---
62
+
63
+ ## `ode_reset` <Badge type="info" text="v2.0.0" />
64
+
65
+ Initialise the ODE module state in `storage rs:ode`.
66
+
67
+ ```redscript
68
+ fn ode_reset(system_id: int, t_fx: int, y_fx: int, y2_fx: int, k_fx: int, extra_fx: int)
69
+ ```
70
+
71
+ **Parameters**
72
+
73
+ | Parameter | Description |
74
+ |-----------|-------------|
75
+ | `system_id` | Built-in system constant (1=decay, 2=growth, 3=oscillator) |
76
+ | `t_fx` | Initial time ×10000 |
77
+ | `y_fx` | Initial primary variable y(0) ×10000 |
78
+ | `y2_fx` | Initial secondary variable y'(0) ×10000 (for system 3) |
79
+ | `k_fx` | Rate/spring constant ×10000 |
80
+ | `extra_fx` | Damping coefficient ×10000 (for system 3) |
81
+
82
+ **Example**
83
+
84
+ ```redscript
85
+ ode_reset(1, 0, 10000, 0, 10000, 0)
86
+ ```
87
+
88
+ ---
89
+
90
+ ## `ode_get_system` <Badge type="info" text="v2.0.0" />
91
+
92
+ Return the current system ID from ODE state.
93
+
94
+ ```redscript
95
+ fn ode_get_system(): int
96
+ ```
97
+
98
+ **Returns:** System ID stored in slot 0
99
+
100
+ ---
101
+
102
+ ## `ode_get_t` <Badge type="info" text="v2.0.0" />
103
+
104
+ Return the current time `t` from ODE state (×10000).
105
+
106
+ ```redscript
107
+ fn ode_get_t(): int
108
+ ```
109
+
110
+ **Returns:** Current time ×10000
111
+
112
+ ---
113
+
114
+ ## `ode_get_y` <Badge type="info" text="v2.0.0" />
115
+
116
+ Return the current primary variable `y` from ODE state (×10000).
117
+
118
+ ```redscript
119
+ fn ode_get_y(): int
120
+ ```
121
+
122
+ **Returns:** Current y value ×10000
123
+
124
+ ---
125
+
126
+ ## `ode_get_y2` <Badge type="info" text="v2.0.0" />
127
+
128
+ Return the current secondary variable `y'` from ODE state (×10000).
129
+
130
+ ```redscript
131
+ fn ode_get_y2(): int
132
+ ```
133
+
134
+ **Returns:** Current y' value ×10000 (meaningful for system 3 only)
135
+
136
+ ---
137
+
138
+ ## `ode_get_k` <Badge type="info" text="v2.0.0" />
139
+
140
+ Return the rate constant `k` from ODE state (×10000).
141
+
142
+ ```redscript
143
+ fn ode_get_k(): int
144
+ ```
145
+
146
+ **Returns:** Rate constant ×10000
147
+
148
+ ---
149
+
150
+ ## `ode_get_extra` <Badge type="info" text="v2.0.0" />
151
+
152
+ Return the extra parameter from ODE state (×10000).
153
+
154
+ ```redscript
155
+ fn ode_get_extra(): int
156
+ ```
157
+
158
+ **Returns:** Extra parameter ×10000 (damping for system 3)
159
+
160
+ ---
161
+
162
+ ## `ode_get_steps` <Badge type="info" text="v2.0.0" />
163
+
164
+ Return the number of steps taken so far.
165
+
166
+ ```redscript
167
+ fn ode_get_steps(): int
168
+ ```
169
+
170
+ **Returns:** Step count (plain integer)
171
+
172
+ ---
173
+
174
+ ## `ode_step` <Badge type="info" text="v2.0.0" />
175
+
176
+ Advance the ODE state by one RK4 step of size `h_fx`.
177
+
178
+ Updates time `t`, primary variable `y` (and `y2` for system 3), and
179
+ increments the step counter in `storage rs:ode`.
180
+
181
+ ```redscript
182
+ fn ode_step(h_fx: int)
183
+ ```
184
+
185
+ **Parameters**
186
+
187
+ | Parameter | Description |
188
+ |-----------|-------------|
189
+ | `h_fx` | Step size ×10000 (e.g. `1000` = 0.1 time unit) |
190
+
191
+ ---
192
+
193
+ ## `ode_run` <Badge type="info" text="v2.0.0" />
194
+
195
+ Run `steps` RK4 steps of a scalar ODE system and store results in module state.
196
+
197
+ Built-in systems: `1` = exponential decay (`dy/dt = -k·y`),
198
+ `2` = exponential growth (`dy/dt = k·y`).
199
+
200
+ ```redscript
201
+ fn ode_run(system_id: int, t0_fx: int, y0_fx: int, h_fx: int, steps: int, k_fx: int)
202
+ ```
203
+
204
+ **Parameters**
205
+
206
+ | Parameter | Description |
207
+ |-----------|-------------|
208
+ | `system_id` | Built-in system constant (1 or 2 for scalar systems) |
209
+ | `t0_fx` | Initial time ×10000 |
210
+ | `y0_fx` | Initial y value ×10000 |
211
+ | `h_fx` | Step size ×10000 |
212
+ | `steps` | Number of RK4 steps to execute |
213
+ | `k_fx` | Rate constant ×10000 |
214
+
215
+ **Example**
216
+
217
+ ```redscript
218
+ ode_run(1, 0, 10000, 1000, 10, 10000)
219
+ let y: int = ode_get_y()
220
+ ```
221
+
222
+ ---
223
+
224
+ ## `ode_run2` <Badge type="info" text="v2.0.0" />
225
+
226
+ Run `steps` RK4 steps of a 2D ODE system (e.g. harmonic oscillator).
227
+
228
+ Built-in system 3: `y' = y2`, `y2' = -k·y - extra·y2`.
229
+
230
+ ```redscript
231
+ fn ode_run2(system_id: int, t0_fx: int, y0_fx: int, y20_fx: int, h_fx: int, steps: int, k_fx: int, extra_fx: int)
232
+ ```
233
+
234
+ **Parameters**
235
+
236
+ | Parameter | Description |
237
+ |-----------|-------------|
238
+ | `system_id` | Built-in system constant (use `3` for harmonic oscillator) |
239
+ | `t0_fx` | Initial time ×10000 |
240
+ | `y0_fx` | Initial y value ×10000 |
241
+ | `y20_fx` | Initial y' value ×10000 |
242
+ | `h_fx` | Step size ×10000 |
243
+ | `steps` | Number of RK4 steps to execute |
244
+ | `k_fx` | Spring constant ×10000 |
245
+ | `extra_fx` | Damping coefficient ×10000 |
246
+
247
+ **Example**
248
+
249
+ ```redscript
250
+ ode_run2(3, 0, 10000, 0, 1000, 20, 10000, 500)
251
+ ```
252
+
253
+ ---