mlogjs 0.5.2 → 0.6.0
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.
- package/README.md +2 -2
- package/dist/{index.cjs → Compiler-7GMG4MDr.js} +1746 -452
- package/dist/Compiler.d.ts +8 -12
- package/dist/CompilerError.d.ts +13 -3
- package/dist/Scope.d.ts +8 -8
- package/dist/bin/files.d.ts +18 -0
- package/dist/bin.mjs +170 -0
- package/dist/handlers/Import.d.ts +5 -0
- package/dist/handlers/Literal.d.ts +2 -2
- package/dist/handlers/Typescript.d.ts +2 -2
- package/dist/handlers/index.d.ts +1 -0
- package/dist/index.mjs +3 -4267
- package/dist/instructions/AddressResolver.d.ts +4 -4
- package/dist/instructions/ControlInstructions.d.ts +3 -3
- package/dist/instructions/InstructionBase.d.ts +1 -0
- package/dist/instructions/JumpInstruction.d.ts +5 -5
- package/dist/instructions/index.d.ts +0 -1
- package/dist/macros/DynamicArray.d.ts +4 -4
- package/dist/macros/Function.d.ts +2 -2
- package/dist/macros/GetBuildings.d.ts +4 -0
- package/dist/macros/GetColor.d.ts +4 -0
- package/dist/macros/Marker.d.ts +4 -0
- package/dist/macros/Namespace.d.ts +16 -0
- package/dist/macros/Queries.d.ts +10 -0
- package/dist/macros/StringView.d.ts +4 -0
- package/dist/macros/commands/Effect.d.ts +4 -0
- package/dist/macros/commands/Format.d.ts +4 -0
- package/dist/macros/commands/LocalePrint.d.ts +4 -0
- package/dist/macros/commands/PlayMusic.d.ts +4 -0
- package/dist/macros/commands/PlaySound.d.ts +4 -0
- package/dist/macros/commands/PrintChar.d.ts +4 -0
- package/dist/macros/commands/Query.d.ts +4 -0
- package/dist/macros/commands/SetProp.d.ts +4 -0
- package/dist/macros/commands/SpawnBullet.d.ts +4 -0
- package/dist/macros/commands/Sync.d.ts +6 -0
- package/dist/macros/commands/UnpackColor.d.ts +4 -0
- package/dist/macros/commands/WeatherSense.d.ts +4 -0
- package/dist/macros/commands/WeatherSet.d.ts +4 -0
- package/dist/macros/commands/index.d.ts +13 -0
- package/dist/macros/index.d.ts +7 -1
- package/dist/macros/util.d.ts +5 -2
- package/dist/modules.d.ts +8 -0
- package/dist/operators.d.ts +1 -1
- package/dist/types.d.ts +84 -59
- package/dist/utils/constants.d.ts +9 -4
- package/dist/utils/general.d.ts +8 -9
- package/dist/utils/instruction.d.ts +5 -1
- package/dist/utils/value.d.ts +14 -5
- package/dist/values/AssignmentValue.d.ts +1 -1
- package/dist/values/BaseValue.d.ts +4 -2
- package/dist/values/DestructuringValue.d.ts +5 -7
- package/dist/values/FunctionValue.d.ts +8 -6
- package/dist/values/JumpOutValue.d.ts +4 -4
- package/dist/values/LazyValue.d.ts +3 -3
- package/dist/values/LiteralValue.d.ts +2 -3
- package/dist/values/ObjectValue.d.ts +6 -11
- package/dist/values/StoreValue.d.ts +10 -5
- package/dist/values/VoidValue.d.ts +2 -1
- package/dist/values/index.d.ts +0 -1
- package/lib/commands.d.ts +776 -730
- package/lib/eslib/lib.es2015.collection.d.ts +50 -39
- package/lib/eslib/lib.es2015.core.d.ts +59 -0
- package/lib/eslib/lib.es2015.d.ts +0 -3
- package/lib/eslib/lib.es2015.generator.d.ts +54 -53
- package/lib/eslib/lib.es2015.iterable.d.ts +9 -6
- package/lib/eslib/lib.es5.d.ts +53 -6
- package/lib/globals.d.ts +309 -18
- package/lib/helpers.d.ts +86 -52
- package/lib/kinds.d.ts +42 -7
- package/lib/macros.d.ts +53 -18
- package/lib/traits.d.ts +308 -146
- package/lib/util.d.ts +144 -48
- package/lib/world.d.ts +1197 -0
- package/package.json +27 -35
- package/dist/bin.cjs +0 -111
- package/dist/initScope.d.ts +0 -5
- package/dist/instructions/ZeroSpaceInstruction.d.ts +0 -4
- package/dist/values/SenseableValue.d.ts +0 -24
- /package/dist/{bin.d.ts → bin/index.d.ts} +0 -0
package/lib/commands.d.ts
CHANGED
|
@@ -1,45 +1,79 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./kinds";
|
|
2
2
|
import {
|
|
3
3
|
TRadarFilter,
|
|
4
4
|
TRadarSort,
|
|
5
|
-
TUnitEffect,
|
|
6
5
|
TUnitLocateBuildingGroup,
|
|
7
|
-
} from "
|
|
6
|
+
} from "mlogjs:types";
|
|
7
|
+
|
|
8
8
|
declare global {
|
|
9
9
|
/**
|
|
10
|
-
* Appends the items to the
|
|
11
|
-
*
|
|
10
|
+
* Appends the items to the global text buffer, calling this function on its
|
|
11
|
+
* own will not print any contents to a message block.
|
|
12
|
+
*
|
|
13
|
+
* To print the contents of the global text buffer and empty it, call
|
|
14
|
+
* `printFlush`.
|
|
15
|
+
*
|
|
16
|
+
* @param items The items to be added to the global text buffer.
|
|
17
|
+
*
|
|
18
|
+
* ```js
|
|
19
|
+
* const a = Math.floor(Math.rand(10));
|
|
20
|
+
* const b = Math.floor(Math.rand(10));
|
|
12
21
|
*
|
|
13
|
-
*
|
|
22
|
+
* // call normally
|
|
23
|
+
* print("a + b = ", a, " + ", b, " = ", a + b, "\n");
|
|
14
24
|
*
|
|
15
|
-
*
|
|
25
|
+
* // call with tagged string templates
|
|
26
|
+
* print`a + b = ${a} + ${b} = ${a + b}\n`;
|
|
27
|
+
*
|
|
28
|
+
* printFlush();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function print(...items: unknown[]): void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Replaces the first placeholder with lowest value in the global text buffer.
|
|
16
35
|
*
|
|
17
36
|
* ```js
|
|
18
|
-
*
|
|
19
|
-
*
|
|
37
|
+
* print("{1} {0}");
|
|
38
|
+
* format("world!");
|
|
39
|
+
* format("Hello");
|
|
40
|
+
* printFlush(); // prints "Hello world!"
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function format(value: unknown): void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Adds a character to the global text buffer using the provided using the
|
|
47
|
+
* provided UTF-16 code unit or the icon of the provided game content type.
|
|
20
48
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
49
|
+
* ```js
|
|
50
|
+
* printChar(128073); // "👉" emoji
|
|
51
|
+
* printChar(Blocks.router);
|
|
52
|
+
* printFlush();
|
|
23
53
|
* ```
|
|
24
54
|
*/
|
|
25
|
-
function
|
|
55
|
+
function printChar(character: number | symbol): void;
|
|
26
56
|
|
|
27
57
|
/** Contains the multiple variants of the `draw` instruction */
|
|
28
58
|
namespace draw {
|
|
29
59
|
/**
|
|
30
60
|
* Fills the screen with a color.
|
|
31
61
|
*
|
|
62
|
+
* ```js
|
|
63
|
+
* draw.clear(0, 0, 0); // black screen
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
32
66
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
33
67
|
*/
|
|
34
68
|
function clear(r: number, g: number, b: number): void;
|
|
35
69
|
/**
|
|
36
70
|
* Sets the color for the next drawing operations.
|
|
37
71
|
*
|
|
38
|
-
*
|
|
72
|
+
* Each parameter must be within range: [0, 255].
|
|
39
73
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
74
|
+
* ```js
|
|
75
|
+
* draw.color(255, 255, 255, 128);
|
|
76
|
+
* ```
|
|
43
77
|
*
|
|
44
78
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
45
79
|
*/
|
|
@@ -53,16 +87,15 @@ declare global {
|
|
|
53
87
|
* ```js
|
|
54
88
|
* draw.col(packColor(1, 1, 1, 1));
|
|
55
89
|
* ```
|
|
56
|
-
*
|
|
57
90
|
*/
|
|
58
91
|
function col(rgbaData: number): void;
|
|
59
92
|
|
|
60
93
|
/**
|
|
61
94
|
* Sets the width of the next lines to be drawn.
|
|
62
95
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
96
|
+
* ```js
|
|
97
|
+
* draw.stroke(15);
|
|
98
|
+
* ```
|
|
66
99
|
*
|
|
67
100
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
68
101
|
*/
|
|
@@ -71,9 +104,9 @@ declare global {
|
|
|
71
104
|
/**
|
|
72
105
|
* Draws a line between two points.
|
|
73
106
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
107
|
+
* ```js
|
|
108
|
+
* draw.line({ x: 5, y: 5, x2: 50, y2: 50 });
|
|
109
|
+
* ```
|
|
77
110
|
*
|
|
78
111
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
79
112
|
*/
|
|
@@ -86,14 +119,15 @@ declare global {
|
|
|
86
119
|
|
|
87
120
|
/**
|
|
88
121
|
* Draws a filled rectangle.
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
122
|
+
*
|
|
123
|
+
* ```js
|
|
124
|
+
* draw.rect({
|
|
125
|
+
* x: 10,
|
|
126
|
+
* y: 15,
|
|
127
|
+
* height: 60,
|
|
128
|
+
* width: 40,
|
|
129
|
+
* });
|
|
130
|
+
* ```
|
|
97
131
|
*
|
|
98
132
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
99
133
|
*/
|
|
@@ -107,6 +141,15 @@ declare global {
|
|
|
107
141
|
/**
|
|
108
142
|
* Draws a rectangle outline.
|
|
109
143
|
*
|
|
144
|
+
* ```js
|
|
145
|
+
* draw.lineRect({
|
|
146
|
+
* x: 10,
|
|
147
|
+
* y: 15,
|
|
148
|
+
* height: 60,
|
|
149
|
+
* width: 40,
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
110
153
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
111
154
|
*/
|
|
112
155
|
function lineRect(options: {
|
|
@@ -118,21 +161,23 @@ declare global {
|
|
|
118
161
|
|
|
119
162
|
/**
|
|
120
163
|
* Draws a filled, regular polygon.
|
|
164
|
+
*
|
|
121
165
|
* @param options.sides The number of sides the polygon should have
|
|
122
|
-
* @param options.radius The smallest distance between a line and the center
|
|
166
|
+
* @param options.radius The smallest distance between a line and the center
|
|
167
|
+
* of the polygon
|
|
123
168
|
* @param options.rotation The rotation of the polygon in degrees
|
|
124
169
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
170
|
+
* ```js
|
|
171
|
+
* draw.poly({
|
|
172
|
+
* radius: 10,
|
|
173
|
+
* rotation: 0,
|
|
174
|
+
* sides: 10,
|
|
175
|
+
* x: 25,
|
|
176
|
+
* y: 25,
|
|
177
|
+
* });
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
136
181
|
*/
|
|
137
182
|
function poly(options: {
|
|
138
183
|
x: number;
|
|
@@ -147,21 +192,23 @@ declare global {
|
|
|
147
192
|
|
|
148
193
|
/**
|
|
149
194
|
* Draws the outline of a regular polygon.
|
|
195
|
+
*
|
|
150
196
|
* @param options.sides The number of sides the polygon should have
|
|
151
|
-
* @param options.radius The smallest distance between a line and the center
|
|
197
|
+
* @param options.radius The smallest distance between a line and the center
|
|
198
|
+
* of the polygon
|
|
152
199
|
* @param options.rotation The rotation of the polygon in degrees
|
|
153
200
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
201
|
+
* ```js
|
|
202
|
+
* draw.linePoly({
|
|
203
|
+
* radius: 10,
|
|
204
|
+
* rotation: 0,
|
|
205
|
+
* sides: 10,
|
|
206
|
+
* x: 25,
|
|
207
|
+
* y: 25,
|
|
208
|
+
* });
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
165
212
|
*/
|
|
166
213
|
function linePoly(options: {
|
|
167
214
|
x: number;
|
|
@@ -177,16 +224,16 @@ declare global {
|
|
|
177
224
|
/**
|
|
178
225
|
* Draws a filled triangle.
|
|
179
226
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
227
|
+
* ```js
|
|
228
|
+
* draw.triangle({
|
|
229
|
+
* x: 10,
|
|
230
|
+
* y: 10,
|
|
231
|
+
* x2: 20,
|
|
232
|
+
* y2: 20,
|
|
233
|
+
* x3: 30,
|
|
234
|
+
* y3: 10,
|
|
235
|
+
* });
|
|
236
|
+
* ```
|
|
190
237
|
*
|
|
191
238
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
192
239
|
*/
|
|
@@ -200,34 +247,35 @@ declare global {
|
|
|
200
247
|
}): void;
|
|
201
248
|
|
|
202
249
|
/**
|
|
203
|
-
* Draws an image of the respective content. (like `Units.dagger` and
|
|
250
|
+
* Draws an image of the respective content. (like `Units.dagger` and
|
|
251
|
+
* `Blocks.router`)
|
|
204
252
|
*
|
|
205
253
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
254
|
+
*
|
|
206
255
|
* @param options.image The symbol for the image to be drawn.
|
|
207
256
|
* @param options.rotation The rotation of the image in degrees.
|
|
208
257
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* draw
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* ```
|
|
258
|
+
* Example:
|
|
259
|
+
*
|
|
260
|
+
* ```js
|
|
261
|
+
* // draw a router
|
|
262
|
+
* draw.image({
|
|
263
|
+
* x: 30,
|
|
264
|
+
* y: 30,
|
|
265
|
+
* image: Blocks.router,
|
|
266
|
+
* size: 15,
|
|
267
|
+
* rotation: 0,
|
|
268
|
+
* });
|
|
269
|
+
*
|
|
270
|
+
* // draw the unit bound to the processor
|
|
271
|
+
* draw.image({
|
|
272
|
+
* x: 60,
|
|
273
|
+
* y: 60,
|
|
274
|
+
* image: Vars.unit.type,
|
|
275
|
+
* size: 15,
|
|
276
|
+
* rotation: 0,
|
|
277
|
+
* });
|
|
278
|
+
* ```
|
|
231
279
|
*/
|
|
232
280
|
function image(options: {
|
|
233
281
|
x: number;
|
|
@@ -238,39 +286,102 @@ declare global {
|
|
|
238
286
|
/** The rotation of the image in degrees. */
|
|
239
287
|
rotation: number;
|
|
240
288
|
}): void;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Draws text from the global text buffer, clearing it afterwards.
|
|
292
|
+
*
|
|
293
|
+
* Only ASCII characters are supported.
|
|
294
|
+
*
|
|
295
|
+
* ```js
|
|
296
|
+
* draw.print({
|
|
297
|
+
* x: 10,
|
|
298
|
+
* y: 10,
|
|
299
|
+
* align: Align.topLeft,
|
|
300
|
+
* });
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
304
|
+
*/
|
|
305
|
+
function print(options: { x: number; y: number; align: Align }): void;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Applies a translation to the next drawing operations.
|
|
309
|
+
*
|
|
310
|
+
* ```js
|
|
311
|
+
* draw.translate(10, 20);
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
function translate(x: number, y: number): void;
|
|
315
|
+
|
|
316
|
+
/** Applies a scaling to the next drawing operations. */
|
|
317
|
+
function scale(x: number, y: number): void;
|
|
318
|
+
|
|
319
|
+
/** Applies a rotation to the next drawing operations. */
|
|
320
|
+
function rotate(degrees: number): void;
|
|
321
|
+
|
|
322
|
+
/** Removes all applied transformations. */
|
|
323
|
+
function reset(): void;
|
|
241
324
|
}
|
|
242
325
|
|
|
243
326
|
/**
|
|
244
|
-
* Writes the contents of the
|
|
245
|
-
*
|
|
246
|
-
*
|
|
327
|
+
* Writes the contents of the global text buffer into the target message and
|
|
328
|
+
* clears the buffer afterwards.
|
|
329
|
+
*
|
|
330
|
+
* @param target The message building to write to. Writes to `message1` by
|
|
331
|
+
* default.
|
|
247
332
|
*
|
|
248
|
-
*
|
|
333
|
+
* Note that the default value only applies if you don't pass any parameter to
|
|
334
|
+
* this function.
|
|
335
|
+
*
|
|
336
|
+
* If `target` is `undefined`, the contents of the global text buffer will be
|
|
337
|
+
* discarded.
|
|
338
|
+
*
|
|
339
|
+
* ```js
|
|
340
|
+
* const { message2 } = getBuildings();
|
|
341
|
+
* printFlush(message2);
|
|
342
|
+
*
|
|
343
|
+
* printFlush(); // defaults to message1
|
|
344
|
+
* ```
|
|
249
345
|
*/
|
|
250
|
-
function printFlush(target
|
|
346
|
+
function printFlush(target: BasicBuilding | undefined): void;
|
|
347
|
+
function printFlush(): void;
|
|
251
348
|
|
|
252
349
|
/**
|
|
253
|
-
* Writes the contents of the draw buffer into the target display
|
|
254
|
-
*
|
|
255
|
-
*
|
|
350
|
+
* Writes the contents of the draw buffer into the target display and clears
|
|
351
|
+
* the buffer afterwards.
|
|
352
|
+
*
|
|
353
|
+
* @param target The display building to write to. Writes to `display1` by
|
|
354
|
+
* default.
|
|
355
|
+
*
|
|
356
|
+
* Note that the default value only applies if you don't pass any parameter to
|
|
357
|
+
* this function.
|
|
358
|
+
*
|
|
359
|
+
* ```js
|
|
360
|
+
* const { display2 } = getBuildings();
|
|
361
|
+
* printFlush(display2);
|
|
256
362
|
*
|
|
257
|
-
*
|
|
363
|
+
* printFlush(); // defaults to display1
|
|
364
|
+
* ```
|
|
258
365
|
*/
|
|
259
|
-
function drawFlush(target
|
|
366
|
+
function drawFlush(target: BasicBuilding): void;
|
|
367
|
+
function drawFlush(): void;
|
|
260
368
|
|
|
261
369
|
/**
|
|
262
370
|
* Gets a block link by its index.
|
|
263
371
|
*
|
|
264
|
-
* To make safe queries it is recommended to check an index
|
|
265
|
-
*
|
|
266
|
-
* @param index
|
|
372
|
+
* To make safe queries it is recommended to check an index before trying to
|
|
373
|
+
* get a link. This can be done by using `Vars.links`.
|
|
267
374
|
*
|
|
268
375
|
* Example:
|
|
376
|
+
*
|
|
269
377
|
* ```js
|
|
270
|
-
*
|
|
271
|
-
* const
|
|
272
|
-
*
|
|
378
|
+
* for (let i = 0; i < Vars.links; i++) {
|
|
379
|
+
* const building = getLink(i);
|
|
380
|
+
* const { x, y } = building;
|
|
381
|
+
* print`${building}: (${x}, ${y})\n`;
|
|
273
382
|
* }
|
|
383
|
+
*
|
|
384
|
+
* printFlush();
|
|
274
385
|
* ```
|
|
275
386
|
*/
|
|
276
387
|
function getLink<T extends BasicBuilding = AnyBuilding>(index: number): T;
|
|
@@ -280,26 +391,30 @@ declare global {
|
|
|
280
391
|
/**
|
|
281
392
|
* Sets whether the building is enabled or disabled.
|
|
282
393
|
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
394
|
+
* ```js
|
|
395
|
+
* const { conveyor1 } = getBuildings();
|
|
396
|
+
*
|
|
397
|
+
* control.enabled(conveyor1, false);
|
|
398
|
+
* ```
|
|
287
399
|
*/
|
|
288
400
|
function enabled(building: BasicBuilding, value: boolean): void;
|
|
289
401
|
|
|
290
402
|
/**
|
|
291
403
|
* Makes the building shoot or aim at the given position
|
|
404
|
+
*
|
|
292
405
|
* @param options.building The shooting building
|
|
293
406
|
* @param options.shoot `true` to shoot, `false` to just aim at the position
|
|
294
407
|
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
408
|
+
* ```js
|
|
409
|
+
* const { cyclone1 } = getBuildings();
|
|
410
|
+
*
|
|
411
|
+
* control.shoot({
|
|
412
|
+
* building: cyclone1,
|
|
413
|
+
* shoot: true,
|
|
414
|
+
* x: Vars.thisx,
|
|
415
|
+
* y: Vars.thisy,
|
|
416
|
+
* });
|
|
417
|
+
* ```
|
|
303
418
|
*/
|
|
304
419
|
function shoot(options: {
|
|
305
420
|
/** The shooting building */
|
|
@@ -312,26 +427,27 @@ declare global {
|
|
|
312
427
|
|
|
313
428
|
/**
|
|
314
429
|
* Shoot at an unit with velocity prediction
|
|
430
|
+
*
|
|
315
431
|
* @param options.building The shooting building
|
|
316
432
|
* @param options.unit The target unit
|
|
317
433
|
* @param options.shoot `true` to shoot, `false` to just aim
|
|
318
434
|
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
435
|
+
* ```js
|
|
436
|
+
* const { cyclone1 } = getBuildings();
|
|
437
|
+
*
|
|
438
|
+
* const player = radar({
|
|
439
|
+
* building: cyclone1,
|
|
440
|
+
* filters: ["player", "any", "any"],
|
|
441
|
+
* order: true,
|
|
442
|
+
* sort: "distance",
|
|
443
|
+
* });
|
|
444
|
+
*
|
|
445
|
+
* control.shootp({
|
|
446
|
+
* building: cyclone1,
|
|
447
|
+
* unit: player,
|
|
448
|
+
* shoot: true,
|
|
449
|
+
* });
|
|
450
|
+
* ```
|
|
335
451
|
*/
|
|
336
452
|
function shootp(options: {
|
|
337
453
|
/** The shooting building */
|
|
@@ -343,46 +459,64 @@ declare global {
|
|
|
343
459
|
}): void;
|
|
344
460
|
|
|
345
461
|
/**
|
|
346
|
-
* Sets the config of a block (like the item of a sorter)
|
|
462
|
+
* Sets the config of a block (like the item of a sorter).
|
|
463
|
+
*
|
|
464
|
+
* In privileged (world) processors, this can also be used to:
|
|
347
465
|
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
466
|
+
* - Configure the target block of a mass driver.
|
|
467
|
+
* - Configure the target block of a bridge.
|
|
468
|
+
* - Toggle whether a block is connected to a power node.
|
|
350
469
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
470
|
+
* ```js
|
|
471
|
+
* const { sorter1, driver1, driver2, node1, factory1 } =
|
|
472
|
+
* getBuildings();
|
|
473
|
+
*
|
|
474
|
+
* control.config(sorter1, Items.copper);
|
|
475
|
+
* // World processor only:
|
|
476
|
+
* control.config(driver1, driver2);
|
|
477
|
+
* control.config(node1, factory1);
|
|
478
|
+
* ```
|
|
353
479
|
*/
|
|
354
|
-
function config(
|
|
480
|
+
function config(
|
|
481
|
+
building: BasicBuilding,
|
|
482
|
+
value: symbol | BasicBuilding,
|
|
483
|
+
): void;
|
|
355
484
|
|
|
356
485
|
/**
|
|
357
486
|
* Sets the color of an illuminator.
|
|
358
487
|
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
488
|
+
* ```js
|
|
489
|
+
* const { illuminator1 } = getBuildings();
|
|
361
490
|
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
491
|
+
* control.color(illuminator1, packColor(0.2, 0.65, 1, 1));
|
|
492
|
+
* ```
|
|
364
493
|
*/
|
|
365
494
|
function color(building: BasicBuilding, rgbaData: number): void;
|
|
366
495
|
}
|
|
367
496
|
|
|
368
497
|
/**
|
|
369
498
|
* Detects an unit nearby this `building`.
|
|
499
|
+
*
|
|
370
500
|
* @param options.building The building used to detect potential targets
|
|
371
|
-
* @param options.filters The filters for selecting a target. Use "any" for
|
|
372
|
-
*
|
|
501
|
+
* @param options.filters The filters for selecting a target. Use "any" for
|
|
502
|
+
* any target.
|
|
503
|
+
* @param options.order `true` to get the first result, `false` to get the
|
|
504
|
+
* last result.
|
|
373
505
|
* @param options.sort The method on which the results should be sorted
|
|
374
506
|
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
507
|
+
* Example:
|
|
508
|
+
*
|
|
509
|
+
* ```js
|
|
510
|
+
* const { cyclone1 } = getBuildings();
|
|
511
|
+
*
|
|
512
|
+
* // returns the furthest enemy unit
|
|
513
|
+
* const result = radar({
|
|
514
|
+
* building: cyclone1,
|
|
515
|
+
* filters: ["enemy", "any", "any"],
|
|
516
|
+
* order: false,
|
|
517
|
+
* sort: "distance",
|
|
518
|
+
* });
|
|
519
|
+
* ```
|
|
386
520
|
*/
|
|
387
521
|
function radar<T extends BasicUnit = AnyUnit>(options: {
|
|
388
522
|
/** The building used to detect potential targets */
|
|
@@ -398,36 +532,54 @@ declare global {
|
|
|
398
532
|
/**
|
|
399
533
|
* Alternate way to access special properties on objects.
|
|
400
534
|
*
|
|
401
|
-
* This method allows you to use customly created symbols
|
|
402
|
-
*
|
|
535
|
+
* This method allows you to use customly created symbols and sensor them on
|
|
536
|
+
* buildings.
|
|
537
|
+
*
|
|
403
538
|
* @param property The property to be sensed on the building
|
|
404
539
|
* @param target The object that will be "sensed"
|
|
405
540
|
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
541
|
+
* Example:
|
|
542
|
+
*
|
|
543
|
+
* ```ts
|
|
544
|
+
* const myBuilding = getBuilding("container1");
|
|
409
545
|
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
546
|
+
* // typescript annotation, you can use jsdoc comments on
|
|
547
|
+
* // regular javascript
|
|
548
|
+
* const myCustomSymbol = getVar<symbol>("@custom-symbol"); // problably defined by a mod
|
|
549
|
+
* const result = sensor(myCustomSymbol, myBuilding);
|
|
550
|
+
* ```
|
|
415
551
|
*/
|
|
416
|
-
function sensor
|
|
552
|
+
function sensor(property: BasicBuilding, target: BasicBuilding): boolean;
|
|
553
|
+
function sensor<T>(
|
|
554
|
+
property: symbol,
|
|
555
|
+
target: BasicBuilding | BasicUnit | Bullet,
|
|
556
|
+
): T;
|
|
417
557
|
|
|
418
558
|
/**
|
|
419
|
-
* Stops the execution for the given amount of
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
559
|
+
* Stops the execution for the given amount of seconds
|
|
560
|
+
*
|
|
561
|
+
* ```js
|
|
562
|
+
* print("before");
|
|
563
|
+
* printFlush();
|
|
564
|
+
* wait(3.5);
|
|
565
|
+
* print("after");
|
|
566
|
+
* printFlush();
|
|
567
|
+
* ```
|
|
427
568
|
*/
|
|
428
569
|
function wait(seconds: number): void;
|
|
429
570
|
|
|
430
|
-
/**
|
|
571
|
+
/**
|
|
572
|
+
* Looks up content symbols by their index.
|
|
573
|
+
*
|
|
574
|
+
* For the inverse of this operation, you can sense the `id` of a symbol:
|
|
575
|
+
*
|
|
576
|
+
* ```js
|
|
577
|
+
* const { type } = getLink(0);
|
|
578
|
+
*
|
|
579
|
+
* print(type === lookup.block(type.id));
|
|
580
|
+
* printFlush(); // prints "1"
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
431
583
|
namespace lookup {
|
|
432
584
|
/**
|
|
433
585
|
* Looks up a block symbol by it's index on the content registry.
|
|
@@ -435,24 +587,37 @@ declare global {
|
|
|
435
587
|
* Use `Vars.blockCount` to check the maximum index allowed.
|
|
436
588
|
*
|
|
437
589
|
* Example:
|
|
590
|
+
*
|
|
438
591
|
* ```js
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
592
|
+
* const first = lookup.block(0);
|
|
593
|
+
* const last = lookup.block(Vars.blockCount - 1);
|
|
594
|
+
*
|
|
595
|
+
* print`
|
|
596
|
+
* first block type: ${first}
|
|
597
|
+
* last block type: ${last}`;
|
|
598
|
+
*
|
|
599
|
+
* printFlush();
|
|
442
600
|
* ```
|
|
443
601
|
*/
|
|
444
|
-
function block(index: number): BlockSymbol;
|
|
602
|
+
function block(index: number): BlockSymbol | undefined;
|
|
445
603
|
|
|
446
604
|
/**
|
|
447
605
|
* Looks up an unit symbol by it's index on the content registry.
|
|
448
606
|
*
|
|
449
|
-
*
|
|
607
|
+
* `index` must an integer that satisfies the following range `index <
|
|
608
|
+
* Vars.unitCount`
|
|
450
609
|
*
|
|
451
610
|
* Example:
|
|
611
|
+
*
|
|
452
612
|
* ```js
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
613
|
+
* const first = lookup.unit(0);
|
|
614
|
+
* const last = lookup.unit(Vars.unitCount - 1);
|
|
615
|
+
*
|
|
616
|
+
* print`
|
|
617
|
+
* first unit type: ${first}
|
|
618
|
+
* last unit type: ${last}`;
|
|
619
|
+
*
|
|
620
|
+
* printFlush();
|
|
456
621
|
* ```
|
|
457
622
|
*/
|
|
458
623
|
function unit(index: number): UnitSymbol | undefined;
|
|
@@ -463,10 +628,16 @@ declare global {
|
|
|
463
628
|
* Use `Vars.itemCount` to check the maximum index allowed.
|
|
464
629
|
*
|
|
465
630
|
* Example:
|
|
631
|
+
*
|
|
466
632
|
* ```js
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
633
|
+
* const first = lookup.item(0);
|
|
634
|
+
* const last = lookup.item(Vars.itemCount - 1);
|
|
635
|
+
*
|
|
636
|
+
* print`
|
|
637
|
+
* first item type: ${first}
|
|
638
|
+
* last item type: ${last}`;
|
|
639
|
+
*
|
|
640
|
+
* printFlush();
|
|
470
641
|
* ```
|
|
471
642
|
*/
|
|
472
643
|
function item(index: number): ItemSymbol | undefined;
|
|
@@ -477,13 +648,34 @@ declare global {
|
|
|
477
648
|
* Use `Vars.liquidCount` to check the maximum index allowed.
|
|
478
649
|
*
|
|
479
650
|
* Example:
|
|
651
|
+
*
|
|
480
652
|
* ```js
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
653
|
+
* const first = lookup.liquid(0);
|
|
654
|
+
* const last = lookup.liquid(Vars.liquidCount - 1);
|
|
655
|
+
*
|
|
656
|
+
* print`
|
|
657
|
+
* first liquid type: ${first}
|
|
658
|
+
* last liquid type: ${last}`;
|
|
659
|
+
*
|
|
660
|
+
* printFlush();
|
|
484
661
|
* ```
|
|
485
662
|
*/
|
|
486
663
|
function liquid(index: number): LiquidSymbol | undefined;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Looks up a team symbol by its index on the content registry.
|
|
667
|
+
*
|
|
668
|
+
* Example:
|
|
669
|
+
*
|
|
670
|
+
* ```js
|
|
671
|
+
* const first = lookup.team(0);
|
|
672
|
+
*
|
|
673
|
+
* print`first team type: ${first}`;
|
|
674
|
+
*
|
|
675
|
+
* printFlush();
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
function team(index: number): TeamSymbol | undefined;
|
|
487
679
|
}
|
|
488
680
|
|
|
489
681
|
/**
|
|
@@ -491,60 +683,106 @@ declare global {
|
|
|
491
683
|
*
|
|
492
684
|
* Each paremeter must range from `0` to `1`.
|
|
493
685
|
*
|
|
686
|
+
* ```js
|
|
687
|
+
* const colorData = packColor(0.1, 0.6, 0.8, 0.1);
|
|
494
688
|
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
* // world processor only
|
|
499
|
-
* // sets the color of the ambient light
|
|
500
|
-
* setRule.ambientLight(colorData);
|
|
689
|
+
* // world processor only
|
|
690
|
+
* // sets the color of the ambient light
|
|
691
|
+
* setRule.ambientLight(colorData);
|
|
501
692
|
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
693
|
+
* // set color of illuminator
|
|
694
|
+
* const { illuminator1 } = getBuildings();
|
|
695
|
+
* control.color(illuminator1, packColor(0.2, 0.65, 1, 1));
|
|
696
|
+
* ```
|
|
506
697
|
*/
|
|
507
698
|
function packColor(r: number, g: number, b: number, a: number): number;
|
|
508
699
|
|
|
700
|
+
/**
|
|
701
|
+
* Unpacks RGBA color information from a color.
|
|
702
|
+
*
|
|
703
|
+
* ```js
|
|
704
|
+
* const colorData = packColor(0.1, 0.6, 0.8, 0.1);
|
|
705
|
+
*
|
|
706
|
+
* const { r, g, b, a } = unpackColor(colorData);
|
|
707
|
+
*
|
|
708
|
+
* print`r: ${r}, g: ${g}, b: ${b}, a: ${a}`;
|
|
709
|
+
* printFlush();
|
|
710
|
+
* ```
|
|
711
|
+
*/
|
|
712
|
+
function unpackColor(color: number): {
|
|
713
|
+
r: number;
|
|
714
|
+
g: number;
|
|
715
|
+
b: number;
|
|
716
|
+
a: number;
|
|
717
|
+
};
|
|
718
|
+
|
|
509
719
|
/**
|
|
510
720
|
* Binds an unit to the this processor. The unit is accessible at `Vars.unit`.
|
|
511
721
|
*
|
|
512
|
-
* If an unit symbol is received, the processor will pick an
|
|
513
|
-
*
|
|
722
|
+
* If an unit symbol is received, the processor will pick an unit of the given
|
|
723
|
+
* type.
|
|
514
724
|
*
|
|
515
725
|
* If an unit object is received, the processor will bind to the unit.
|
|
516
726
|
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
727
|
+
* ```js
|
|
728
|
+
* unitBind(Units.flare);
|
|
519
729
|
*
|
|
520
|
-
*
|
|
730
|
+
* const { x, y } = Vars.unit;
|
|
521
731
|
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
732
|
+
* print`x: ${x} y: ${y}`;
|
|
733
|
+
* printFlush();
|
|
734
|
+
* ```
|
|
525
735
|
*/
|
|
526
736
|
function unitBind(unit: UnitSymbol | BasicUnit): void;
|
|
527
737
|
|
|
528
738
|
namespace unitControl {
|
|
529
739
|
/**
|
|
530
|
-
* Makes the unit bound to this processor stop moving but
|
|
531
|
-
*
|
|
740
|
+
* Makes the unit bound to this processor stop moving but allows it to keep
|
|
741
|
+
* doing it's action (like mining or building)
|
|
742
|
+
*
|
|
743
|
+
* ```js
|
|
744
|
+
* unitControl.idle();
|
|
745
|
+
* ```
|
|
532
746
|
*/
|
|
533
747
|
function idle(): void;
|
|
534
748
|
|
|
535
749
|
/**
|
|
536
750
|
* Makes the unit bound to this processor stop mining, building and moving
|
|
751
|
+
*
|
|
752
|
+
* ```js
|
|
753
|
+
* unitControl.stop();
|
|
754
|
+
* ```
|
|
537
755
|
*/
|
|
538
756
|
function stop(): void;
|
|
539
757
|
|
|
540
758
|
/**
|
|
541
|
-
* Makes the unit bound to this processor move to the given position
|
|
759
|
+
* Makes the unit bound to this processor move to the given position.
|
|
760
|
+
*
|
|
761
|
+
* The unit tends to move in a straight line to the target location, which
|
|
762
|
+
* doesn't work in situations where the unit encounters an obstacle (such as
|
|
763
|
+
* a dagger trying to get past a wall).
|
|
764
|
+
*
|
|
765
|
+
* For those scenarios it's better to use `unitControl.pathfind`.
|
|
766
|
+
*
|
|
767
|
+
* ```js
|
|
768
|
+
* unitControl.move(10, 20);
|
|
769
|
+
* ```
|
|
542
770
|
*/
|
|
543
771
|
function move(x: number, y: number): void;
|
|
544
772
|
|
|
545
773
|
/**
|
|
546
|
-
* Makes the unit bound to this processor approach the given position at the
|
|
774
|
+
* Makes the unit bound to this processor approach the given position at the
|
|
775
|
+
* given radius
|
|
776
|
+
*
|
|
547
777
|
* @param options.radius How distant to the position the unit can be
|
|
778
|
+
*
|
|
779
|
+
* ```js
|
|
780
|
+
* unitControl.approach({
|
|
781
|
+
* x: 15,
|
|
782
|
+
* y: 30,
|
|
783
|
+
* radius: 5,
|
|
784
|
+
* });
|
|
785
|
+
* ```
|
|
548
786
|
*/
|
|
549
787
|
function approach(options: {
|
|
550
788
|
x: number;
|
|
@@ -554,20 +792,62 @@ declare global {
|
|
|
554
792
|
}): void;
|
|
555
793
|
|
|
556
794
|
/**
|
|
557
|
-
*
|
|
795
|
+
* Makes the unit bound to this processor move to the given location.
|
|
796
|
+
*
|
|
797
|
+
* Uses the unit's pathfinding algorithm to decide how to reach the desired
|
|
798
|
+
* location instead of blidly going in a straight line.
|
|
799
|
+
*
|
|
800
|
+
* ```js
|
|
801
|
+
* // makes flares follow the player's cursor
|
|
802
|
+
* const { foreshadow1 } = getBuildings();
|
|
803
|
+
*
|
|
804
|
+
* const player = radar({
|
|
805
|
+
* building: foreshadow1,
|
|
806
|
+
* filters: ["player", "any", "any"],
|
|
807
|
+
* order: true,
|
|
808
|
+
* sort: "distance",
|
|
809
|
+
* });
|
|
810
|
+
*
|
|
811
|
+
* unitBind(Units.flare);
|
|
812
|
+
*
|
|
813
|
+
* unitControl.pathfind(player.shootX, player.shootY);
|
|
814
|
+
* ```
|
|
558
815
|
*/
|
|
559
|
-
function
|
|
816
|
+
function pathfind(x: number, y: number): void;
|
|
560
817
|
|
|
561
818
|
/**
|
|
562
|
-
* Makes the unit bound to this processor
|
|
819
|
+
* Makes the unit bound to this processor automatically pathfind to the
|
|
820
|
+
* nearest enemy core or drop point.
|
|
563
821
|
*
|
|
564
|
-
*
|
|
822
|
+
* Is the same as standard wave enemy pathfinding.
|
|
823
|
+
*
|
|
824
|
+
* ```js
|
|
825
|
+
* unitControl.autoPathfind();
|
|
826
|
+
* ```
|
|
565
827
|
*/
|
|
566
|
-
function
|
|
828
|
+
function autoPathfind(): void;
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Whether the unit bound to this processor should be boosted (floating)
|
|
832
|
+
*
|
|
833
|
+
* ```js
|
|
834
|
+
* unitControl.boost(true);
|
|
835
|
+
* ```
|
|
836
|
+
*/
|
|
837
|
+
function boost(enable: boolean): void;
|
|
567
838
|
|
|
568
839
|
/**
|
|
569
840
|
* Makes the unit bound to this processor shoot/aim at the given position
|
|
841
|
+
*
|
|
570
842
|
* @param options.shoot `true` to shoot, `false` to just aim
|
|
843
|
+
*
|
|
844
|
+
* ```js
|
|
845
|
+
* unitControl.target({
|
|
846
|
+
* x: 15,
|
|
847
|
+
* y: 30,
|
|
848
|
+
* shoot: true,
|
|
849
|
+
* });
|
|
850
|
+
* ```
|
|
571
851
|
*/
|
|
572
852
|
function target(options: {
|
|
573
853
|
x: number;
|
|
@@ -577,22 +857,26 @@ declare global {
|
|
|
577
857
|
}): void;
|
|
578
858
|
|
|
579
859
|
/**
|
|
580
|
-
* Makes the unit bound to this processor target an unit with velocity
|
|
860
|
+
* Makes the unit bound to this processor target an unit with velocity
|
|
861
|
+
* prediction
|
|
862
|
+
*
|
|
581
863
|
* @param options.unit The shoot target
|
|
582
864
|
* @param options.shoot `true` to shoot, `false` to just aim
|
|
583
865
|
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
866
|
+
* ```js
|
|
867
|
+
* unitBind(Units.flare);
|
|
868
|
+
*
|
|
869
|
+
* const player = unitRadar({
|
|
870
|
+
* filters: ["player", "any", "any"],
|
|
871
|
+
* order: true,
|
|
872
|
+
* sort: "distance",
|
|
873
|
+
* });
|
|
874
|
+
*
|
|
875
|
+
* unitControl.targetp({
|
|
876
|
+
* unit: player,
|
|
877
|
+
* shoot: true,
|
|
878
|
+
* });
|
|
879
|
+
* ```
|
|
596
880
|
*/
|
|
597
881
|
function targetp(options: {
|
|
598
882
|
/** The shoot target */
|
|
@@ -602,59 +886,94 @@ declare global {
|
|
|
602
886
|
}): void;
|
|
603
887
|
|
|
604
888
|
/**
|
|
605
|
-
* Makes the unit bound to this processor drop it's held items onto the
|
|
606
|
-
*
|
|
889
|
+
* Makes the unit bound to this processor drop it's held items onto the
|
|
890
|
+
* given target
|
|
891
|
+
*
|
|
892
|
+
* Using this command sets the unit's action timeout.
|
|
893
|
+
*
|
|
894
|
+
* This command will be on cooldown for 1.5 seconds after the timeout has
|
|
895
|
+
* been set.
|
|
896
|
+
*
|
|
897
|
+
* @param target Where to drop the items, if `Blocks.air`, the unit will
|
|
898
|
+
* throw it's items away
|
|
607
899
|
* @param amount How many items should be dropped
|
|
608
900
|
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
901
|
+
* ```js
|
|
902
|
+
* const { container1 } = getBuildings();
|
|
611
903
|
*
|
|
612
|
-
*
|
|
904
|
+
* // ...
|
|
613
905
|
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
906
|
+
* // drop 40 items on the container
|
|
907
|
+
* unitControl.itemDrop(container1, 40);
|
|
616
908
|
*
|
|
617
|
-
*
|
|
909
|
+
* // ...
|
|
618
910
|
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
911
|
+
* // discard 10 items from the current unit
|
|
912
|
+
* unitControl.itemDrop(Blocks.air, 10);
|
|
913
|
+
* ```
|
|
622
914
|
*/
|
|
623
915
|
function itemDrop(
|
|
624
916
|
target: BasicBuilding | typeof Blocks.air,
|
|
625
|
-
amount: number
|
|
917
|
+
amount: number,
|
|
626
918
|
): void;
|
|
627
919
|
|
|
628
920
|
/**
|
|
629
921
|
* Makes the unit bound to this processor take items from a building
|
|
922
|
+
*
|
|
923
|
+
* Using this command sets the unit's action timeout.
|
|
924
|
+
*
|
|
925
|
+
* This command will be on cooldown for 1.5 seconds after the timeout has
|
|
926
|
+
* been set.
|
|
927
|
+
*
|
|
630
928
|
* @param target The building that will have it's items taken
|
|
631
929
|
* @param item The kind of item to take
|
|
632
930
|
* @param amount How many items should be taken
|
|
633
931
|
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
932
|
+
* ```js
|
|
933
|
+
* const { vault1 } = getBuildings();
|
|
636
934
|
*
|
|
637
|
-
*
|
|
935
|
+
* // bind unit and move to the valult...
|
|
638
936
|
*
|
|
639
|
-
*
|
|
937
|
+
* unitControl.itemTake(vault1, Items.graphite, 50);
|
|
640
938
|
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
939
|
+
* // do something with the graphite...
|
|
940
|
+
* ```
|
|
643
941
|
*/
|
|
644
942
|
function itemTake(
|
|
645
943
|
target: BasicBuilding,
|
|
646
944
|
item: ItemSymbol,
|
|
647
|
-
amount: number
|
|
945
|
+
amount: number,
|
|
648
946
|
): void;
|
|
649
947
|
|
|
650
948
|
/**
|
|
651
949
|
* Makes the unit bound to this processor drop one entity from it's payload
|
|
950
|
+
*
|
|
951
|
+
* Using this command sets the unit's action timeout.
|
|
952
|
+
*
|
|
953
|
+
* This command will be on cooldown for 1.5 seconds after the timeout has
|
|
954
|
+
* been set.
|
|
955
|
+
*
|
|
956
|
+
* ```js
|
|
957
|
+
* unitControl.payDrop();
|
|
958
|
+
* ```
|
|
652
959
|
*/
|
|
653
960
|
function payDrop(): void;
|
|
654
961
|
|
|
655
962
|
/**
|
|
656
963
|
* Makes the unit bound to this processor take an entity into it's payload
|
|
964
|
+
*
|
|
965
|
+
* Using this command sets the unit's action timeout.
|
|
966
|
+
*
|
|
967
|
+
* This command will be on cooldown for 1.5 seconds after the timeout has
|
|
968
|
+
* been set.
|
|
969
|
+
*
|
|
657
970
|
* @param options.takeUnits Whether to take units or buildings
|
|
971
|
+
*
|
|
972
|
+
* ```js
|
|
973
|
+
* unitControl.payTake({
|
|
974
|
+
* takeUnits: true,
|
|
975
|
+
* });
|
|
976
|
+
* ```
|
|
658
977
|
*/
|
|
659
978
|
function payTake(options: {
|
|
660
979
|
/** Whether to take units or buildings */
|
|
@@ -662,37 +981,54 @@ declare global {
|
|
|
662
981
|
}): void;
|
|
663
982
|
|
|
664
983
|
/**
|
|
665
|
-
* Makes the unit bound to this processor enter/land on the
|
|
666
|
-
*
|
|
984
|
+
* Makes the unit bound to this processor enter/land on the payload block
|
|
985
|
+
* the unit is on
|
|
986
|
+
*
|
|
987
|
+
* ```js
|
|
988
|
+
* unitControl.payEnter();
|
|
989
|
+
* ```
|
|
667
990
|
*/
|
|
668
991
|
function payEnter(): void;
|
|
669
992
|
|
|
670
993
|
/**
|
|
671
994
|
* Makes the unit bound to this processor mine at the given position
|
|
995
|
+
*
|
|
996
|
+
* ```js
|
|
997
|
+
* unitControl.mine(10, 20);
|
|
998
|
+
* ```
|
|
672
999
|
*/
|
|
673
1000
|
function mine(x: number, y: number): void;
|
|
674
1001
|
|
|
675
1002
|
/**
|
|
676
1003
|
* Sets the numeric flag of the unit bound to this processor
|
|
1004
|
+
*
|
|
1005
|
+
* ```js
|
|
1006
|
+
* // a unique id based on the coordinates of this processor
|
|
1007
|
+
* const processorId = Vars.thisx * Vars.mapw + Vars.thisy;
|
|
1008
|
+
*
|
|
1009
|
+
* unitControl.flag(processorId);
|
|
1010
|
+
* ```
|
|
677
1011
|
*/
|
|
678
1012
|
function flag(value: number): void;
|
|
679
1013
|
|
|
680
1014
|
/**
|
|
681
|
-
* Makes the unit bound to this processor build a building with the
|
|
682
|
-
*
|
|
1015
|
+
* Makes the unit bound to this processor build a building with the given
|
|
1016
|
+
* properties
|
|
1017
|
+
*
|
|
683
1018
|
* @param options.block The kind of building to build
|
|
684
1019
|
* @param options.rotation The rotation of the building, ranges from 0 to 3
|
|
685
|
-
* @param options.config The
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
1020
|
+
* @param options.config The configuration value to use, or a building from
|
|
1021
|
+
* which the configuration value will be copied.
|
|
1022
|
+
*
|
|
1023
|
+
* ```js
|
|
1024
|
+
* unitControl.build({
|
|
1025
|
+
* x: 10,
|
|
1026
|
+
* y: 20,
|
|
1027
|
+
* block: Blocks.sorter,
|
|
1028
|
+
* rotation: 1,
|
|
1029
|
+
* config: Items.silicon,
|
|
1030
|
+
* });
|
|
1031
|
+
* ```
|
|
696
1032
|
*/
|
|
697
1033
|
function build(options: {
|
|
698
1034
|
x: number;
|
|
@@ -701,51 +1037,116 @@ declare global {
|
|
|
701
1037
|
block: BuildingSymbol;
|
|
702
1038
|
/** The rotation of the building, ranges from 0 to 3 */
|
|
703
1039
|
rotation: number;
|
|
704
|
-
/**
|
|
705
|
-
|
|
1040
|
+
/**
|
|
1041
|
+
* The configuration value to use, or a building from which the
|
|
1042
|
+
* configuration value will be copied.
|
|
1043
|
+
*/
|
|
1044
|
+
config?: symbol | BasicBuilding;
|
|
706
1045
|
}): void;
|
|
707
1046
|
|
|
708
1047
|
/**
|
|
709
|
-
* Makes the unit bound to this processor
|
|
1048
|
+
* Makes the unit bound to this processor deconstruct the building at the
|
|
1049
|
+
* given position.
|
|
1050
|
+
*
|
|
1051
|
+
* ```js
|
|
1052
|
+
* unitControl.deconstruct(10, 20);
|
|
1053
|
+
* ```
|
|
1054
|
+
*/
|
|
1055
|
+
function deconstruct(x: number, y: number): void;
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Makes the unit bound to this processor get data about a block at the
|
|
1059
|
+
* given position.
|
|
1060
|
+
*
|
|
1061
|
+
* ```js
|
|
1062
|
+
* // prints info about the block the player is pointing at
|
|
1063
|
+
* unitBind(Units.flare);
|
|
1064
|
+
*
|
|
1065
|
+
* const player = unitRadar({
|
|
1066
|
+
* filters: ["player", "any", "any"],
|
|
1067
|
+
* sort: "distance",
|
|
1068
|
+
* order: true,
|
|
1069
|
+
* });
|
|
1070
|
+
*
|
|
1071
|
+
* const { shootX, shootY } = player;
|
|
1072
|
+
* const [type, building, floor] = unitControl.getBlock(shootX, shootY);
|
|
1073
|
+
*
|
|
1074
|
+
* print`
|
|
1075
|
+
* block: ${type}
|
|
1076
|
+
* floor: ${floor}
|
|
1077
|
+
* size: ${building.size ?? 1}
|
|
1078
|
+
* `;
|
|
1079
|
+
* printFlush();
|
|
1080
|
+
* ```
|
|
710
1081
|
*/
|
|
711
1082
|
function getBlock<T extends BasicBuilding = AnyBuilding>(
|
|
712
1083
|
x: number,
|
|
713
|
-
y: number
|
|
1084
|
+
y: number,
|
|
714
1085
|
): [
|
|
715
1086
|
type: BlockSymbol | undefined,
|
|
716
1087
|
building: T | undefined,
|
|
717
|
-
floor: EnvBlockSymbol | OreSymbol | undefined
|
|
1088
|
+
floor: EnvBlockSymbol | OreSymbol | undefined,
|
|
718
1089
|
];
|
|
719
1090
|
|
|
720
1091
|
/**
|
|
721
|
-
* Checks if the unit bound to this processor is within a radius of a given
|
|
1092
|
+
* Checks if the unit bound to this processor is within a radius of a given
|
|
1093
|
+
* position.
|
|
1094
|
+
*
|
|
1095
|
+
* ```js
|
|
1096
|
+
* if (Vars.unit == undefined) {
|
|
1097
|
+
* unitBind(Units.flare);
|
|
1098
|
+
* }
|
|
1099
|
+
*
|
|
1100
|
+
* const player = unitRadar({
|
|
1101
|
+
* filters: ["player", "any", "any"],
|
|
1102
|
+
* sort: "distance",
|
|
1103
|
+
* order: true,
|
|
1104
|
+
* });
|
|
1105
|
+
*
|
|
1106
|
+
* const nearby = unitControl.within({
|
|
1107
|
+
* x: player.x,
|
|
1108
|
+
* y: player.y,
|
|
1109
|
+
* radius: 5,
|
|
1110
|
+
* });
|
|
1111
|
+
*
|
|
1112
|
+
* print`nearby: ${nearby}`;
|
|
1113
|
+
* printFlush();
|
|
1114
|
+
* ```
|
|
722
1115
|
*/
|
|
723
1116
|
function within(options: { x: number; y: number; radius: number }): boolean;
|
|
724
1117
|
|
|
725
1118
|
/**
|
|
726
1119
|
* Resets the AI of the unit.
|
|
727
1120
|
*
|
|
728
|
-
* Calling `unbind` does not actually unbind the unit from the processor,
|
|
729
|
-
*
|
|
1121
|
+
* Calling `unbind` does not actually unbind the unit from the processor, it
|
|
1122
|
+
* just makes the unit resume its natural behavior.
|
|
1123
|
+
*
|
|
1124
|
+
* ```js
|
|
1125
|
+
* unitControl.unbind();
|
|
1126
|
+
* ```
|
|
730
1127
|
*/
|
|
731
1128
|
function unbind(): void;
|
|
732
1129
|
}
|
|
733
1130
|
|
|
734
1131
|
/**
|
|
735
1132
|
* Finds an unit near the unit bound to this processor
|
|
736
|
-
*
|
|
737
|
-
* @param options.
|
|
1133
|
+
*
|
|
1134
|
+
* @param options.filters The filters for selecting a target. Use "any" for
|
|
1135
|
+
* any target.
|
|
1136
|
+
* @param options.order `true` to get the first result, `false` to get the
|
|
1137
|
+
* last result.
|
|
738
1138
|
* @param options.sort The method on which the results should be sorted
|
|
739
1139
|
*
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
1140
|
+
* Example:
|
|
1141
|
+
*
|
|
1142
|
+
* ```js
|
|
1143
|
+
* // returns the furthest enemy unit
|
|
1144
|
+
* const result = unitRadar({
|
|
1145
|
+
* filters: ["enemy", "any", "any"],
|
|
1146
|
+
* order: false,
|
|
1147
|
+
* sort: "distance",
|
|
1148
|
+
* });
|
|
1149
|
+
* ```
|
|
749
1150
|
*/
|
|
750
1151
|
function unitRadar<T extends BasicUnit = AnyUnit>(options: {
|
|
751
1152
|
/** The filters for selecting a target. Use "any" for any target. */
|
|
@@ -759,61 +1160,66 @@ declare global {
|
|
|
759
1160
|
/** Uses the unit bound to this processor to find specific types of blocks */
|
|
760
1161
|
namespace unitLocate {
|
|
761
1162
|
/**
|
|
762
|
-
* Uses the unit bound to this processor to find an ore vein anywhere on the
|
|
1163
|
+
* Uses the unit bound to this processor to find an ore vein anywhere on the
|
|
1164
|
+
* map
|
|
1165
|
+
*
|
|
763
1166
|
* @param ore The kind of item the ore should contain
|
|
764
1167
|
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
1168
|
+
* ```js
|
|
1169
|
+
* const [found, x, y] = unitLocate.ore(Items.copper);
|
|
767
1170
|
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
1171
|
+
* if (found) {
|
|
1172
|
+
* unitControl.approach({ x, y, radius: 5 });
|
|
1173
|
+
* }
|
|
1174
|
+
* ```
|
|
772
1175
|
*/
|
|
773
1176
|
function ore(
|
|
774
|
-
ore: ItemSymbol
|
|
1177
|
+
ore: ItemSymbol,
|
|
775
1178
|
): [found: false] | [found: true, x: number, y: number];
|
|
776
1179
|
|
|
777
1180
|
/**
|
|
778
|
-
* Uses the unit bound to this processor to find a building anywhere on the
|
|
1181
|
+
* Uses the unit bound to this processor to find a building anywhere on the
|
|
1182
|
+
* map
|
|
1183
|
+
*
|
|
779
1184
|
* @param options.group The group that the building belongs to
|
|
780
|
-
* @param options.enemy Whether it should be an enemy building or an ally
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
*
|
|
809
|
-
*
|
|
810
|
-
*
|
|
811
|
-
*
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
*
|
|
1185
|
+
* @param options.enemy Whether it should be an enemy building or an ally
|
|
1186
|
+
* one
|
|
1187
|
+
*
|
|
1188
|
+
* ```js
|
|
1189
|
+
* const vault = getBuilding("vault1");
|
|
1190
|
+
* const takeAmount = 100;
|
|
1191
|
+
*
|
|
1192
|
+
* unitBind(Units.mega);
|
|
1193
|
+
*
|
|
1194
|
+
* // we don't use the `found` variable
|
|
1195
|
+
* // because we always have our own core
|
|
1196
|
+
* const [, x, y, core] = unitLocate.building({
|
|
1197
|
+
* group: "core",
|
|
1198
|
+
* enemy: false,
|
|
1199
|
+
* });
|
|
1200
|
+
*
|
|
1201
|
+
* const location = {
|
|
1202
|
+
* x,
|
|
1203
|
+
* y,
|
|
1204
|
+
* radius: 5,
|
|
1205
|
+
* };
|
|
1206
|
+
*
|
|
1207
|
+
* if (!unitControl.within(location) && Vars.unit.totalItems == 0) {
|
|
1208
|
+
* // if the unit has no items and it is not near
|
|
1209
|
+
* // the core, move it to the core
|
|
1210
|
+
* // and take 100 copper
|
|
1211
|
+
* unitControl.approach(location);
|
|
1212
|
+
* unitControl.itemTake(core, Items.copper, takeAmount);
|
|
1213
|
+
* } else {
|
|
1214
|
+
* // else, approach the vault and drop the items on it
|
|
1215
|
+
* unitControl.approach({
|
|
1216
|
+
* x: vault.x,
|
|
1217
|
+
* y: vault.y,
|
|
1218
|
+
* radius: 5,
|
|
1219
|
+
* });
|
|
1220
|
+
* unitControl.itemDrop(vault, takeAmount);
|
|
1221
|
+
* }
|
|
1222
|
+
* ```
|
|
817
1223
|
*/
|
|
818
1224
|
function building<T extends BasicBuilding = AnyBuilding>(options: {
|
|
819
1225
|
/** The group that the building belongs to */
|
|
@@ -823,436 +1229,76 @@ declare global {
|
|
|
823
1229
|
}): [found: false] | [found: true, x: number, y: number, building: T];
|
|
824
1230
|
|
|
825
1231
|
/**
|
|
826
|
-
* Uses the unit bound to this processor to find an enemy spawn anywhere on
|
|
1232
|
+
* Uses the unit bound to this processor to find an enemy spawn anywhere on
|
|
1233
|
+
* the map.
|
|
827
1234
|
*
|
|
828
1235
|
* Returns the enemy spawn point or its core, if it exists.
|
|
829
1236
|
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
*
|
|
838
|
-
*
|
|
839
|
-
*
|
|
1237
|
+
* ```js
|
|
1238
|
+
* const [found, x, y, core] = unitLocate.spawn();
|
|
1239
|
+
*
|
|
1240
|
+
* if (!found) {
|
|
1241
|
+
* print("No enemy core found");
|
|
1242
|
+
* } else if (core) {
|
|
1243
|
+
* print`core location at (${x}, ${y})`;
|
|
1244
|
+
* } else {
|
|
1245
|
+
* print`enemy spawn at (${x}, ${y})`;
|
|
1246
|
+
* }
|
|
840
1247
|
*
|
|
841
|
-
*
|
|
842
|
-
*
|
|
1248
|
+
* printFlush();
|
|
1249
|
+
* ```
|
|
843
1250
|
*/
|
|
844
1251
|
function spawn<T extends BasicBuilding = AnyBuilding>():
|
|
845
|
-
| [found:
|
|
846
|
-
| [found: true, x: number, y: number, building: T];
|
|
1252
|
+
[found: false] | [found: true, x: number, y: number, building: T];
|
|
847
1253
|
|
|
848
1254
|
/**
|
|
849
|
-
* Uses the unit bound to this processor to find a damaged ally building
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
*
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
*
|
|
860
|
-
*
|
|
1255
|
+
* Uses the unit bound to this processor to find a damaged ally building
|
|
1256
|
+
* anywhere on the map
|
|
1257
|
+
*
|
|
1258
|
+
* ```js
|
|
1259
|
+
* const [found, x, y, building] = unitLocate.damaged();
|
|
1260
|
+
*
|
|
1261
|
+
* if (found) {
|
|
1262
|
+
* print`go fix a ${building} at (${x}, ${y})`;
|
|
1263
|
+
* } else {
|
|
1264
|
+
* print("No damaged building found");
|
|
1265
|
+
* }
|
|
1266
|
+
* printFlush();
|
|
1267
|
+
* ```
|
|
861
1268
|
*/
|
|
862
1269
|
function damaged<T extends BasicBuilding = AnyBuilding>():
|
|
863
|
-
| [found:
|
|
864
|
-
| [found: true, x: number, y: number, building: T];
|
|
1270
|
+
[found: false] | [found: true, x: number, y: number, building: T];
|
|
865
1271
|
}
|
|
866
1272
|
|
|
867
1273
|
/**
|
|
868
1274
|
* Jumps to the top of the instruction stack.
|
|
869
1275
|
*
|
|
870
|
-
*
|
|
871
|
-
*
|
|
1276
|
+
* ```js
|
|
1277
|
+
* const { switch1 } = getBuildings();
|
|
872
1278
|
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
1279
|
+
* if (!switch1.enabled) endScript();
|
|
1280
|
+
* // do something when the switch is enabled
|
|
1281
|
+
* ```
|
|
876
1282
|
*/
|
|
877
1283
|
function endScript(): never;
|
|
878
1284
|
|
|
879
1285
|
/**
|
|
880
|
-
* Halts the execution of this processor. Can be used to debug
|
|
881
|
-
*
|
|
1286
|
+
* Halts the execution of this processor. Can be used to debug code and
|
|
1287
|
+
* analyze the processor registers.
|
|
882
1288
|
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
*
|
|
1289
|
+
* ```js
|
|
1290
|
+
* // stop the processor to debug variables
|
|
1291
|
+
* stopScript();
|
|
1292
|
+
* ```
|
|
887
1293
|
*/
|
|
888
1294
|
function stopScript(): never;
|
|
889
1295
|
|
|
890
|
-
/** Gets block data from the map. Available ONLY for world processors. */
|
|
891
|
-
namespace getBlock {
|
|
892
|
-
/** Gets the floor type on the given location */
|
|
893
|
-
function floor(x: number, y: number): EnvBlockSymbol;
|
|
894
|
-
|
|
895
|
-
/** Gets the ore type on the given location. `Blocks.air` if there is no ore */
|
|
896
|
-
function ore(x: number, y: number): OreSymbol | typeof Blocks.air;
|
|
897
|
-
|
|
898
|
-
/** Gets the block type on the give location. `Blocks.air` if there is no block. */
|
|
899
|
-
function block(x: number, y: number): BlockSymbol;
|
|
900
|
-
|
|
901
|
-
/** Gets the building on the given location. `undefined` if there is no building. */
|
|
902
|
-
function building<T extends BasicBuilding = AnyBuilding>(
|
|
903
|
-
x: number,
|
|
904
|
-
y: number
|
|
905
|
-
): T | undefined;
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
/** Sets block data on a given location. World processor ONLY. */
|
|
909
|
-
namespace setBlock {
|
|
910
|
-
// TODO: maybe have a separate floor symbol type?
|
|
911
|
-
/** Sets the floor of the tile at the given location. */
|
|
912
|
-
function floor(x: number, y: number, to: EnvBlockSymbol): void;
|
|
913
|
-
|
|
914
|
-
/** Sets the ore at the given location. Use `Blocks.air` to remove any ore. */
|
|
915
|
-
function ore(x: number, y: number, to: OreSymbol | typeof Blocks.air): void;
|
|
916
|
-
|
|
917
|
-
/** Sets the block at a given location, it can be a regular building or an environment block. */
|
|
918
|
-
function block(options: {
|
|
919
|
-
x: number;
|
|
920
|
-
y: number;
|
|
921
|
-
to: EnvBlockSymbol | BuildingSymbol;
|
|
922
|
-
team: TeamSymbol;
|
|
923
|
-
rotation: number;
|
|
924
|
-
}): void;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
1296
|
/**
|
|
928
|
-
*
|
|
929
|
-
*
|
|
930
|
-
* @param options.rotation The initial rotation of the unit in degrees.
|
|
931
|
-
*/
|
|
932
|
-
function spawnUnit<T extends BasicUnit = AnyUnit>(options: {
|
|
933
|
-
type: UnitSymbol;
|
|
934
|
-
x: number;
|
|
935
|
-
y: number;
|
|
936
|
-
team: TeamSymbol;
|
|
937
|
-
/** The initial rotation of the unit in degrees. */
|
|
938
|
-
rotation?: number;
|
|
939
|
-
}): T;
|
|
940
|
-
|
|
941
|
-
/** Contains the variants for the `applyStatus` instruction. World processor ONLY. */
|
|
942
|
-
namespace applyStatus {
|
|
943
|
-
/**
|
|
944
|
-
* Applies a status effect to the given unit.
|
|
945
|
-
*
|
|
946
|
-
* The only status effects that don't require a duration are `overdrive` and `boss`.
|
|
947
|
-
*/
|
|
948
|
-
function apply(
|
|
949
|
-
status: Exclude<TUnitEffect, "overdrive" | "boss">,
|
|
950
|
-
unit: BasicUnit,
|
|
951
|
-
duration: number
|
|
952
|
-
): void;
|
|
953
|
-
|
|
954
|
-
function apply(status: "overdrive" | "boss", unit: BasicUnit): void;
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Removes a status effect to the given unit.
|
|
958
|
-
*/
|
|
959
|
-
function clear(status: TUnitEffect, unit: BasicUnit): void;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
/**
|
|
963
|
-
* Spawns an enemy wave, can be used even if there is an already active wave.
|
|
964
|
-
*
|
|
965
|
-
* World processor ONLY.
|
|
966
|
-
*/
|
|
967
|
-
function spawnWave(natural: true): void;
|
|
968
|
-
function spawnWave(natural: false, x: number, y: number): void;
|
|
969
|
-
|
|
970
|
-
/** Contains the multiple variants of the `set rule` instruction. World processor ONLY. */
|
|
971
|
-
namespace setRule {
|
|
972
|
-
/** Sets the wave countdown in seconds. */
|
|
973
|
-
function currentWaveTime(seconds: number): void;
|
|
974
|
-
|
|
975
|
-
/** Enables/disables the wave timer. */
|
|
976
|
-
function waveTimer(enabled: boolean): void;
|
|
977
|
-
|
|
978
|
-
/** Allows or prevents waves from spawning. */
|
|
979
|
-
function waves(enabled: boolean): void;
|
|
980
|
-
|
|
981
|
-
/** Sets the current wave number. */
|
|
982
|
-
function wave(number: number): void;
|
|
983
|
-
|
|
984
|
-
/** Sets the time between waves in seconds. */
|
|
985
|
-
function waveSpacing(seconds: number): void;
|
|
986
|
-
|
|
987
|
-
/** Sets wether waves can be manually summoned by pressing the play button. */
|
|
988
|
-
function waveSending(enabled: boolean): void;
|
|
989
|
-
|
|
990
|
-
/** Sets wether the gamemode is the attack mode */
|
|
991
|
-
function attackMode(enabled: boolean): void;
|
|
992
|
-
|
|
993
|
-
/** Sets the radius of the no-build zone around enemy cores. */
|
|
994
|
-
function enemyCoreBuildRadius(radius: number): void;
|
|
995
|
-
|
|
996
|
-
/** Sets the radius around enemy wave drop zones. */
|
|
997
|
-
function dropZoneRadius(radius: number): void;
|
|
998
|
-
|
|
999
|
-
/** Sets the base unit cap. */
|
|
1000
|
-
function unitCap(cap: number): void;
|
|
1001
|
-
|
|
1002
|
-
/** Sets the playable map area. Blocks that are out of the new bounds will be removed. */
|
|
1003
|
-
function mapArea(options: {
|
|
1004
|
-
x: number;
|
|
1005
|
-
y: number;
|
|
1006
|
-
width: number;
|
|
1007
|
-
height: number;
|
|
1008
|
-
}): void;
|
|
1009
|
-
|
|
1010
|
-
/** Sets wether ambient lighting is enabled */
|
|
1011
|
-
function lighting(enabled: boolean): void;
|
|
1012
|
-
|
|
1013
|
-
/**
|
|
1014
|
-
* Sets the ambient light color.
|
|
1015
|
-
*
|
|
1016
|
-
* `packColor` can be used to get the rgba data recevied by this function.
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
* ```js
|
|
1020
|
-
* // enables lighting and sets the color to gray
|
|
1021
|
-
* setRule.lighting(true);
|
|
1022
|
-
* setRule.ambientLight(packColor(0.5, 0.5, 0.5, 1));
|
|
1023
|
-
* ```
|
|
1024
|
-
*/
|
|
1025
|
-
function ambientLight(rgbaData: number): void;
|
|
1026
|
-
|
|
1027
|
-
/** Sets the multiplier for the energy output of solar panels. */
|
|
1028
|
-
function solarMultiplier(multiplier: number): void;
|
|
1029
|
-
|
|
1030
|
-
/**
|
|
1031
|
-
* Sets the build speed multiplier of a team.
|
|
1032
|
-
* The multiplier will always be clamped between `0.001` and `50`.
|
|
1033
|
-
*/
|
|
1034
|
-
function buildSpeed(team: TeamSymbol, multiplier: number): void;
|
|
1035
|
-
|
|
1036
|
-
/**
|
|
1037
|
-
* Sets the speed multiplier for unit factories.
|
|
1038
|
-
* The multiplier will always be clamped between `0` and `50`.
|
|
1039
|
-
*/
|
|
1040
|
-
function unitBuildSpeed(team: TeamSymbol, multiplier: number): void;
|
|
1041
|
-
|
|
1042
|
-
/** Sets the build cost multiplier for constructing units. */
|
|
1043
|
-
function unitCost(team: TeamSymbol, multiplier: number): void;
|
|
1044
|
-
|
|
1045
|
-
/** Sets the damage multiplier for units on a given team. */
|
|
1046
|
-
function unitDamage(team: TeamSymbol, multiplier: number): void;
|
|
1047
|
-
|
|
1048
|
-
/** Sets the block health multiplier for a given team. */
|
|
1049
|
-
function blockHealth(team: TeamSymbol, multiplier: number): void;
|
|
1050
|
-
|
|
1051
|
-
/** Sets the block damage multiplier for a given team. */
|
|
1052
|
-
function blockDamage(team: TeamSymbol, multiplier: number): void;
|
|
1053
|
-
|
|
1054
|
-
/**
|
|
1055
|
-
* Sets the Real Time Strategy minimum weight for a team.
|
|
1056
|
-
*
|
|
1057
|
-
* In other words it, sets the minimum "advantage" needed for a squad to attack.
|
|
1058
|
-
* The higher the value, the more cautious the squad is.
|
|
1059
|
-
*/
|
|
1060
|
-
|
|
1061
|
-
function rtsMinWeight(team: TeamSymbol, value: number): void;
|
|
1062
|
-
|
|
1063
|
-
/**
|
|
1064
|
-
* Sets the Real Time Strategy minimum size of attack squads of a team.
|
|
1065
|
-
*
|
|
1066
|
-
* The higher the value, the more units are required before a squad attacks.
|
|
1067
|
-
*/
|
|
1068
|
-
function rtsMinSquad(team: TeamSymbol, value: number): void;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
/**
|
|
1072
|
-
* Writes the contents of the print buffer in the selected mode
|
|
1073
|
-
* and clears the buffer afterwards. World processor ONLY.
|
|
1297
|
+
* Sets the execution rate of the current processor in instructions per tick.
|
|
1074
1298
|
*
|
|
1075
1299
|
* ```js
|
|
1076
|
-
*
|
|
1077
|
-
* flushMessage.announce(4); // lasts 4 seconds
|
|
1078
|
-
* wait(5);
|
|
1079
|
-
* print("World");
|
|
1080
|
-
* flushMessage.toast(4);
|
|
1081
|
-
* wait(5);
|
|
1300
|
+
* setRate(1000);
|
|
1082
1301
|
* ```
|
|
1083
1302
|
*/
|
|
1084
|
-
namespace flushMessage {
|
|
1085
|
-
/** Shows a nofication at the top of the screen */
|
|
1086
|
-
function notify(): void;
|
|
1087
|
-
/** Puts the content on the top left corner of the screen */
|
|
1088
|
-
function mission(): void;
|
|
1089
|
-
/**
|
|
1090
|
-
* Puts the content on the middle of the screen
|
|
1091
|
-
*
|
|
1092
|
-
* @param duration The duration, in seconds
|
|
1093
|
-
*/
|
|
1094
|
-
function announce(duration: number): void;
|
|
1095
|
-
/**
|
|
1096
|
-
* Puts the content on the middle top of the screen
|
|
1097
|
-
*
|
|
1098
|
-
* @param duration The duration, in seconds
|
|
1099
|
-
*/
|
|
1100
|
-
function toast(duration: number): void;
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
/** Controls the player camera. World processor ONLY. */
|
|
1104
|
-
namespace cutscene {
|
|
1105
|
-
/** Moves the player's camera to the given location. */
|
|
1106
|
-
function pan(options: { x: number; y: number; speed: number }): void;
|
|
1107
|
-
/** Zooms the player camera to the desired level */
|
|
1108
|
-
function zoom(level: number): void;
|
|
1109
|
-
/** Gives the camera control back to the player */
|
|
1110
|
-
function stop(): void;
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
/** Creates an explosion. World processor ONLY. */
|
|
1114
|
-
function explosion(options: {
|
|
1115
|
-
team: TeamSymbol;
|
|
1116
|
-
x: number;
|
|
1117
|
-
y: number;
|
|
1118
|
-
radius: number;
|
|
1119
|
-
damage: number;
|
|
1120
|
-
air: boolean;
|
|
1121
|
-
ground: boolean;
|
|
1122
|
-
pierce: boolean;
|
|
1123
|
-
}): void;
|
|
1124
|
-
|
|
1125
|
-
/** Sets the speed of this world processor in instructions per tick. World processor ONLY. */
|
|
1126
1303
|
function setRate(ipt: number): void;
|
|
1127
|
-
|
|
1128
|
-
/** Contains the variants of the `fetch` instruction. World processor ONLY. */
|
|
1129
|
-
namespace fetch {
|
|
1130
|
-
/**
|
|
1131
|
-
* Gets an unit from the given team
|
|
1132
|
-
*
|
|
1133
|
-
* The index starts at 0.
|
|
1134
|
-
*
|
|
1135
|
-
* ```js
|
|
1136
|
-
* const count = fetch.unitCount(Teams.sharded);
|
|
1137
|
-
* for(let i = 0; i < count; i++) {
|
|
1138
|
-
* const unit = fetch.unit(Teams.sharded, i);
|
|
1139
|
-
* print`x: ${unit.x}, y: ${unit.y}\n`;
|
|
1140
|
-
* }
|
|
1141
|
-
* printFlush();
|
|
1142
|
-
* ```
|
|
1143
|
-
*/
|
|
1144
|
-
function unit<T extends BasicUnit = AnyUnit>(
|
|
1145
|
-
team: TeamSymbol,
|
|
1146
|
-
index: number
|
|
1147
|
-
): T;
|
|
1148
|
-
/**
|
|
1149
|
-
* Gets the amount of units existing on a given team.
|
|
1150
|
-
*
|
|
1151
|
-
* ```js
|
|
1152
|
-
* const count = fetch.unitCount(Teams.sharded);
|
|
1153
|
-
* for(let i = 0; i < count; i++) {
|
|
1154
|
-
* const unit = fetch.unit(Teams.sharded, i);
|
|
1155
|
-
* print`x: ${unit.x}, y: ${unit.y}\n`;
|
|
1156
|
-
* }
|
|
1157
|
-
* printFlush();
|
|
1158
|
-
* ```
|
|
1159
|
-
*/
|
|
1160
|
-
function unitCount(team: TeamSymbol): number;
|
|
1161
|
-
/**
|
|
1162
|
-
* Gets a player from a team.
|
|
1163
|
-
*
|
|
1164
|
-
* The index starts at 0.
|
|
1165
|
-
*
|
|
1166
|
-
* ```js
|
|
1167
|
-
* const count = fetch.playerCount(Teams.sharded);
|
|
1168
|
-
* for(let i = 0; i < count; i++) {
|
|
1169
|
-
* const player = fetch.player(Teams.sharded, i);
|
|
1170
|
-
* print`x: ${player.x}, y: ${player.y}\n`;
|
|
1171
|
-
* }
|
|
1172
|
-
* printFlush();
|
|
1173
|
-
* ```
|
|
1174
|
-
*/
|
|
1175
|
-
function player<T extends BasicUnit = AnyUnit>(
|
|
1176
|
-
team: TeamSymbol,
|
|
1177
|
-
index: number
|
|
1178
|
-
): T;
|
|
1179
|
-
/**
|
|
1180
|
-
* Gets the amount of players existing on a given team.
|
|
1181
|
-
*
|
|
1182
|
-
* ```js
|
|
1183
|
-
* const count = fetch.playerCount(Teams.sharded);
|
|
1184
|
-
* for(let i = 0; i < count; i++) {
|
|
1185
|
-
* const player = fetch.player(Teams.sharded, i);
|
|
1186
|
-
* print`x: ${player.x}, y: ${player.y}\n`;
|
|
1187
|
-
* }
|
|
1188
|
-
* printFlush();
|
|
1189
|
-
* ```
|
|
1190
|
-
*/
|
|
1191
|
-
function playerCount(team: TeamSymbol): number;
|
|
1192
|
-
/**
|
|
1193
|
-
* Gets a core from a team.
|
|
1194
|
-
*
|
|
1195
|
-
* The index of the starts at 0.
|
|
1196
|
-
*
|
|
1197
|
-
* ```js
|
|
1198
|
-
* const count = fetch.coreCount(Teams.sharded);
|
|
1199
|
-
* for(let i = 0; i < count; i++) {
|
|
1200
|
-
* const core = fetch.core(Teams.sharded, i);
|
|
1201
|
-
* print`x: ${core.x}, y: ${core.y}\n`;
|
|
1202
|
-
* }
|
|
1203
|
-
* printFlush();
|
|
1204
|
-
* ```
|
|
1205
|
-
*/
|
|
1206
|
-
function core(team: TeamSymbol, index: number): AnyBuilding;
|
|
1207
|
-
/**
|
|
1208
|
-
* Gets the amount of cores existing on a given team.
|
|
1209
|
-
* ```js
|
|
1210
|
-
* const count = fetch.coreCount(Teams.sharded);
|
|
1211
|
-
* for(let i = 0; i < count; i++) {
|
|
1212
|
-
* const core = fetch.core(Teams.sharded, i);
|
|
1213
|
-
* print`x: ${core.x}, y: ${core.y}\n`;
|
|
1214
|
-
* }
|
|
1215
|
-
* printFlush();
|
|
1216
|
-
* ```
|
|
1217
|
-
*/
|
|
1218
|
-
function coreCount(team: TeamSymbol): number;
|
|
1219
|
-
/**
|
|
1220
|
-
* Gets a building from a team.
|
|
1221
|
-
*
|
|
1222
|
-
* The index starts at 0.
|
|
1223
|
-
*
|
|
1224
|
-
* ```js
|
|
1225
|
-
* const count = fetch.buildCount(Teams.sharded, Blocks.router);
|
|
1226
|
-
* for(let i = 0; i < count; i++) {
|
|
1227
|
-
* const router = fetch.build(Teams.sharded, i, Blocks.router);
|
|
1228
|
-
* print`x: ${router.x}, y: ${router.y}\n`;
|
|
1229
|
-
* }
|
|
1230
|
-
* printFlush();
|
|
1231
|
-
* ```
|
|
1232
|
-
*/
|
|
1233
|
-
function build<T extends BasicBuilding = AnyBuilding>(
|
|
1234
|
-
team: TeamSymbol,
|
|
1235
|
-
index: number,
|
|
1236
|
-
block: BuildingSymbol
|
|
1237
|
-
): T;
|
|
1238
|
-
/**
|
|
1239
|
-
* Gets the amount of buildings existing on a given team.
|
|
1240
|
-
*
|
|
1241
|
-
* ```js
|
|
1242
|
-
* const count = fetch.buildCount(Teams.sharded, Blocks.router);
|
|
1243
|
-
* for(let i = 0; i < count; i++) {
|
|
1244
|
-
* const router = fetch.build(Teams.sharded, i, Blocks.router)
|
|
1245
|
-
* print`x: ${router.x}, y: ${router.y}\n`
|
|
1246
|
-
* }
|
|
1247
|
-
* printFlush()
|
|
1248
|
-
* ```
|
|
1249
|
-
*/
|
|
1250
|
-
function buildCount(team: TeamSymbol, block: BuildingSymbol): number;
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
/** Checks if a global flag is set. World processor ONLY. */
|
|
1254
|
-
function getFlag(flag: string): boolean;
|
|
1255
|
-
|
|
1256
|
-
/** Sets a global flag. World processor ONLY. */
|
|
1257
|
-
function setFlag(flag: string, value: boolean): void;
|
|
1258
1304
|
}
|