mlogjs 0.4.0 → 0.4.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.
- package/dist/Scope.d.ts +1 -0
- package/dist/handlers/Statements.d.ts +1 -0
- package/dist/index.cjs +500 -350
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +500 -350
- package/dist/index.mjs.map +1 -1
- package/dist/instructions/SetInstruction.d.ts +2 -0
- package/dist/macros/Asm.d.ts +1 -2
- package/dist/macros/Function.d.ts +4 -4
- package/dist/macros/GetGlobal.d.ts +2 -2
- package/dist/macros/Memory.d.ts +1 -2
- package/dist/macros/Namespace.d.ts +1 -1
- package/dist/macros/Other.d.ts +1 -2
- package/dist/macros/commands/ApplyStatus.d.ts +1 -2
- package/dist/macros/commands/Control.d.ts +1 -2
- package/dist/macros/commands/Cutscene.d.ts +1 -2
- package/dist/macros/commands/Draw.d.ts +1 -2
- package/dist/macros/commands/DrawFlush.d.ts +1 -2
- package/dist/macros/commands/End.d.ts +1 -2
- package/dist/macros/commands/Explosion.d.ts +1 -2
- package/dist/macros/commands/Fetch.d.ts +1 -2
- package/dist/macros/commands/FlushMessage.d.ts +1 -2
- package/dist/macros/commands/GetBlock.d.ts +1 -2
- package/dist/macros/commands/GetFlag.d.ts +1 -2
- package/dist/macros/commands/GetLink.d.ts +1 -2
- package/dist/macros/commands/Lookup.d.ts +1 -2
- package/dist/macros/commands/PackColor.d.ts +1 -2
- package/dist/macros/commands/Print.d.ts +1 -2
- package/dist/macros/commands/PrintFlush.d.ts +1 -2
- package/dist/macros/commands/Radar.d.ts +1 -2
- package/dist/macros/commands/Sensor.d.ts +1 -2
- package/dist/macros/commands/SetBlock.d.ts +1 -2
- package/dist/macros/commands/SetFlag.d.ts +1 -2
- package/dist/macros/commands/SetRate.d.ts +1 -2
- package/dist/macros/commands/SetRule.d.ts +1 -2
- package/dist/macros/commands/SpawnUnit.d.ts +1 -2
- package/dist/macros/commands/SpawnWave.d.ts +1 -2
- package/dist/macros/commands/Stop.d.ts +1 -2
- package/dist/macros/commands/UnitBind.d.ts +1 -2
- package/dist/macros/commands/UnitControl.d.ts +1 -2
- package/dist/macros/commands/UnitLocate.d.ts +1 -2
- package/dist/macros/commands/UnitRadar.d.ts +1 -2
- package/dist/macros/commands/Wait.d.ts +1 -2
- package/dist/macros/util.d.ts +2 -3
- package/dist/operators.d.ts +4 -4
- package/dist/types.d.ts +3 -1
- package/dist/values/BaseValue.d.ts +2 -2
- package/dist/values/DestructuringValue.d.ts +1 -1
- package/dist/values/FunctionValue.d.ts +3 -4
- package/dist/values/LiteralValue.d.ts +3 -2
- package/dist/values/ObjectValue.d.ts +3 -3
- package/dist/values/StoreValue.d.ts +4 -2
- package/dist/values/VoidValue.d.ts +0 -2
- package/lib/commands.d.ts +306 -40
- package/lib/eslib/lib.es5.d.ts +23 -0
- package/lib/globals.d.ts +2 -3
- package/lib/helpers.d.ts +2 -1
- package/lib/kinds.d.ts +5 -2
- package/lib/traits.d.ts +10 -6
- package/package.json +2 -7
- package/dist/types/Compiler.d.ts +0 -39
- package/dist/types/CompilerError.d.ts +0 -33
- package/dist/types/Scope.d.ts +0 -24
- package/dist/types/assertions.d.ts +0 -28
- package/dist/types/bin.d.ts +0 -1
- package/dist/types/handlers/BlockStatement.d.ts +0 -2
- package/dist/types/handlers/CallExpression.d.ts +0 -4
- package/dist/types/handlers/File.d.ts +0 -2
- package/dist/types/handlers/ForStatement.d.ts +0 -2
- package/dist/types/handlers/Function.d.ts +0 -5
- package/dist/types/handlers/Identifier.d.ts +0 -2
- package/dist/types/handlers/IfStatement.d.ts +0 -2
- package/dist/types/handlers/Literal.d.ts +0 -5
- package/dist/types/handlers/Object.d.ts +0 -6
- package/dist/types/handlers/OperationExpressions.d.ts +0 -8
- package/dist/types/handlers/Program.d.ts +0 -2
- package/dist/types/handlers/Statements.d.ts +0 -5
- package/dist/types/handlers/SwitchStatement.d.ts +0 -2
- package/dist/types/handlers/TemplateExpression.d.ts +0 -2
- package/dist/types/handlers/Typescript.d.ts +0 -7
- package/dist/types/handlers/VariableDeclaration.d.ts +0 -3
- package/dist/types/handlers/WhileStatement.d.ts +0 -3
- package/dist/types/handlers/index.d.ts +0 -17
- package/dist/types/index.d.ts +0 -3
- package/dist/types/initScope.d.ts +0 -5
- package/dist/types/instructions/AddressResolver.d.ts +0 -12
- package/dist/types/instructions/ControlInstructions.d.ts +0 -10
- package/dist/types/instructions/EndInstruction.d.ts +0 -4
- package/dist/types/instructions/InstructionBase.d.ts +0 -14
- package/dist/types/instructions/JumpInstruction.d.ts +0 -16
- package/dist/types/instructions/OperationInstruction.d.ts +0 -5
- package/dist/types/instructions/SetCounterInstruction.d.ts +0 -5
- package/dist/types/instructions/SetInstruction.d.ts +0 -6
- package/dist/types/instructions/ZeroSpaceInstruction.d.ts +0 -4
- package/dist/types/instructions/index.d.ts +0 -9
- package/dist/types/macros/Asm.d.ts +0 -5
- package/dist/types/macros/Function.d.ts +0 -13
- package/dist/types/macros/GetGlobal.d.ts +0 -5
- package/dist/types/macros/Math.d.ts +0 -5
- package/dist/types/macros/Memory.d.ts +0 -5
- package/dist/types/macros/Namespace.d.ts +0 -13
- package/dist/types/macros/Other.d.ts +0 -5
- package/dist/types/macros/commands/ApplyStatus.d.ts +0 -5
- package/dist/types/macros/commands/Control.d.ts +0 -5
- package/dist/types/macros/commands/Cutscene.d.ts +0 -5
- package/dist/types/macros/commands/Draw.d.ts +0 -5
- package/dist/types/macros/commands/DrawFlush.d.ts +0 -5
- package/dist/types/macros/commands/End.d.ts +0 -5
- package/dist/types/macros/commands/Explosion.d.ts +0 -5
- package/dist/types/macros/commands/Fetch.d.ts +0 -5
- package/dist/types/macros/commands/FlushMessage.d.ts +0 -5
- package/dist/types/macros/commands/GetBlock.d.ts +0 -5
- package/dist/types/macros/commands/GetFlag.d.ts +0 -5
- package/dist/types/macros/commands/GetLink.d.ts +0 -5
- package/dist/types/macros/commands/Lookup.d.ts +0 -5
- package/dist/types/macros/commands/PackColor.d.ts +0 -5
- package/dist/types/macros/commands/Print.d.ts +0 -5
- package/dist/types/macros/commands/PrintFlush.d.ts +0 -5
- package/dist/types/macros/commands/Radar.d.ts +0 -7
- package/dist/types/macros/commands/Sensor.d.ts +0 -5
- package/dist/types/macros/commands/SetBlock.d.ts +0 -5
- package/dist/types/macros/commands/SetFlag.d.ts +0 -5
- package/dist/types/macros/commands/SetRate.d.ts +0 -5
- package/dist/types/macros/commands/SetRule.d.ts +0 -5
- package/dist/types/macros/commands/SpawnUnit.d.ts +0 -5
- package/dist/types/macros/commands/SpawnWave.d.ts +0 -5
- package/dist/types/macros/commands/Stop.d.ts +0 -5
- package/dist/types/macros/commands/UnitBind.d.ts +0 -5
- package/dist/types/macros/commands/UnitControl.d.ts +0 -5
- package/dist/types/macros/commands/UnitLocate.d.ts +0 -5
- package/dist/types/macros/commands/UnitRadar.d.ts +0 -5
- package/dist/types/macros/commands/Wait.d.ts +0 -5
- package/dist/types/macros/commands/index.d.ts +0 -30
- package/dist/types/macros/index.d.ts +0 -6
- package/dist/types/macros/util.d.ts +0 -18
- package/dist/types/operators.d.ts +0 -25
- package/dist/types/types.d.ts +0 -238
- package/dist/types/utils.d.ts +0 -47
- package/dist/types/values/BaseValue.d.ts +0 -9
- package/dist/types/values/DestructuringValue.d.ts +0 -17
- package/dist/types/values/FunctionValue.d.ts +0 -47
- package/dist/types/values/LiteralValue.d.ts +0 -13
- package/dist/types/values/ObjectValue.d.ts +0 -23
- package/dist/types/values/SenseableValue.d.ts +0 -23
- package/dist/types/values/StoreValue.d.ts +0 -15
- package/dist/types/values/ValueOwner.d.ts +0 -27
- package/dist/types/values/VoidValue.d.ts +0 -16
- package/dist/types/values/index.d.ts +0 -7
package/lib/commands.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ declare global {
|
|
|
10
10
|
* Appends the items to the print buffer, calling this function
|
|
11
11
|
* on its own will not print any contents to a message block.
|
|
12
12
|
*
|
|
13
|
-
* To print the contents of the print buffer and empty it call `printFlush`.
|
|
13
|
+
* To print the contents of the print buffer and empty it call, `printFlush`.
|
|
14
14
|
*
|
|
15
15
|
* @param items The items to be added to the print buffer.
|
|
16
16
|
*
|
|
@@ -35,6 +35,12 @@ declare global {
|
|
|
35
35
|
/**
|
|
36
36
|
* Sets the color for the next drawing operations.
|
|
37
37
|
*
|
|
38
|
+
* Each parameter must be within range: [0, 255].
|
|
39
|
+
*
|
|
40
|
+
* ```js
|
|
41
|
+
* draw.color(255, 255, 255, 128);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
38
44
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
39
45
|
*/
|
|
40
46
|
function color(r: number, g: number, b: number, a?: number): void;
|
|
@@ -42,6 +48,10 @@ declare global {
|
|
|
42
48
|
/**
|
|
43
49
|
* Sets the width of the next lines to be drawn.
|
|
44
50
|
*
|
|
51
|
+
* ```js
|
|
52
|
+
* draw.stroke(15);
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
45
55
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
46
56
|
*/
|
|
47
57
|
function stroke(width: number): void;
|
|
@@ -49,6 +59,10 @@ declare global {
|
|
|
49
59
|
/**
|
|
50
60
|
* Draws a line between two points.
|
|
51
61
|
*
|
|
62
|
+
* ```js
|
|
63
|
+
* draw.line({ x: 5, y: 5, x2: 50, y2: 50 });
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
52
66
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
53
67
|
*/
|
|
54
68
|
function line(options: {
|
|
@@ -60,6 +74,14 @@ declare global {
|
|
|
60
74
|
|
|
61
75
|
/**
|
|
62
76
|
* Draws a filled rectangle.
|
|
77
|
+
* ```js
|
|
78
|
+
* draw.rect({
|
|
79
|
+
* x: 10,
|
|
80
|
+
* y: 15,
|
|
81
|
+
* height: 60,
|
|
82
|
+
* width: 40,
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
63
85
|
*
|
|
64
86
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
65
87
|
*/
|
|
@@ -88,6 +110,16 @@ declare global {
|
|
|
88
110
|
* @param options.radius The smallest distance between a line and the center of the polygon
|
|
89
111
|
* @param options.rotation The rotation of the polygon in degrees
|
|
90
112
|
*
|
|
113
|
+
* ```js
|
|
114
|
+
* draw.poly({
|
|
115
|
+
* radius: 10,
|
|
116
|
+
* rotation: 0,
|
|
117
|
+
* sides: 10,
|
|
118
|
+
* x: 25,
|
|
119
|
+
* y: 25,
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
91
123
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
92
124
|
*/
|
|
93
125
|
function poly(options: {
|
|
@@ -107,6 +139,15 @@ declare global {
|
|
|
107
139
|
* @param options.radius The smallest distance between a line and the center of the polygon
|
|
108
140
|
* @param options.rotation The rotation of the polygon in degrees
|
|
109
141
|
*
|
|
142
|
+
* ```js
|
|
143
|
+
* draw.linePoly({
|
|
144
|
+
* radius: 10,
|
|
145
|
+
* rotation: 0,
|
|
146
|
+
* sides: 10,
|
|
147
|
+
* x: 25,
|
|
148
|
+
* y: 25,
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
110
151
|
*
|
|
111
152
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
112
153
|
*/
|
|
@@ -124,6 +165,17 @@ declare global {
|
|
|
124
165
|
/**
|
|
125
166
|
* Draws a filled triangle.
|
|
126
167
|
*
|
|
168
|
+
* ```js
|
|
169
|
+
* draw.triangle({
|
|
170
|
+
* x: 10,
|
|
171
|
+
* y: 10,
|
|
172
|
+
* x2: 20,
|
|
173
|
+
* y2: 20,
|
|
174
|
+
* x3: 30,
|
|
175
|
+
* y3: 10,
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
127
179
|
* Warning: nothing is drawn until `drawFlush` is called.
|
|
128
180
|
*/
|
|
129
181
|
function triangle(options: {
|
|
@@ -204,7 +256,8 @@ declare global {
|
|
|
204
256
|
* Example:
|
|
205
257
|
* ```js
|
|
206
258
|
* if(index < Vars.links) {
|
|
207
|
-
* myBlock = getLink(index)
|
|
259
|
+
* let myBlock = getLink(index)
|
|
260
|
+
* // ...
|
|
208
261
|
* }
|
|
209
262
|
* ```
|
|
210
263
|
*/
|
|
@@ -214,6 +267,11 @@ declare global {
|
|
|
214
267
|
namespace control {
|
|
215
268
|
/**
|
|
216
269
|
* Sets whether the building is enabled or disabled.
|
|
270
|
+
*
|
|
271
|
+
* ```js
|
|
272
|
+
* const conveyor = getBuilding("conveyor1");
|
|
273
|
+
* control.enabled(conveyor, false);
|
|
274
|
+
* ```
|
|
217
275
|
*/
|
|
218
276
|
function enabled(building: BasicBuilding, value: boolean): void;
|
|
219
277
|
|
|
@@ -221,6 +279,15 @@ declare global {
|
|
|
221
279
|
* Makes the building shoot or aim at the given position
|
|
222
280
|
* @param options.building The shooting building
|
|
223
281
|
* @param options.shoot `true` to shoot, `false` to just aim at the position
|
|
282
|
+
*
|
|
283
|
+
* ```js
|
|
284
|
+
* control.shoot({
|
|
285
|
+
* building: getBuilding("cyclone1"),
|
|
286
|
+
* shoot: true,
|
|
287
|
+
* x: Vars.thisx,
|
|
288
|
+
* y: Vars.thisy,
|
|
289
|
+
* });
|
|
290
|
+
* ```
|
|
224
291
|
*/
|
|
225
292
|
function shoot(options: {
|
|
226
293
|
/** The shooting building */
|
|
@@ -236,6 +303,23 @@ declare global {
|
|
|
236
303
|
* @param options.building The shooting building
|
|
237
304
|
* @param options.unit The target unit
|
|
238
305
|
* @param options.shoot `true` to shoot, `false` to just aim
|
|
306
|
+
*
|
|
307
|
+
* ```js
|
|
308
|
+
* const turret = getBuilding("cyclone1");
|
|
309
|
+
*
|
|
310
|
+
* const player = radar({
|
|
311
|
+
* building: turret,
|
|
312
|
+
* filters: ["player", "any", "any"],
|
|
313
|
+
* order: true,
|
|
314
|
+
* sort: "distance",
|
|
315
|
+
* });
|
|
316
|
+
*
|
|
317
|
+
* control.shootp({
|
|
318
|
+
* building: turret,
|
|
319
|
+
* unit: player,
|
|
320
|
+
* shoot: true,
|
|
321
|
+
* });
|
|
322
|
+
* ```
|
|
239
323
|
*/
|
|
240
324
|
function shootp(options: {
|
|
241
325
|
/** The shooting building */
|
|
@@ -248,11 +332,25 @@ declare global {
|
|
|
248
332
|
|
|
249
333
|
/**
|
|
250
334
|
* Sets the config of a block (like the item of a sorter)
|
|
335
|
+
*
|
|
336
|
+
* ```js
|
|
337
|
+
* const sorter = getBuilding("sorter1");
|
|
338
|
+
*
|
|
339
|
+
* control.config(sorter, Items.copper);
|
|
340
|
+
* ```
|
|
251
341
|
*/
|
|
252
342
|
function config(building: BasicBuilding, value: symbol): void;
|
|
253
343
|
|
|
254
344
|
/**
|
|
255
|
-
* Sets the color of an illuminator
|
|
345
|
+
* Sets the color of an illuminator.
|
|
346
|
+
*
|
|
347
|
+
* The RGB values must be within the range: [0, 255].
|
|
348
|
+
*
|
|
349
|
+
* ```js
|
|
350
|
+
* const illuminator = getBuilding("illuminator1");
|
|
351
|
+
*
|
|
352
|
+
* control.color(illuminator, 10, 150, 210);
|
|
353
|
+
* ```
|
|
256
354
|
*/
|
|
257
355
|
function color(
|
|
258
356
|
building: BasicBuilding,
|
|
@@ -266,18 +364,17 @@ declare global {
|
|
|
266
364
|
* Detects an unit nearby this `building`.
|
|
267
365
|
* @param options.building The building used to detect potential targets
|
|
268
366
|
* @param options.filters The filters for selecting a target. Use "any" for any target.
|
|
269
|
-
* @param options.order
|
|
270
|
-
* (1 => first unit, 2 => second unit and so on)
|
|
367
|
+
* @param options.order `true` to get the first result, `false` to get the last result.
|
|
271
368
|
* @param options.sort The method on which the results should be sorted
|
|
272
369
|
*
|
|
273
370
|
* Example:
|
|
274
371
|
* ```js
|
|
275
372
|
* const turret = getBuilding("cyclone1")
|
|
276
|
-
* // returns the
|
|
373
|
+
* // returns the furthest enemy unit
|
|
277
374
|
* const result = radar({
|
|
278
375
|
* building: turret,
|
|
279
376
|
* filters: ["enemy", "any", "any"],
|
|
280
|
-
* order:
|
|
377
|
+
* order: false,
|
|
281
378
|
* sort: "distance"
|
|
282
379
|
* });
|
|
283
380
|
* ```
|
|
@@ -287,9 +384,8 @@ declare global {
|
|
|
287
384
|
building: BasicBuilding;
|
|
288
385
|
/** The filters for selecting a target. Use "any" for any target. */
|
|
289
386
|
filters: [TRadarFilter, TRadarFilter, TRadarFilter];
|
|
290
|
-
/**
|
|
291
|
-
|
|
292
|
-
order: number;
|
|
387
|
+
/** `true` to get the first result, `false` to get the last result. */
|
|
388
|
+
order: boolean;
|
|
293
389
|
/** The method on which the results should be sorted */
|
|
294
390
|
sort: TRadarSort;
|
|
295
391
|
}): T;
|
|
@@ -300,24 +396,33 @@ declare global {
|
|
|
300
396
|
* This method allows you to use customly created symbols
|
|
301
397
|
* and sensor them on buildings.
|
|
302
398
|
* @param property The property to be sensed on the building
|
|
303
|
-
* @param target
|
|
399
|
+
* @param target The object that will be "sensed"
|
|
304
400
|
*
|
|
305
401
|
* Example:
|
|
306
|
-
*
|
|
307
|
-
* let myBuilding = getBuilding("container1")
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* let
|
|
312
|
-
*
|
|
402
|
+
* ```ts
|
|
403
|
+
* let myBuilding = getBuilding("container1");
|
|
404
|
+
*
|
|
405
|
+
* // typescript annotation, you can use jsdoc comments on
|
|
406
|
+
* // regular javascript
|
|
407
|
+
* let myCustomSymbol = getVar<symbol>("@custom-symbol"); // problably defined by a mod
|
|
408
|
+
* let result = sensor(myCustomSymbol, myBuilding);
|
|
409
|
+
* ```
|
|
313
410
|
*/
|
|
314
411
|
function sensor<T>(property: symbol, target: BasicBuilding | BasicUnit): T;
|
|
315
412
|
|
|
316
413
|
/**
|
|
317
|
-
* Stops the execution for the given amount of
|
|
414
|
+
* Stops the execution for the given amount of
|
|
415
|
+
* ```js
|
|
416
|
+
* print("before");
|
|
417
|
+
* printFlush();
|
|
418
|
+
* wait(3.5);
|
|
419
|
+
* print("after");
|
|
420
|
+
* printFlush();
|
|
421
|
+
* ```
|
|
318
422
|
*/
|
|
319
423
|
function wait(seconds: number): void;
|
|
320
424
|
|
|
425
|
+
/** Looks up content symbols by their index. */
|
|
321
426
|
namespace lookup {
|
|
322
427
|
/**
|
|
323
428
|
* Looks up a block symbol by it's index on the content registry.
|
|
@@ -380,11 +485,28 @@ declare global {
|
|
|
380
485
|
* Packs RGBA color information into a single number.
|
|
381
486
|
*
|
|
382
487
|
* Each paremeter must range from `0` to `1`.
|
|
488
|
+
*
|
|
489
|
+
*
|
|
490
|
+
* ```js
|
|
491
|
+
* const colorData = packColor(0.1, 0.6, 0.8, 0.1);
|
|
492
|
+
*
|
|
493
|
+
* // world processor only
|
|
494
|
+
* setRule.ambientLight(colorData);
|
|
495
|
+
* ```
|
|
383
496
|
*/
|
|
384
497
|
function packColor(r: number, g: number, b: number, a: number): number;
|
|
385
498
|
|
|
386
499
|
/**
|
|
387
|
-
* Binds an unit to the this processor. The unit is accessible at `Vars.unit
|
|
500
|
+
* Binds an unit to the this processor. The unit is accessible at `Vars.unit`.
|
|
501
|
+
*
|
|
502
|
+
* ```js
|
|
503
|
+
* unitBind(Units.flare);
|
|
504
|
+
*
|
|
505
|
+
* const { x, y } = Vars.unit;
|
|
506
|
+
*
|
|
507
|
+
* print`x: ${x} y: ${y}`;
|
|
508
|
+
* printFlush();
|
|
509
|
+
* ```
|
|
388
510
|
*/
|
|
389
511
|
function unitBind(type: UnitSymbol): void;
|
|
390
512
|
|
|
@@ -441,6 +563,19 @@ declare global {
|
|
|
441
563
|
* Makes the unit bound to this processor target an unit with velocity prediction
|
|
442
564
|
* @param options.unit The shoot target
|
|
443
565
|
* @param options.shoot `true` to shoot, `false` to just aim
|
|
566
|
+
*
|
|
567
|
+
* ```js
|
|
568
|
+
* const player = unitRadar({
|
|
569
|
+
* filters: ["player", "any", "any"],
|
|
570
|
+
* order: true,
|
|
571
|
+
* sort: "distance",
|
|
572
|
+
* });
|
|
573
|
+
*
|
|
574
|
+
* unitControl.targetp({
|
|
575
|
+
* shoot: true,
|
|
576
|
+
* unit: player,
|
|
577
|
+
* });
|
|
578
|
+
* ```
|
|
444
579
|
*/
|
|
445
580
|
function targetp(options: {
|
|
446
581
|
/** The shoot target */
|
|
@@ -451,8 +586,22 @@ declare global {
|
|
|
451
586
|
|
|
452
587
|
/**
|
|
453
588
|
* Makes the unit bound to this processor drop it's held items onto the given target
|
|
454
|
-
* @param target Where to drop the items, if `
|
|
589
|
+
* @param target Where to drop the items, if `Blocks.air`, the unit will throw it's items away
|
|
455
590
|
* @param amount How many items should be dropped
|
|
591
|
+
*
|
|
592
|
+
* ```js
|
|
593
|
+
* const container = getBuilding("container1");
|
|
594
|
+
*
|
|
595
|
+
* // ...
|
|
596
|
+
*
|
|
597
|
+
* // drop 40 items on the container
|
|
598
|
+
* unitControl.itemDrop(container, 40);
|
|
599
|
+
*
|
|
600
|
+
* // ...
|
|
601
|
+
*
|
|
602
|
+
* // discard 10 items from the current unit
|
|
603
|
+
* unitControl.itemDrop(Blocks.air, 10);
|
|
604
|
+
* ```
|
|
456
605
|
*/
|
|
457
606
|
function itemDrop(
|
|
458
607
|
target: BasicBuilding | typeof Blocks.air,
|
|
@@ -464,6 +613,16 @@ declare global {
|
|
|
464
613
|
* @param target The building that will have it's items taken
|
|
465
614
|
* @param item The kind of item to take
|
|
466
615
|
* @param amount How many items should be taken
|
|
616
|
+
*
|
|
617
|
+
* ```js
|
|
618
|
+
* const vault = getBuilding("vault1");
|
|
619
|
+
*
|
|
620
|
+
* // bind unit and move to the valult...
|
|
621
|
+
*
|
|
622
|
+
* unitControl.itemTake(vault, Items.graphite, 50);
|
|
623
|
+
*
|
|
624
|
+
* // do something with the graphite...
|
|
625
|
+
* ```
|
|
467
626
|
*/
|
|
468
627
|
function itemTake(
|
|
469
628
|
target: BasicBuilding,
|
|
@@ -507,17 +666,30 @@ declare global {
|
|
|
507
666
|
* @param options.block The kind of building to build
|
|
508
667
|
* @param options.rotation The rotation of the building, ranges from 0 to 3
|
|
509
668
|
* @param options.config The config of the building
|
|
669
|
+
*
|
|
670
|
+
* ```js
|
|
671
|
+
* unitControl.build({
|
|
672
|
+
* x: 10,
|
|
673
|
+
* y: 20,
|
|
674
|
+
* block: Blocks.sorter,
|
|
675
|
+
* rotation: 1,
|
|
676
|
+
* config: Items.silicon,
|
|
677
|
+
* });
|
|
678
|
+
* ```
|
|
510
679
|
*/
|
|
511
680
|
function build(options: {
|
|
512
681
|
x: number;
|
|
513
682
|
y: number;
|
|
683
|
+
/** The kind of building to build */
|
|
514
684
|
block: BuildingSymbol;
|
|
685
|
+
/** The rotation of the building, ranges from 0 to 3 */
|
|
515
686
|
rotation: number;
|
|
687
|
+
/** The config of the building */
|
|
516
688
|
config?: unknown;
|
|
517
689
|
}): void;
|
|
518
690
|
|
|
519
691
|
/**
|
|
520
|
-
* Makes the unit bound to this processor data about a block at the given position
|
|
692
|
+
* Makes the unit bound to this processor get data about a block at the given position
|
|
521
693
|
*/
|
|
522
694
|
function getBlock<T extends BasicBuilding = AnyBuilding>(
|
|
523
695
|
x: number,
|
|
@@ -533,16 +705,15 @@ declare global {
|
|
|
533
705
|
/**
|
|
534
706
|
* Finds an unit near the unit bound to this processor
|
|
535
707
|
* @param options.filters The filters for selecting a target. Use "any" for any target.
|
|
536
|
-
* @param options.order
|
|
537
|
-
* (1 => first unit, 2 => second unit and so on)
|
|
708
|
+
* @param options.order `true` to get the first result, `false` to get the last result.
|
|
538
709
|
* @param options.sort The method on which the results should be sorted
|
|
539
710
|
*
|
|
540
711
|
* Example:
|
|
541
712
|
* ```js
|
|
542
|
-
* // returns the
|
|
713
|
+
* // returns the furthest enemy unit
|
|
543
714
|
* const result = unitRadar({
|
|
544
715
|
* filters: ["enemy", "any", "any"],
|
|
545
|
-
* order:
|
|
716
|
+
* order: false,
|
|
546
717
|
* sort: "distance",
|
|
547
718
|
* });
|
|
548
719
|
* ```
|
|
@@ -550,17 +721,25 @@ declare global {
|
|
|
550
721
|
function unitRadar<T extends BasicUnit = AnyUnit>(options: {
|
|
551
722
|
/** The filters for selecting a target. Use "any" for any target. */
|
|
552
723
|
filters: [TRadarFilter, TRadarFilter, TRadarFilter];
|
|
553
|
-
/**
|
|
554
|
-
|
|
555
|
-
order: number;
|
|
724
|
+
/** `true` to get the first result, `false` to get the last result. */
|
|
725
|
+
order: boolean;
|
|
556
726
|
/** The method on which the results should be sorted */
|
|
557
727
|
sort: TRadarSort;
|
|
558
728
|
}): T;
|
|
559
729
|
|
|
730
|
+
/** Uses the unit bound to this processor to find specific types of blocks */
|
|
560
731
|
namespace unitLocate {
|
|
561
732
|
/**
|
|
562
733
|
* Uses the unit bound to this processor to find an ore vein anywhere on the map
|
|
563
734
|
* @param ore The kind of item the ore should contain
|
|
735
|
+
*
|
|
736
|
+
* ```js
|
|
737
|
+
* const [found, x, y] = unitLocate.ore(Items.copper);
|
|
738
|
+
*
|
|
739
|
+
* if (found) {
|
|
740
|
+
* unitControl.approach({ x, y, radius: 5 });
|
|
741
|
+
* }
|
|
742
|
+
* ```
|
|
564
743
|
*/
|
|
565
744
|
function ore(
|
|
566
745
|
ore: ItemSymbol
|
|
@@ -570,6 +749,42 @@ declare global {
|
|
|
570
749
|
* Uses the unit bound to this processor to find a building anywhere on the map
|
|
571
750
|
* @param options.group The group that the building belongs to
|
|
572
751
|
* @param options.enemy Whether it should be an enemy building or an ally one
|
|
752
|
+
*
|
|
753
|
+
* ```js
|
|
754
|
+
* const vault = getBuilding("vault1");
|
|
755
|
+
* const takeAmount = 100;
|
|
756
|
+
*
|
|
757
|
+
* unitBind(Units.mega);
|
|
758
|
+
*
|
|
759
|
+
* // we don't use the `found` variable
|
|
760
|
+
* // because we always have our own core
|
|
761
|
+
* const [, x, y, core] = unitLocate.building({
|
|
762
|
+
* group: "core",
|
|
763
|
+
* enemy: false,
|
|
764
|
+
* });
|
|
765
|
+
*
|
|
766
|
+
* const location = {
|
|
767
|
+
* x,
|
|
768
|
+
* y,
|
|
769
|
+
* radius: 5,
|
|
770
|
+
* };
|
|
771
|
+
*
|
|
772
|
+
* if (!unitControl.within(location) && Vars.unit.totalItems == 0) {
|
|
773
|
+
* // if the unit has no items and it is not near
|
|
774
|
+
* // the core, move it to the core
|
|
775
|
+
* // and take 100 copper
|
|
776
|
+
* unitControl.approach(location);
|
|
777
|
+
* unitControl.itemTake(core, Items.copper, takeAmount);
|
|
778
|
+
* } else {
|
|
779
|
+
* // else, approach the vault and drop the items on it
|
|
780
|
+
* unitControl.approach({
|
|
781
|
+
* x: vault.x,
|
|
782
|
+
* y: vault.y,
|
|
783
|
+
* radius: 5,
|
|
784
|
+
* });
|
|
785
|
+
* unitControl.itemDrop(vault, takeAmount);
|
|
786
|
+
* }
|
|
787
|
+
* ```
|
|
573
788
|
*/
|
|
574
789
|
function building<T extends BasicBuilding = AnyBuilding>(options: {
|
|
575
790
|
/** The group that the building belongs to */
|
|
@@ -581,24 +796,66 @@ declare global {
|
|
|
581
796
|
/**
|
|
582
797
|
* Uses the unit bound to this processor to find an enemy spawn anywhere on the map.
|
|
583
798
|
*
|
|
584
|
-
*
|
|
799
|
+
* Returns the enemy spawn point or its core, if it exists.
|
|
800
|
+
*
|
|
801
|
+
* ```js
|
|
802
|
+
* const [found, x, y, core] = unitLocate.spawn();
|
|
803
|
+
*
|
|
804
|
+
* if (!found) {
|
|
805
|
+
* print("No enemy core found");
|
|
806
|
+
* } else if (core) {
|
|
807
|
+
* print`core location at (${x}, ${y})`;
|
|
808
|
+
* } else {
|
|
809
|
+
* print`enemy spawn at (${x}, ${y})`;
|
|
810
|
+
* }
|
|
811
|
+
*
|
|
812
|
+
* printFlush();
|
|
813
|
+
* ```
|
|
585
814
|
*/
|
|
586
815
|
function spawn<T extends BasicBuilding = AnyBuilding>():
|
|
587
816
|
| [found: false]
|
|
588
817
|
| [found: true, x: number, y: number, building: T];
|
|
589
818
|
|
|
590
819
|
/**
|
|
591
|
-
* Uses the unit bound to this processor to find a damaged ally
|
|
820
|
+
* Uses the unit bound to this processor to find a damaged ally building anywhere on the map
|
|
821
|
+
*
|
|
822
|
+
* ```js
|
|
823
|
+
* const [found, x, y, building] = unitLocate.damaged();
|
|
824
|
+
*
|
|
825
|
+
* if (found) {
|
|
826
|
+
* print`go fix a ${building} at (${x}, ${y})`;
|
|
827
|
+
* } else {
|
|
828
|
+
* print("No damaged building found");
|
|
829
|
+
* }
|
|
830
|
+
* printFlush();
|
|
831
|
+
* ```
|
|
592
832
|
*/
|
|
593
833
|
function damaged<T extends BasicBuilding = AnyBuilding>():
|
|
594
834
|
| [found: false]
|
|
595
835
|
| [found: true, x: number, y: number, building: T];
|
|
596
836
|
}
|
|
597
837
|
|
|
598
|
-
/**
|
|
838
|
+
/**
|
|
839
|
+
* Jumps to the top of the instruction stack.
|
|
840
|
+
*
|
|
841
|
+
* ```js
|
|
842
|
+
* const { enabled } = getBuilding("switch1");
|
|
843
|
+
*
|
|
844
|
+
* if (!enabled) endScript();
|
|
845
|
+
* // do something when the switch is enabled
|
|
846
|
+
* ```
|
|
847
|
+
*/
|
|
599
848
|
function endScript(): never;
|
|
600
849
|
|
|
601
|
-
/**
|
|
850
|
+
/**
|
|
851
|
+
* Halts the execution of this processor. Can be used to debug
|
|
852
|
+
* code and analyze the processor registers.
|
|
853
|
+
*
|
|
854
|
+
* ```js
|
|
855
|
+
* // stop the processor to debug variables
|
|
856
|
+
* stopScript();
|
|
857
|
+
* ```
|
|
858
|
+
*/
|
|
602
859
|
function stopScript(): never;
|
|
603
860
|
|
|
604
861
|
/** Gets block data from the map. Available ONLY for world processors. */
|
|
@@ -619,6 +876,7 @@ declare global {
|
|
|
619
876
|
): T | null;
|
|
620
877
|
}
|
|
621
878
|
|
|
879
|
+
/** Sets block data on a given location. World processor ONLY. */
|
|
622
880
|
namespace setBlock {
|
|
623
881
|
// TODO: maybe have a separate floor symbol type?
|
|
624
882
|
/** Sets the floor of the tile at the given location. */
|
|
@@ -637,12 +895,17 @@ declare global {
|
|
|
637
895
|
}): void;
|
|
638
896
|
}
|
|
639
897
|
|
|
640
|
-
/**
|
|
898
|
+
/**
|
|
899
|
+
* Spawns an unit at the given location. World processor ONLY.
|
|
900
|
+
*
|
|
901
|
+
* @param options.rotation The initial rotation of the unit in degrees.
|
|
902
|
+
*/
|
|
641
903
|
function spawnUnit<T extends BasicUnit = AnyUnit>(options: {
|
|
642
904
|
type: UnitSymbol;
|
|
643
905
|
x: number;
|
|
644
906
|
y: number;
|
|
645
907
|
team: TeamSymbol;
|
|
908
|
+
/** The initial rotation of the unit in degrees. */
|
|
646
909
|
rotation?: number;
|
|
647
910
|
}): T;
|
|
648
911
|
|
|
@@ -726,8 +989,8 @@ declare global {
|
|
|
726
989
|
*
|
|
727
990
|
* ```js
|
|
728
991
|
* // enables lighting and sets the color to gray
|
|
729
|
-
* setRule(
|
|
730
|
-
* setRule(
|
|
992
|
+
* setRule.lighting(true);
|
|
993
|
+
* setRule.ambientLight(packColor(0.5, 0.5, 0.5, 1));
|
|
731
994
|
* ```
|
|
732
995
|
*/
|
|
733
996
|
function ambientLight(rgbaData: number): void;
|
|
@@ -747,11 +1010,13 @@ declare global {
|
|
|
747
1010
|
*/
|
|
748
1011
|
function unitBuildSpeed(team: TeamSymbol, multiplier: number): void;
|
|
749
1012
|
|
|
750
|
-
/** Sets the
|
|
1013
|
+
/** Sets the build cost multiplier for constructing units. */
|
|
1014
|
+
function unitCost(team: TeamSymbol, multiplier: number): void;
|
|
751
1015
|
|
|
1016
|
+
/** Sets the damage multiplier for units on a given team. */
|
|
752
1017
|
function unitDamage(team: TeamSymbol, multiplier: number): void;
|
|
753
|
-
/** Sets the block health multiplier for a given team. */
|
|
754
1018
|
|
|
1019
|
+
/** Sets the block health multiplier for a given team. */
|
|
755
1020
|
function blockHealth(team: TeamSymbol, multiplier: number): void;
|
|
756
1021
|
|
|
757
1022
|
/** Sets the block damage multiplier for a given team. */
|
|
@@ -806,6 +1071,7 @@ declare global {
|
|
|
806
1071
|
function toast(duration: number): void;
|
|
807
1072
|
}
|
|
808
1073
|
|
|
1074
|
+
/** Controls the player camera. World processor ONLY. */
|
|
809
1075
|
namespace cutscene {
|
|
810
1076
|
/** Moves the player's camera to the given location. */
|
|
811
1077
|
function pan(options: { x: number; y: number; speed: number }): void;
|
|
@@ -815,7 +1081,7 @@ declare global {
|
|
|
815
1081
|
function stop(): void;
|
|
816
1082
|
}
|
|
817
1083
|
|
|
818
|
-
/** Creates an explosion */
|
|
1084
|
+
/** Creates an explosion. World processor ONLY. */
|
|
819
1085
|
function explosion(options: {
|
|
820
1086
|
team: TeamSymbol;
|
|
821
1087
|
x: number;
|
|
@@ -827,7 +1093,7 @@ declare global {
|
|
|
827
1093
|
pierce: boolean;
|
|
828
1094
|
}): void;
|
|
829
1095
|
|
|
830
|
-
/** Sets the speed of this world processor in instructions per tick. */
|
|
1096
|
+
/** Sets the speed of this world processor in instructions per tick. World processor ONLY. */
|
|
831
1097
|
function setRate(ipt: number): void;
|
|
832
1098
|
|
|
833
1099
|
/** Contains the variants of the `fetch` instruction. World processor ONLY. */
|
package/lib/eslib/lib.es5.d.ts
CHANGED
|
@@ -56,6 +56,29 @@ interface TemplateStringsArray extends ReadonlyArray<string> {
|
|
|
56
56
|
interface ImportMeta {}
|
|
57
57
|
|
|
58
58
|
interface Math {
|
|
59
|
+
/** Pi. This is the ratio of the circumference of a circle to its diameter. */
|
|
60
|
+
readonly PI: number;
|
|
61
|
+
|
|
62
|
+
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
|
|
63
|
+
readonly E: number;
|
|
64
|
+
/**
|
|
65
|
+
* Use this value to convert degrees to radians.
|
|
66
|
+
*
|
|
67
|
+
* ```js
|
|
68
|
+
* let radians = degrees * Math.degToRad;
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
readonly degToRad: number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Use this value to convert radians to degrees.
|
|
75
|
+
*
|
|
76
|
+
* ```js
|
|
77
|
+
* let degrees = radians * Math.radToDeg;
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
readonly radToDeg: number;
|
|
81
|
+
|
|
59
82
|
/**
|
|
60
83
|
* Returns the larger of two of supplied numeric expressions.
|
|
61
84
|
* @param a
|
package/lib/globals.d.ts
CHANGED
|
@@ -245,9 +245,6 @@ declare namespace LAccess {
|
|
|
245
245
|
const payloadCount: unique symbol;
|
|
246
246
|
const payloadType: unique symbol;
|
|
247
247
|
const enabled: unique symbol;
|
|
248
|
-
const shoot: unique symbol;
|
|
249
|
-
const shootp: unique symbol;
|
|
250
|
-
const config: unique symbol;
|
|
251
248
|
const color: unique symbol;
|
|
252
249
|
}
|
|
253
250
|
|
|
@@ -278,6 +275,7 @@ interface BuildingSymbolTable {
|
|
|
278
275
|
readonly slagHeater: unique symbol;
|
|
279
276
|
readonly phaseHeater: unique symbol;
|
|
280
277
|
readonly heatRedirector: unique symbol;
|
|
278
|
+
readonly heatRouter: unique symbol;
|
|
281
279
|
readonly slagIncinerator: unique symbol;
|
|
282
280
|
readonly carbideCrucible: unique symbol;
|
|
283
281
|
readonly slagCentrifuge: unique symbol;
|
|
@@ -546,6 +544,7 @@ interface EnvBlockSymbolTable {
|
|
|
546
544
|
readonly arkyicVent: unique symbol;
|
|
547
545
|
readonly yellowStoneVent: unique symbol;
|
|
548
546
|
readonly redStoneVent: unique symbol;
|
|
547
|
+
readonly crystallineVent: unique symbol;
|
|
549
548
|
readonly redmat: unique symbol;
|
|
550
549
|
readonly bluemat: unique symbol;
|
|
551
550
|
readonly grass: unique symbol;
|
package/lib/helpers.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Using this method is discouraged because most values are
|
|
7
7
|
* already accessible under the namespaces `Units`, `Blocks`,
|
|
8
|
-
* `Items`, `Liquids`, `ControlKind
|
|
8
|
+
* `Items`, `Liquids`, `ControlKind` and `Vars`.
|
|
9
9
|
*
|
|
10
10
|
* @param name The identifier of the value
|
|
11
11
|
*/
|
|
@@ -20,6 +20,7 @@ declare function getBuilding<T extends BasicBuilding = AnyBuilding>(
|
|
|
20
20
|
name: string
|
|
21
21
|
): T;
|
|
22
22
|
|
|
23
|
+
/** Concatenates a list of constant strings */
|
|
23
24
|
declare function concat(...strings: string[]): string;
|
|
24
25
|
|
|
25
26
|
/**
|