mlogjs 0.2.1 → 0.3.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/LICENSE +1 -1
- package/README.md +2 -2
- package/build/Compiler.js +104 -99
- package/build/Compiler.js.map +1 -1
- package/build/CompilerError.js +11 -0
- package/build/CompilerError.js.map +1 -0
- package/build/Scope.js +70 -60
- package/build/Scope.js.map +1 -1
- package/build/bin.js +74 -60
- package/build/bin.js.map +1 -1
- package/build/handlers/BlockStatement.js +13 -13
- package/build/handlers/BlockStatement.js.map +1 -1
- package/build/handlers/CallExpression.js +19 -19
- package/build/handlers/CallExpression.js.map +1 -1
- package/build/handlers/File.js +9 -0
- package/build/handlers/File.js.map +1 -0
- package/build/handlers/ForStatement.js +31 -31
- package/build/handlers/ForStatement.js.map +1 -1
- package/build/handlers/Function.js +46 -35
- package/build/handlers/Function.js.map +1 -1
- package/build/handlers/Identifier.js +7 -7
- package/build/handlers/IfStatement.js +24 -24
- package/build/handlers/IfStatement.js.map +1 -1
- package/build/handlers/Literal.js +14 -17
- package/build/handlers/Literal.js.map +1 -1
- package/build/handlers/Object.js +54 -43
- package/build/handlers/Object.js.map +1 -1
- package/build/handlers/OperationExpressions.js +37 -32
- package/build/handlers/OperationExpressions.js.map +1 -1
- package/build/handlers/Program.js +8 -8
- package/build/handlers/Program.js.map +1 -1
- package/build/handlers/Statements.js +29 -29
- package/build/handlers/Statements.js.map +1 -1
- package/build/handlers/TemplateExpression.js +17 -17
- package/build/handlers/TemplateExpression.js.map +1 -1
- package/build/handlers/VariableDeclaration.js +71 -55
- package/build/handlers/VariableDeclaration.js.map +1 -1
- package/build/handlers/WhileStatement.js +22 -22
- package/build/handlers/WhileStatement.js.map +1 -1
- package/build/handlers/index.js +31 -30
- package/build/handlers/index.js.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/initScope.js +39 -39
- package/build/instructions/AddressResolver.js +30 -30
- package/build/instructions/ControlInstructions.js +22 -22
- package/build/instructions/EndInstruction.js +10 -10
- package/build/instructions/InstructionBase.js +20 -20
- package/build/instructions/InstructionBase.js.map +1 -1
- package/build/instructions/JumpInstruction.js +21 -21
- package/build/instructions/JumpInstruction.js.map +1 -1
- package/build/instructions/OperationInstruction.js +10 -10
- package/build/instructions/OperationInstruction.js.map +1 -1
- package/build/instructions/SetCounterInstruction.js +10 -10
- package/build/instructions/SetInstruction.js +10 -10
- package/build/instructions/ZeroSpaceInstruction.js +10 -10
- package/build/instructions/index.js +25 -25
- package/build/macros/Building.js +88 -80
- package/build/macros/Building.js.map +1 -1
- package/build/macros/Function.js +19 -19
- package/build/macros/Function.js.map +1 -1
- package/build/macros/Math.js +61 -56
- package/build/macros/Math.js.map +1 -1
- package/build/macros/Memory.js +62 -60
- package/build/macros/Memory.js.map +1 -1
- package/build/macros/Namespace.js +110 -97
- package/build/macros/Namespace.js.map +1 -1
- package/build/macros/Other.js +20 -19
- package/build/macros/Other.js.map +1 -1
- package/build/macros/RawValue.js +16 -15
- package/build/macros/RawValue.js.map +1 -1
- package/build/macros/commands/Control.js +25 -24
- package/build/macros/commands/Control.js.map +1 -1
- package/build/macros/commands/Draw.js +39 -38
- package/build/macros/commands/Draw.js.map +1 -1
- package/build/macros/commands/DrawFlush.js +17 -16
- package/build/macros/commands/DrawFlush.js.map +1 -1
- package/build/macros/commands/GetLink.js +24 -20
- package/build/macros/commands/GetLink.js.map +1 -1
- package/build/macros/commands/Lookup.js +24 -23
- package/build/macros/commands/Lookup.js.map +1 -1
- package/build/macros/commands/Print.js +17 -13
- package/build/macros/commands/Print.js.map +1 -1
- package/build/macros/commands/PrintFlush.js +17 -16
- package/build/macros/commands/PrintFlush.js.map +1 -1
- package/build/macros/commands/Radar.js +64 -60
- package/build/macros/commands/Radar.js.map +1 -1
- package/build/macros/commands/Sensor.js +20 -19
- package/build/macros/commands/Sensor.js.map +1 -1
- package/build/macros/commands/UnitBind.js +17 -16
- package/build/macros/commands/UnitBind.js.map +1 -1
- package/build/macros/commands/UnitControl.js +72 -67
- package/build/macros/commands/UnitControl.js.map +1 -1
- package/build/macros/commands/UnitLocate.js +75 -54
- package/build/macros/commands/UnitLocate.js.map +1 -1
- package/build/macros/commands/UnitRadar.js +47 -40
- package/build/macros/commands/UnitRadar.js.map +1 -1
- package/build/macros/commands/Wait.js +18 -17
- package/build/macros/commands/Wait.js.map +1 -1
- package/build/macros/commands/index.js +32 -32
- package/build/macros/index.js +39 -39
- package/build/operators.js +101 -101
- package/build/operators.js.map +1 -1
- package/build/types.js +27 -27
- package/build/types.js.map +1 -1
- package/build/utils.js +17 -12
- package/build/utils.js.map +1 -1
- package/build/values/BaseValue.js +111 -111
- package/build/values/BaseValue.js.map +1 -1
- package/build/values/FunctionValue.js +115 -103
- package/build/values/FunctionValue.js.map +1 -1
- package/build/values/LiteralValue.js +88 -87
- package/build/values/LiteralValue.js.map +1 -1
- package/build/values/ObjectValue.js +54 -49
- package/build/values/ObjectValue.js.map +1 -1
- package/build/values/StoreValue.js +31 -30
- package/build/values/StoreValue.js.map +1 -1
- package/build/values/TempValue.js +77 -66
- package/build/values/TempValue.js.map +1 -1
- package/build/values/VoidValue.js +31 -30
- package/build/values/VoidValue.js.map +1 -1
- package/build/values/index.js +22 -22
- package/dist/bin.cjs +82 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/index.cjs +2220 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +2195 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/Compiler.d.ts +26 -0
- package/dist/types/CompilerError.d.ts +9 -0
- package/dist/types/Scope.d.ts +24 -0
- package/dist/types/bin.d.ts +1 -0
- package/dist/types/handlers/BlockStatement.d.ts +2 -0
- package/dist/types/handlers/CallExpression.d.ts +3 -0
- package/dist/types/handlers/File.d.ts +2 -0
- package/dist/types/handlers/ForStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/Function.d.ts +5 -4
- package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
- package/dist/types/handlers/IfStatement.d.ts +2 -0
- package/dist/types/handlers/Literal.d.ts +5 -0
- package/{build → dist/types}/handlers/Object.d.ts +6 -4
- package/{build → dist/types}/handlers/OperationExpressions.d.ts +8 -7
- package/dist/types/handlers/Program.d.ts +2 -0
- package/dist/types/handlers/Statements.d.ts +5 -0
- package/dist/types/handlers/TemplateExpression.d.ts +2 -0
- package/dist/types/handlers/Typescript.d.ts +7 -0
- package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
- package/dist/types/handlers/WhileStatement.d.ts +3 -0
- package/{build → dist/types}/handlers/index.d.ts +16 -14
- package/dist/types/index.d.ts +2 -0
- package/{build → dist/types}/initScope.d.ts +5 -2
- package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
- package/{build → dist/types}/instructions/ControlInstructions.d.ts +8 -11
- package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
- package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
- package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetInstruction.d.ts +6 -5
- package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/index.d.ts +9 -9
- package/{build → dist/types}/macros/Building.d.ts +10 -11
- package/dist/types/macros/Entities.d.ts +11 -0
- package/dist/types/macros/Function.d.ts +13 -0
- package/dist/types/macros/GetGlobal.d.ts +5 -0
- package/{build → dist/types}/macros/Math.d.ts +5 -5
- package/{build → dist/types}/macros/Memory.d.ts +5 -5
- package/{build → dist/types}/macros/Namespace.d.ts +16 -21
- package/{build → dist/types}/macros/Other.d.ts +5 -5
- package/{build → dist/types}/macros/RawValue.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
- package/dist/types/macros/commands/Draw.d.ts +5 -0
- package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
- package/{build/macros/commands/Draw.d.ts → dist/types/macros/commands/End.d.ts} +5 -5
- package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
- package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
- package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
- package/dist/types/macros/commands/UnitControl.d.ts +5 -0
- package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
- package/{build → dist/types}/macros/commands/index.d.ts +15 -14
- package/{build → dist/types}/macros/index.d.ts +6 -7
- package/{build → dist/types}/operators.d.ts +25 -25
- package/dist/types/types.d.ts +224 -0
- package/dist/types/utils.d.ts +30 -0
- package/dist/types/values/BaseValue.d.ts +7 -0
- package/dist/types/values/DestructuringValue.d.ts +17 -0
- package/dist/types/values/FunctionValue.d.ts +47 -0
- package/{build → dist/types}/values/LiteralValue.d.ts +13 -12
- package/dist/types/values/ObjectValue.d.ts +23 -0
- package/dist/types/values/SenseableValue.d.ts +23 -0
- package/dist/types/values/StackValue.d.ts +16 -0
- package/dist/types/values/StoreValue.d.ts +15 -0
- package/{build → dist/types}/values/TempValue.d.ts +19 -12
- package/dist/types/values/ValueOwner.d.ts +27 -0
- package/dist/types/values/VoidValue.d.ts +16 -0
- package/{build → dist/types}/values/index.d.ts +7 -6
- package/lib/commands.d.ts +242 -36
- package/lib/eslib/lib.es5.d.ts +1 -1
- package/lib/globals.d.ts +172 -159
- package/lib/helpers.d.ts +2 -2
- package/lib/memory.d.ts +1 -1
- package/lib/traits.d.ts +130 -110
- package/package.json +33 -38
- package/build/Compiler.d.ts +0 -18
- package/build/Scope.d.ts +0 -26
- package/build/bin.d.ts +0 -2
- package/build/handlers/BlockStatement.d.ts +0 -2
- package/build/handlers/CallExpression.d.ts +0 -3
- package/build/handlers/ForStatement.d.ts +0 -2
- package/build/handlers/IfStatement.d.ts +0 -2
- package/build/handlers/Literal.d.ts +0 -2
- package/build/handlers/Program.d.ts +0 -2
- package/build/handlers/Statements.d.ts +0 -5
- package/build/handlers/TemplateExpression.d.ts +0 -2
- package/build/handlers/VariableDeclaration.d.ts +0 -3
- package/build/handlers/WhileStatement.d.ts +0 -2
- package/build/index.d.ts +0 -1
- package/build/macros/Function.d.ts +0 -12
- package/build/macros/commands/UnitControl.d.ts +0 -5
- package/build/types.d.ts +0 -49
- package/build/utils.d.ts +0 -3
- package/build/values/BaseValue.d.ts +0 -5
- package/build/values/FunctionValue.d.ts +0 -34
- package/build/values/ObjectValue.d.ts +0 -17
- package/build/values/StoreValue.d.ts +0 -11
- package/build/values/VoidValue.d.ts +0 -11
- package/dist/mlogjs.es.js +0 -6366
- package/dist/mlogjs.umd.js +0 -8
package/lib/commands.d.ts
CHANGED
|
@@ -12,40 +12,36 @@ declare global {
|
|
|
12
12
|
function print(...items: unknown[]): void;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Fills the screen with a color.
|
|
16
16
|
*
|
|
17
|
-
* Warning:
|
|
18
|
-
* which is used by `drawFlush` to actually draw content on a display.
|
|
17
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
19
18
|
*/
|
|
20
19
|
function draw(mode: "clear", r: number, g: number, b: number): void;
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
22
|
+
* Sets the color for the next drawing operations.
|
|
24
23
|
*
|
|
25
|
-
* Warning:
|
|
26
|
-
* which is used by `drawFlush` to actually draw content on a display.
|
|
24
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
27
25
|
*/
|
|
28
26
|
function draw(
|
|
29
27
|
mode: "color",
|
|
30
28
|
r: number,
|
|
31
29
|
g: number,
|
|
32
30
|
b: number,
|
|
33
|
-
a
|
|
31
|
+
a?: number
|
|
34
32
|
): void;
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
|
-
*
|
|
35
|
+
* Sets the width of the next lines to be drawn.
|
|
38
36
|
*
|
|
39
|
-
* Warning:
|
|
40
|
-
* which is used by `drawFlush` to actually draw content on a display.
|
|
37
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
41
38
|
*/
|
|
42
39
|
function draw(mode: "stroke", width: number): void;
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
|
-
*
|
|
42
|
+
* Draws a line between two points.
|
|
46
43
|
*
|
|
47
|
-
* Warning:
|
|
48
|
-
* which is used by `drawFlush` to actually draw content on a display.
|
|
44
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
49
45
|
*/
|
|
50
46
|
function draw(
|
|
51
47
|
mode: "line",
|
|
@@ -56,10 +52,9 @@ declare global {
|
|
|
56
52
|
): void;
|
|
57
53
|
|
|
58
54
|
/**
|
|
59
|
-
*
|
|
55
|
+
* Draws a filled rectangle.
|
|
60
56
|
*
|
|
61
|
-
* Warning:
|
|
62
|
-
* which is used by `drawFlush` to actually draw content on a display.
|
|
57
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
63
58
|
*/
|
|
64
59
|
function draw(
|
|
65
60
|
mode: "rect",
|
|
@@ -70,10 +65,9 @@ declare global {
|
|
|
70
65
|
): void;
|
|
71
66
|
|
|
72
67
|
/**
|
|
73
|
-
*
|
|
68
|
+
* Draws a rectangle outline.
|
|
74
69
|
*
|
|
75
|
-
* Warning:
|
|
76
|
-
* which is used by `drawFlush` to actually draw content on a display.
|
|
70
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
77
71
|
*/
|
|
78
72
|
function draw(
|
|
79
73
|
mode: "lineRect",
|
|
@@ -84,10 +78,12 @@ declare global {
|
|
|
84
78
|
): void;
|
|
85
79
|
|
|
86
80
|
/**
|
|
87
|
-
*
|
|
81
|
+
* Draws a filled, regular polygon.
|
|
82
|
+
* @param sides The number of sides the polygon should have
|
|
83
|
+
* @param radius The smallest distance between a line and the center of the polygon
|
|
84
|
+
* @param rotation The rotation of the polygon in degrees
|
|
88
85
|
*
|
|
89
|
-
* Warning:
|
|
90
|
-
* which is used by `drawFlush` to actually draw content on a display.
|
|
86
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
91
87
|
*/
|
|
92
88
|
function draw(
|
|
93
89
|
mode: "poly",
|
|
@@ -99,10 +95,13 @@ declare global {
|
|
|
99
95
|
): void;
|
|
100
96
|
|
|
101
97
|
/**
|
|
102
|
-
*
|
|
98
|
+
* Draws the outline of a regular polygon.
|
|
99
|
+
* @param sides The number of sides the polygon should have
|
|
100
|
+
* @param radius The smallest distance between a line and the center of the polygon
|
|
101
|
+
* @param rotation The rotation of the polygon in degrees
|
|
103
102
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
103
|
+
*
|
|
104
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
106
105
|
*/
|
|
107
106
|
function draw(
|
|
108
107
|
mode: "linePoly",
|
|
@@ -114,10 +113,9 @@ declare global {
|
|
|
114
113
|
): void;
|
|
115
114
|
|
|
116
115
|
/**
|
|
117
|
-
*
|
|
116
|
+
* Draws a filled triangle.
|
|
118
117
|
*
|
|
119
|
-
* Warning:
|
|
120
|
-
* which is used by `drawFlush` to actually draw content on a display.
|
|
118
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
121
119
|
*/
|
|
122
120
|
function draw(
|
|
123
121
|
mode: "triangle",
|
|
@@ -130,10 +128,20 @@ declare global {
|
|
|
130
128
|
): void;
|
|
131
129
|
|
|
132
130
|
/**
|
|
133
|
-
*
|
|
131
|
+
* Draws an image of the respective content. (like `Units.dagger` and `Blocks.router`)
|
|
132
|
+
*
|
|
133
|
+
* Warning: nothing is drawn until `drawFlush` is called.
|
|
134
|
+
* @param image The symbol for the image to be drawn.
|
|
135
|
+
* @param rotation The rotation of the image in degrees.
|
|
136
|
+
*
|
|
137
|
+
* Example:
|
|
138
|
+
* ```js
|
|
139
|
+
* // draw a router
|
|
140
|
+
* draw("image", 30, 30, Blocks.router, 15, 0);
|
|
134
141
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
142
|
+
* // draw the unit bound to the processor
|
|
143
|
+
* draw("image", 60, 60, Vars.unit.type, 15, 0);
|
|
144
|
+
* ```
|
|
137
145
|
*/
|
|
138
146
|
function draw(
|
|
139
147
|
mode: "image",
|
|
@@ -160,16 +168,34 @@ declare global {
|
|
|
160
168
|
|
|
161
169
|
/**
|
|
162
170
|
* Gets a block link by its index.
|
|
171
|
+
*
|
|
172
|
+
* To make safe queries it is recommended to check an index
|
|
173
|
+
* before trying to get a link. This can be done by using `Vars.links`.
|
|
163
174
|
* @param index
|
|
175
|
+
*
|
|
176
|
+
* Example:
|
|
177
|
+
* ```js
|
|
178
|
+
* if(index < Vars.links) {
|
|
179
|
+
* myBlock = getLink(index)
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
164
182
|
*/
|
|
165
183
|
function getLink<T extends BasicBuilding = AnyBuilding>(index: number): T;
|
|
166
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Sets whether the building is enabled or disabled.
|
|
187
|
+
*/
|
|
167
188
|
function control(
|
|
168
189
|
kind: "enabled",
|
|
169
190
|
building: BasicBuilding,
|
|
170
191
|
value: boolean
|
|
171
192
|
): void;
|
|
172
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Makes the building shoot or aim at the given position
|
|
196
|
+
* @param building The shooting building
|
|
197
|
+
* @param shoot `true` to shoot, `false` to just aim at the position
|
|
198
|
+
*/
|
|
173
199
|
function control(
|
|
174
200
|
kind: "shoot",
|
|
175
201
|
building: BasicBuilding & Shooting,
|
|
@@ -178,6 +204,12 @@ declare global {
|
|
|
178
204
|
shoot: boolean
|
|
179
205
|
): void;
|
|
180
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Shoot at an unit with velocity prediction
|
|
209
|
+
* @param building The shooting building
|
|
210
|
+
* @param unit The target unit
|
|
211
|
+
* @param shoot `true` to shoot, `false` to just aim
|
|
212
|
+
*/
|
|
181
213
|
function control(
|
|
182
214
|
kind: "shootp",
|
|
183
215
|
building: BasicBuilding & Shooting,
|
|
@@ -185,12 +217,18 @@ declare global {
|
|
|
185
217
|
shoot: boolean
|
|
186
218
|
): void;
|
|
187
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Sets the config of a block (like the item of a sorter)
|
|
222
|
+
*/
|
|
188
223
|
function control(
|
|
189
224
|
kind: "config",
|
|
190
225
|
building: BasicBuilding,
|
|
191
226
|
value: symbol
|
|
192
227
|
): void;
|
|
193
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Sets the color of an illuminator
|
|
231
|
+
*/
|
|
194
232
|
function control(
|
|
195
233
|
kind: "color",
|
|
196
234
|
building: BasicBuilding,
|
|
@@ -209,10 +247,12 @@ declare global {
|
|
|
209
247
|
* (1 => first unit, 2 => second unit and so on)
|
|
210
248
|
* @param sort The method on which the results should be sorted
|
|
211
249
|
*
|
|
212
|
-
*
|
|
250
|
+
* Example:
|
|
251
|
+
* ```js
|
|
213
252
|
* const turret = getBuilding("cyclone1")
|
|
214
253
|
* // returns the second nearest enemy unit
|
|
215
254
|
* const result = radar(turret, "enemy", "any", "any", 2, "distance")
|
|
255
|
+
* ```
|
|
216
256
|
*/
|
|
217
257
|
function radar<T extends BasicUnit = AnyUnit>(
|
|
218
258
|
building: BasicBuilding,
|
|
@@ -231,58 +271,178 @@ declare global {
|
|
|
231
271
|
* @param property The property to be sensed on the building
|
|
232
272
|
* @param target
|
|
233
273
|
*
|
|
234
|
-
*
|
|
274
|
+
* Example:
|
|
275
|
+
* ```js
|
|
235
276
|
* let myBuilding = getBuilding("container1")
|
|
236
277
|
* // jsdoc doesn't allow me to type this
|
|
237
278
|
* // variable, but you should type it as a symbol in this case
|
|
238
279
|
* let myCustomSymbol = getVar("@custom-symbol") // problably defined by a mod
|
|
239
280
|
* let result = sensor(myCustomSymbol, myBuilding)
|
|
281
|
+
* ```
|
|
240
282
|
*/
|
|
241
283
|
function sensor<T>(property: symbol, target: BasicBuilding | BasicUnit): T;
|
|
242
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Stops the execution for the given amount of seconds
|
|
287
|
+
*/
|
|
243
288
|
function wait(seconds: number): void;
|
|
244
289
|
|
|
245
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Looks up a block symbol by it's index on the content registry.
|
|
292
|
+
*
|
|
293
|
+
* Use `Vars.blockCount` to check the maximum index allowed.
|
|
294
|
+
*
|
|
295
|
+
* Example:
|
|
296
|
+
* ```js
|
|
297
|
+
* if(index < Vars.blockCount) {
|
|
298
|
+
* let blockKind = lookup("block", index);
|
|
299
|
+
* }
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
function lookup(kind: "block", index: number): BlockSymbol;
|
|
303
|
+
/**
|
|
304
|
+
* Looks up an unit symbol by it's index on the content registry.
|
|
305
|
+
*
|
|
306
|
+
* Use `Vars.unitCount` to check the maximum index allowed.
|
|
307
|
+
*
|
|
308
|
+
* Example:
|
|
309
|
+
* ```js
|
|
310
|
+
* if(index < Vars.unitCount) {
|
|
311
|
+
* let unitKind = lookup("unit", index);
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
246
315
|
function lookup(kind: "unit", index: number): UnitSymbol | null;
|
|
316
|
+
/**
|
|
317
|
+
* Looks up an item symbol by it's index on the content registry.
|
|
318
|
+
*
|
|
319
|
+
* Use `Vars.itemCount` to check the maximum index allowed.
|
|
320
|
+
*
|
|
321
|
+
* Example:
|
|
322
|
+
* ```js
|
|
323
|
+
* if(index < Vars.itemCount) {
|
|
324
|
+
* let itemKind = lookup("item", index);
|
|
325
|
+
* }
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
247
328
|
function lookup(kind: "item", index: number): ItemSymbol | null;
|
|
329
|
+
/**
|
|
330
|
+
* Looks up a liquid symbol by it's index on the content registry.
|
|
331
|
+
*
|
|
332
|
+
* Use `Vars.liquidCount` to check the maximum index allowed.
|
|
333
|
+
*
|
|
334
|
+
* Example:
|
|
335
|
+
* ```js
|
|
336
|
+
* if(index < Vars.liquidCount) {
|
|
337
|
+
* let liquidKind = lookup("liquid", index);
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
248
341
|
function lookup(kind: "liquid", index: number): LiquidSymbol | null;
|
|
249
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Binds an unit to the this processor. The unit is accessible at `Vars.unit`
|
|
345
|
+
*/
|
|
250
346
|
function unitBind(type: UnitSymbol): void;
|
|
251
347
|
|
|
348
|
+
/**
|
|
349
|
+
* Makes the unit bound to this processor stop moving but
|
|
350
|
+
* allows it to keep doing it's action (like mining or building)
|
|
351
|
+
*/
|
|
252
352
|
function unitControl(mode: "idle"): void;
|
|
353
|
+
/**
|
|
354
|
+
* Makes the unit bound to this processor stop mining, building and moving
|
|
355
|
+
*/
|
|
253
356
|
function unitControl(mode: "stop"): void;
|
|
357
|
+
/**
|
|
358
|
+
* Makes the unit bound to this processor move to the given position
|
|
359
|
+
*/
|
|
254
360
|
function unitControl(mode: "move", x: number, y: number): void;
|
|
361
|
+
/**
|
|
362
|
+
* Makes the unit bound to this processor approach the given position at the given radius
|
|
363
|
+
* @param radius How distant to the position the unit can be
|
|
364
|
+
*/
|
|
255
365
|
function unitControl(
|
|
256
366
|
mode: "approach",
|
|
257
367
|
x: number,
|
|
258
368
|
y: number,
|
|
259
369
|
radius: number
|
|
260
370
|
): void;
|
|
371
|
+
/**
|
|
372
|
+
* Whether the unit bound to this processor should be boosted (floating)
|
|
373
|
+
*/
|
|
261
374
|
function unitControl(mode: "boost", enable: boolean): void;
|
|
375
|
+
/**
|
|
376
|
+
* Makes the unit bound to this processor move to the enemy spawn
|
|
377
|
+
*/
|
|
262
378
|
function unitControl(mode: "pathfind"): void;
|
|
379
|
+
/**
|
|
380
|
+
* Makes the unit bound to this processor shoot/aim at the given position
|
|
381
|
+
* @param shoot `true` to shoot, `false` to just aim
|
|
382
|
+
*/
|
|
263
383
|
function unitControl(
|
|
264
384
|
mode: "target",
|
|
265
385
|
x: number,
|
|
266
386
|
y: number,
|
|
267
387
|
shoot: boolean
|
|
268
388
|
): void;
|
|
389
|
+
/**
|
|
390
|
+
* Makes the unit bound to this processor target an unit with velocity prediction
|
|
391
|
+
* @param unit The shoot target
|
|
392
|
+
* @param shoot `true` to shoot, `false` to just aim
|
|
393
|
+
*/
|
|
269
394
|
function unitControl(mode: "targetp", unit: BasicUnit, shoot: boolean): void;
|
|
395
|
+
/**
|
|
396
|
+
* Makes the unit bound to this processor drop it's held items onto the given target
|
|
397
|
+
* @param target Where to drop the items, if `Blocks.air`, the unit will throw it's items away
|
|
398
|
+
* @param amount How many items should be dropped
|
|
399
|
+
*/
|
|
270
400
|
function unitControl(
|
|
271
401
|
mode: "itemDrop",
|
|
272
402
|
target: BasicBuilding | typeof Blocks.air,
|
|
273
403
|
amount: number
|
|
274
404
|
): void;
|
|
405
|
+
/**
|
|
406
|
+
* Makes the unit bound to this processor take items from a building
|
|
407
|
+
* @param target The building that will have it's items taken
|
|
408
|
+
* @param item The kind of item to take
|
|
409
|
+
* @param amount How many items should be taken
|
|
410
|
+
*/
|
|
275
411
|
function unitControl(
|
|
276
412
|
mode: "itemTake",
|
|
277
413
|
target: BasicBuilding,
|
|
278
414
|
item: ItemSymbol,
|
|
279
415
|
amount: number
|
|
280
416
|
): void;
|
|
417
|
+
/**
|
|
418
|
+
* Makes the unit bound to this processor drop one entity from it's payload
|
|
419
|
+
*/
|
|
281
420
|
function unitControl(mode: "payDrop"): void;
|
|
421
|
+
/**
|
|
422
|
+
* Makes the unit bound to this processor take an entity into it's payload
|
|
423
|
+
* @param takeUnits Whether to take units or buildings
|
|
424
|
+
*/
|
|
282
425
|
function unitControl(mode: "payTake", takeUnits: boolean): void;
|
|
426
|
+
/**
|
|
427
|
+
* Makes the unit bound to this processor enter/land on the
|
|
428
|
+
* payload block the unit is on
|
|
429
|
+
*/
|
|
283
430
|
function unitControl(mode: "payEnter"): void;
|
|
431
|
+
/**
|
|
432
|
+
* Makes the unit bound to this processor mine at the given position
|
|
433
|
+
*/
|
|
284
434
|
function unitControl(mode: "mine", x: number, y: number): void;
|
|
435
|
+
/**
|
|
436
|
+
* Sets the numeric flag of the unit bound to this processor
|
|
437
|
+
*/
|
|
285
438
|
function unitControl(mode: "flag", value: number): void;
|
|
439
|
+
/**
|
|
440
|
+
* Makes the unit bound to this processor build a building with the
|
|
441
|
+
* given properties
|
|
442
|
+
* @param block The kind of building to build
|
|
443
|
+
* @param rotation The rotation of the building, ranges from 0 to 3
|
|
444
|
+
* @param config The config of the building
|
|
445
|
+
*/
|
|
286
446
|
function unitControl(
|
|
287
447
|
mode: "build",
|
|
288
448
|
x: number,
|
|
@@ -291,11 +451,17 @@ declare global {
|
|
|
291
451
|
rotation: number,
|
|
292
452
|
config: unknown
|
|
293
453
|
): void;
|
|
454
|
+
/**
|
|
455
|
+
* Makes the unit bound to this processor data about a block at the given position
|
|
456
|
+
*/
|
|
294
457
|
function unitControl<T extends BasicBuilding = AnyBuilding>(
|
|
295
458
|
mode: "getBlock",
|
|
296
459
|
x: number,
|
|
297
460
|
y: number
|
|
298
461
|
): [type: BlockSymbol | null, building: T | null];
|
|
462
|
+
/**
|
|
463
|
+
* Checks if the unit bound to this processor is within a radius of a given position.
|
|
464
|
+
*/
|
|
299
465
|
function unitControl(
|
|
300
466
|
mode: "within",
|
|
301
467
|
x: number,
|
|
@@ -303,7 +469,22 @@ declare global {
|
|
|
303
469
|
radius: number
|
|
304
470
|
): boolean;
|
|
305
471
|
|
|
306
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Finds an unit near the unit bound to this processor
|
|
474
|
+
* @param filter1 First filter for selecting a target. Setting it to "any" ignores it
|
|
475
|
+
* @param filter2 Second filter for selecting a target. Setting it to "any" ignores it
|
|
476
|
+
* @param filter3 Third filter for selecting a target. Setting it to "any" ignores it
|
|
477
|
+
* @param order The n th unit that fits these requirements based on the sorting method
|
|
478
|
+
* (1 => first unit, 2 => second unit and so on)
|
|
479
|
+
* @param sort The method on which the results should be sorted
|
|
480
|
+
*
|
|
481
|
+
* Example:
|
|
482
|
+
* ```js
|
|
483
|
+
* // returns the second nearest enemy unit
|
|
484
|
+
* const result = unitRadar("enemy", "any", "any", 2, "distance")
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
function unitRadar<T extends BasicUnit = AnyUnit>(
|
|
307
488
|
filter1: TRadarFilter,
|
|
308
489
|
filter2: TRadarFilter,
|
|
309
490
|
filter3: TRadarFilter,
|
|
@@ -311,16 +492,41 @@ declare global {
|
|
|
311
492
|
sort: TRadarSort
|
|
312
493
|
): T;
|
|
313
494
|
|
|
495
|
+
/**
|
|
496
|
+
* Uses the unit bound to this processor to find an ore vein anywhere on the map
|
|
497
|
+
* @param ore The kind of item the ore should contain
|
|
498
|
+
*/
|
|
314
499
|
function unitLocate(
|
|
315
500
|
find: "ore",
|
|
316
501
|
ore: ItemSymbol
|
|
317
502
|
): [found: false] | [found: true, x: number, y: number];
|
|
503
|
+
/**
|
|
504
|
+
* Uses the unit bound to this processor to find a building anywhere on the map
|
|
505
|
+
* @param group The group that the building belongs to
|
|
506
|
+
* @param enemy Whether it should be an enemy building or an ally one
|
|
507
|
+
*/
|
|
318
508
|
function unitLocate<T extends BasicBuilding = AnyBuilding>(
|
|
319
509
|
find: "building",
|
|
320
510
|
group: TUnitLocateBuildingGroup,
|
|
321
511
|
enemy: boolean
|
|
322
512
|
): [found: false] | [found: true, x: number, y: number, building: T];
|
|
513
|
+
/**
|
|
514
|
+
* Uses the unit bound to this processor to find an enemy spawn anywhere on the map.
|
|
515
|
+
*
|
|
516
|
+
* May return a building (a core) or a position
|
|
517
|
+
* @param find
|
|
518
|
+
*/
|
|
323
519
|
function unitLocate<T extends BasicBuilding = AnyBuilding>(
|
|
324
|
-
find: "spawn"
|
|
520
|
+
find: "spawn"
|
|
325
521
|
): [found: false] | [found: true, x: number, y: number, building: T];
|
|
522
|
+
/**
|
|
523
|
+
* Uses the unit bound to this processor to find a damaged ally buildings anywhere on the map
|
|
524
|
+
* @param find
|
|
525
|
+
*/
|
|
526
|
+
function unitLocate<T extends BasicBuilding = AnyBuilding>(
|
|
527
|
+
find: "damaged"
|
|
528
|
+
): [found: false] | [found: true, x: number, y: number, building: T];
|
|
529
|
+
|
|
530
|
+
/** Ends the execution of this script */
|
|
531
|
+
function endScript(): never;
|
|
326
532
|
}
|
package/lib/eslib/lib.es5.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ interface Math {
|
|
|
120
120
|
sqrt(x: number): number;
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* Returns a random floating point number from 0 to `range` (excluding `range`
|
|
123
|
+
* Returns a random floating point number from 0 to `range` (excluding `range` itself)
|
|
124
124
|
* @param range
|
|
125
125
|
*/
|
|
126
126
|
rand(range: number): number;
|