mlogjs 0.4.1 → 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/bin.cjs.map +1 -0
- package/dist/handlers/Statements.d.ts +1 -0
- package/dist/index.cjs +152 -48
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +152 -48
- package/dist/index.mjs.map +1 -0
- package/dist/instructions/SetInstruction.d.ts +2 -0
- package/dist/macros/Function.d.ts +2 -2
- package/dist/macros/Math.d.ts +2 -1
- package/dist/operators.d.ts +4 -4
- package/dist/types.d.ts +3 -0
- package/dist/values/BaseValue.d.ts +1 -0
- package/lib/commands.d.ts +300 -30
- 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 +1 -6
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,
|
|
@@ -272,11 +370,11 @@ declare global {
|
|
|
272
370
|
* Example:
|
|
273
371
|
* ```js
|
|
274
372
|
* const turret = getBuilding("cyclone1")
|
|
275
|
-
* // returns the
|
|
373
|
+
* // returns the furthest enemy unit
|
|
276
374
|
* const result = radar({
|
|
277
375
|
* building: turret,
|
|
278
376
|
* filters: ["enemy", "any", "any"],
|
|
279
|
-
* order:
|
|
377
|
+
* order: false,
|
|
280
378
|
* sort: "distance"
|
|
281
379
|
* });
|
|
282
380
|
* ```
|
|
@@ -298,24 +396,33 @@ declare global {
|
|
|
298
396
|
* This method allows you to use customly created symbols
|
|
299
397
|
* and sensor them on buildings.
|
|
300
398
|
* @param property The property to be sensed on the building
|
|
301
|
-
* @param target
|
|
399
|
+
* @param target The object that will be "sensed"
|
|
302
400
|
*
|
|
303
401
|
* Example:
|
|
304
|
-
*
|
|
305
|
-
* let myBuilding = getBuilding("container1")
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* let
|
|
310
|
-
*
|
|
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
|
+
* ```
|
|
311
410
|
*/
|
|
312
411
|
function sensor<T>(property: symbol, target: BasicBuilding | BasicUnit): T;
|
|
313
412
|
|
|
314
413
|
/**
|
|
315
|
-
* 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
|
+
* ```
|
|
316
422
|
*/
|
|
317
423
|
function wait(seconds: number): void;
|
|
318
424
|
|
|
425
|
+
/** Looks up content symbols by their index. */
|
|
319
426
|
namespace lookup {
|
|
320
427
|
/**
|
|
321
428
|
* Looks up a block symbol by it's index on the content registry.
|
|
@@ -378,11 +485,28 @@ declare global {
|
|
|
378
485
|
* Packs RGBA color information into a single number.
|
|
379
486
|
*
|
|
380
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
|
+
* ```
|
|
381
496
|
*/
|
|
382
497
|
function packColor(r: number, g: number, b: number, a: number): number;
|
|
383
498
|
|
|
384
499
|
/**
|
|
385
|
-
* 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
|
+
* ```
|
|
386
510
|
*/
|
|
387
511
|
function unitBind(type: UnitSymbol): void;
|
|
388
512
|
|
|
@@ -439,6 +563,19 @@ declare global {
|
|
|
439
563
|
* Makes the unit bound to this processor target an unit with velocity prediction
|
|
440
564
|
* @param options.unit The shoot target
|
|
441
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
|
+
* ```
|
|
442
579
|
*/
|
|
443
580
|
function targetp(options: {
|
|
444
581
|
/** The shoot target */
|
|
@@ -449,8 +586,22 @@ declare global {
|
|
|
449
586
|
|
|
450
587
|
/**
|
|
451
588
|
* Makes the unit bound to this processor drop it's held items onto the given target
|
|
452
|
-
* @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
|
|
453
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
|
+
* ```
|
|
454
605
|
*/
|
|
455
606
|
function itemDrop(
|
|
456
607
|
target: BasicBuilding | typeof Blocks.air,
|
|
@@ -462,6 +613,16 @@ declare global {
|
|
|
462
613
|
* @param target The building that will have it's items taken
|
|
463
614
|
* @param item The kind of item to take
|
|
464
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
|
+
* ```
|
|
465
626
|
*/
|
|
466
627
|
function itemTake(
|
|
467
628
|
target: BasicBuilding,
|
|
@@ -505,17 +666,30 @@ declare global {
|
|
|
505
666
|
* @param options.block The kind of building to build
|
|
506
667
|
* @param options.rotation The rotation of the building, ranges from 0 to 3
|
|
507
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
|
+
* ```
|
|
508
679
|
*/
|
|
509
680
|
function build(options: {
|
|
510
681
|
x: number;
|
|
511
682
|
y: number;
|
|
683
|
+
/** The kind of building to build */
|
|
512
684
|
block: BuildingSymbol;
|
|
685
|
+
/** The rotation of the building, ranges from 0 to 3 */
|
|
513
686
|
rotation: number;
|
|
687
|
+
/** The config of the building */
|
|
514
688
|
config?: unknown;
|
|
515
689
|
}): void;
|
|
516
690
|
|
|
517
691
|
/**
|
|
518
|
-
* 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
|
|
519
693
|
*/
|
|
520
694
|
function getBlock<T extends BasicBuilding = AnyBuilding>(
|
|
521
695
|
x: number,
|
|
@@ -536,10 +710,10 @@ declare global {
|
|
|
536
710
|
*
|
|
537
711
|
* Example:
|
|
538
712
|
* ```js
|
|
539
|
-
* // returns the
|
|
713
|
+
* // returns the furthest enemy unit
|
|
540
714
|
* const result = unitRadar({
|
|
541
715
|
* filters: ["enemy", "any", "any"],
|
|
542
|
-
* order:
|
|
716
|
+
* order: false,
|
|
543
717
|
* sort: "distance",
|
|
544
718
|
* });
|
|
545
719
|
* ```
|
|
@@ -553,10 +727,19 @@ declare global {
|
|
|
553
727
|
sort: TRadarSort;
|
|
554
728
|
}): T;
|
|
555
729
|
|
|
730
|
+
/** Uses the unit bound to this processor to find specific types of blocks */
|
|
556
731
|
namespace unitLocate {
|
|
557
732
|
/**
|
|
558
733
|
* Uses the unit bound to this processor to find an ore vein anywhere on the map
|
|
559
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
|
+
* ```
|
|
560
743
|
*/
|
|
561
744
|
function ore(
|
|
562
745
|
ore: ItemSymbol
|
|
@@ -566,6 +749,42 @@ declare global {
|
|
|
566
749
|
* Uses the unit bound to this processor to find a building anywhere on the map
|
|
567
750
|
* @param options.group The group that the building belongs to
|
|
568
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
|
+
* ```
|
|
569
788
|
*/
|
|
570
789
|
function building<T extends BasicBuilding = AnyBuilding>(options: {
|
|
571
790
|
/** The group that the building belongs to */
|
|
@@ -577,24 +796,66 @@ declare global {
|
|
|
577
796
|
/**
|
|
578
797
|
* Uses the unit bound to this processor to find an enemy spawn anywhere on the map.
|
|
579
798
|
*
|
|
580
|
-
*
|
|
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
|
+
* ```
|
|
581
814
|
*/
|
|
582
815
|
function spawn<T extends BasicBuilding = AnyBuilding>():
|
|
583
816
|
| [found: false]
|
|
584
817
|
| [found: true, x: number, y: number, building: T];
|
|
585
818
|
|
|
586
819
|
/**
|
|
587
|
-
* 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
|
+
* ```
|
|
588
832
|
*/
|
|
589
833
|
function damaged<T extends BasicBuilding = AnyBuilding>():
|
|
590
834
|
| [found: false]
|
|
591
835
|
| [found: true, x: number, y: number, building: T];
|
|
592
836
|
}
|
|
593
837
|
|
|
594
|
-
/**
|
|
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
|
+
*/
|
|
595
848
|
function endScript(): never;
|
|
596
849
|
|
|
597
|
-
/**
|
|
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
|
+
*/
|
|
598
859
|
function stopScript(): never;
|
|
599
860
|
|
|
600
861
|
/** Gets block data from the map. Available ONLY for world processors. */
|
|
@@ -615,6 +876,7 @@ declare global {
|
|
|
615
876
|
): T | null;
|
|
616
877
|
}
|
|
617
878
|
|
|
879
|
+
/** Sets block data on a given location. World processor ONLY. */
|
|
618
880
|
namespace setBlock {
|
|
619
881
|
// TODO: maybe have a separate floor symbol type?
|
|
620
882
|
/** Sets the floor of the tile at the given location. */
|
|
@@ -633,12 +895,17 @@ declare global {
|
|
|
633
895
|
}): void;
|
|
634
896
|
}
|
|
635
897
|
|
|
636
|
-
/**
|
|
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
|
+
*/
|
|
637
903
|
function spawnUnit<T extends BasicUnit = AnyUnit>(options: {
|
|
638
904
|
type: UnitSymbol;
|
|
639
905
|
x: number;
|
|
640
906
|
y: number;
|
|
641
907
|
team: TeamSymbol;
|
|
908
|
+
/** The initial rotation of the unit in degrees. */
|
|
642
909
|
rotation?: number;
|
|
643
910
|
}): T;
|
|
644
911
|
|
|
@@ -722,8 +989,8 @@ declare global {
|
|
|
722
989
|
*
|
|
723
990
|
* ```js
|
|
724
991
|
* // enables lighting and sets the color to gray
|
|
725
|
-
* setRule(
|
|
726
|
-
* setRule(
|
|
992
|
+
* setRule.lighting(true);
|
|
993
|
+
* setRule.ambientLight(packColor(0.5, 0.5, 0.5, 1));
|
|
727
994
|
* ```
|
|
728
995
|
*/
|
|
729
996
|
function ambientLight(rgbaData: number): void;
|
|
@@ -743,11 +1010,13 @@ declare global {
|
|
|
743
1010
|
*/
|
|
744
1011
|
function unitBuildSpeed(team: TeamSymbol, multiplier: number): void;
|
|
745
1012
|
|
|
746
|
-
/** Sets the
|
|
1013
|
+
/** Sets the build cost multiplier for constructing units. */
|
|
1014
|
+
function unitCost(team: TeamSymbol, multiplier: number): void;
|
|
747
1015
|
|
|
1016
|
+
/** Sets the damage multiplier for units on a given team. */
|
|
748
1017
|
function unitDamage(team: TeamSymbol, multiplier: number): void;
|
|
749
|
-
/** Sets the block health multiplier for a given team. */
|
|
750
1018
|
|
|
1019
|
+
/** Sets the block health multiplier for a given team. */
|
|
751
1020
|
function blockHealth(team: TeamSymbol, multiplier: number): void;
|
|
752
1021
|
|
|
753
1022
|
/** Sets the block damage multiplier for a given team. */
|
|
@@ -802,6 +1071,7 @@ declare global {
|
|
|
802
1071
|
function toast(duration: number): void;
|
|
803
1072
|
}
|
|
804
1073
|
|
|
1074
|
+
/** Controls the player camera. World processor ONLY. */
|
|
805
1075
|
namespace cutscene {
|
|
806
1076
|
/** Moves the player's camera to the given location. */
|
|
807
1077
|
function pan(options: { x: number; y: number; speed: number }): void;
|
|
@@ -811,7 +1081,7 @@ declare global {
|
|
|
811
1081
|
function stop(): void;
|
|
812
1082
|
}
|
|
813
1083
|
|
|
814
|
-
/** Creates an explosion */
|
|
1084
|
+
/** Creates an explosion. World processor ONLY. */
|
|
815
1085
|
function explosion(options: {
|
|
816
1086
|
team: TeamSymbol;
|
|
817
1087
|
x: number;
|
|
@@ -823,7 +1093,7 @@ declare global {
|
|
|
823
1093
|
pierce: boolean;
|
|
824
1094
|
}): void;
|
|
825
1095
|
|
|
826
|
-
/** 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. */
|
|
827
1097
|
function setRate(ipt: number): void;
|
|
828
1098
|
|
|
829
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
|
/**
|
package/lib/kinds.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ interface BasicUnit
|
|
|
11
11
|
Flagged,
|
|
12
12
|
Controllable,
|
|
13
13
|
Nameable,
|
|
14
|
-
WithSpeed
|
|
14
|
+
WithSpeed,
|
|
15
|
+
WithColor,
|
|
16
|
+
WithTeam {}
|
|
15
17
|
|
|
16
18
|
interface AnyUnit extends BasicUnit, Boosted {}
|
|
17
19
|
|
|
@@ -27,7 +29,8 @@ interface BasicBuilding
|
|
|
27
29
|
Ranged,
|
|
28
30
|
Typed<BuildingSymbol>,
|
|
29
31
|
WithEnable,
|
|
30
|
-
|
|
32
|
+
WithColor,
|
|
33
|
+
WithTeam {}
|
|
31
34
|
|
|
32
35
|
interface BasicTurret extends BasicBuilding, Shooting, WithProgress {}
|
|
33
36
|
|