mlogjs 0.3.0 → 0.4.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.
Files changed (278) hide show
  1. package/dist/Compiler.d.ts +39 -0
  2. package/dist/CompilerError.d.ts +33 -0
  3. package/dist/Scope.d.ts +24 -0
  4. package/dist/assertions.d.ts +28 -0
  5. package/dist/bin.cjs +7 -14
  6. package/dist/bin.cjs.map +1 -1
  7. package/dist/bin.d.ts +1 -0
  8. package/dist/handlers/BlockStatement.d.ts +2 -0
  9. package/dist/handlers/CallExpression.d.ts +4 -0
  10. package/dist/handlers/File.d.ts +2 -0
  11. package/dist/handlers/ForStatement.d.ts +2 -0
  12. package/dist/handlers/Function.d.ts +5 -0
  13. package/dist/handlers/Identifier.d.ts +2 -0
  14. package/dist/handlers/IfStatement.d.ts +2 -0
  15. package/dist/handlers/Literal.d.ts +5 -0
  16. package/dist/handlers/Object.d.ts +6 -0
  17. package/dist/handlers/OperationExpressions.d.ts +8 -0
  18. package/dist/handlers/Program.d.ts +2 -0
  19. package/dist/handlers/Statements.d.ts +5 -0
  20. package/dist/handlers/SwitchStatement.d.ts +2 -0
  21. package/dist/handlers/TemplateExpression.d.ts +2 -0
  22. package/dist/handlers/Typescript.d.ts +7 -0
  23. package/dist/handlers/VariableDeclaration.d.ts +3 -0
  24. package/dist/handlers/WhileStatement.d.ts +3 -0
  25. package/dist/handlers/index.d.ts +17 -0
  26. package/dist/index.cjs +1037 -315
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.mjs +1037 -315
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/initScope.d.ts +5 -0
  32. package/dist/instructions/AddressResolver.d.ts +12 -0
  33. package/dist/instructions/ControlInstructions.d.ts +10 -0
  34. package/dist/instructions/EndInstruction.d.ts +4 -0
  35. package/dist/instructions/InstructionBase.d.ts +14 -0
  36. package/dist/instructions/JumpInstruction.d.ts +16 -0
  37. package/dist/instructions/OperationInstruction.d.ts +5 -0
  38. package/dist/instructions/SetCounterInstruction.d.ts +5 -0
  39. package/dist/instructions/SetInstruction.d.ts +6 -0
  40. package/dist/instructions/ZeroSpaceInstruction.d.ts +4 -0
  41. package/dist/instructions/index.d.ts +9 -0
  42. package/dist/{types/macros/RawValue.d.ts → macros/Asm.d.ts} +1 -1
  43. package/dist/macros/Function.d.ts +13 -0
  44. package/dist/macros/GetGlobal.d.ts +5 -0
  45. package/dist/macros/Math.d.ts +5 -0
  46. package/dist/macros/Memory.d.ts +5 -0
  47. package/dist/macros/Namespace.d.ts +13 -0
  48. package/dist/macros/Other.d.ts +5 -0
  49. package/dist/macros/commands/ApplyStatus.d.ts +5 -0
  50. package/dist/macros/commands/Control.d.ts +5 -0
  51. package/dist/macros/commands/Cutscene.d.ts +5 -0
  52. package/dist/macros/commands/Draw.d.ts +5 -0
  53. package/dist/macros/commands/DrawFlush.d.ts +5 -0
  54. package/dist/macros/commands/End.d.ts +5 -0
  55. package/dist/macros/commands/Explosion.d.ts +5 -0
  56. package/dist/macros/commands/Fetch.d.ts +5 -0
  57. package/dist/macros/commands/FlushMessage.d.ts +5 -0
  58. package/dist/macros/commands/GetBlock.d.ts +5 -0
  59. package/dist/macros/commands/GetFlag.d.ts +5 -0
  60. package/dist/macros/commands/GetLink.d.ts +5 -0
  61. package/dist/macros/commands/Lookup.d.ts +5 -0
  62. package/dist/macros/commands/PackColor.d.ts +5 -0
  63. package/dist/macros/commands/Print.d.ts +5 -0
  64. package/dist/macros/commands/PrintFlush.d.ts +5 -0
  65. package/dist/macros/commands/Radar.d.ts +7 -0
  66. package/dist/macros/commands/Sensor.d.ts +5 -0
  67. package/dist/macros/commands/SetBlock.d.ts +5 -0
  68. package/dist/macros/commands/SetFlag.d.ts +5 -0
  69. package/dist/macros/commands/SetRate.d.ts +5 -0
  70. package/dist/macros/commands/SetRule.d.ts +5 -0
  71. package/dist/macros/commands/SpawnUnit.d.ts +5 -0
  72. package/dist/macros/commands/SpawnWave.d.ts +5 -0
  73. package/dist/macros/commands/Stop.d.ts +5 -0
  74. package/dist/macros/commands/UnitBind.d.ts +5 -0
  75. package/dist/macros/commands/UnitControl.d.ts +5 -0
  76. package/dist/macros/commands/UnitLocate.d.ts +5 -0
  77. package/dist/macros/commands/UnitRadar.d.ts +5 -0
  78. package/dist/macros/commands/Wait.d.ts +5 -0
  79. package/dist/macros/commands/index.d.ts +30 -0
  80. package/dist/macros/index.d.ts +6 -0
  81. package/dist/macros/util.d.ts +18 -0
  82. package/dist/operators.d.ts +25 -0
  83. package/dist/types/Compiler.d.ts +17 -4
  84. package/dist/types/CompilerError.d.ts +28 -4
  85. package/dist/types/assertions.d.ts +28 -0
  86. package/dist/types/handlers/CallExpression.d.ts +1 -0
  87. package/dist/types/handlers/SwitchStatement.d.ts +2 -0
  88. package/dist/types/handlers/index.d.ts +1 -0
  89. package/dist/types/index.d.ts +1 -0
  90. package/dist/types/instructions/ControlInstructions.d.ts +3 -1
  91. package/dist/types/instructions/InstructionBase.d.ts +5 -1
  92. package/dist/types/instructions/JumpInstruction.d.ts +1 -0
  93. package/dist/types/macros/Asm.d.ts +5 -0
  94. package/dist/types/macros/Namespace.d.ts +0 -3
  95. package/dist/types/macros/commands/ApplyStatus.d.ts +5 -0
  96. package/dist/types/macros/commands/Control.d.ts +2 -2
  97. package/dist/types/macros/commands/Cutscene.d.ts +5 -0
  98. package/dist/types/macros/commands/Draw.d.ts +2 -2
  99. package/dist/types/macros/commands/Explosion.d.ts +5 -0
  100. package/dist/types/macros/commands/Fetch.d.ts +5 -0
  101. package/dist/types/macros/commands/FlushMessage.d.ts +5 -0
  102. package/dist/types/macros/commands/GetBlock.d.ts +5 -0
  103. package/dist/types/macros/commands/GetFlag.d.ts +5 -0
  104. package/dist/types/macros/commands/Lookup.d.ts +2 -2
  105. package/dist/types/macros/commands/PackColor.d.ts +5 -0
  106. package/dist/types/macros/commands/Radar.d.ts +2 -2
  107. package/dist/types/macros/commands/SetBlock.d.ts +5 -0
  108. package/dist/types/macros/commands/SetFlag.d.ts +5 -0
  109. package/dist/types/macros/commands/SetRate.d.ts +5 -0
  110. package/dist/types/macros/commands/SetRule.d.ts +5 -0
  111. package/dist/types/macros/commands/SpawnUnit.d.ts +5 -0
  112. package/dist/types/macros/commands/SpawnWave.d.ts +5 -0
  113. package/dist/types/macros/commands/Stop.d.ts +5 -0
  114. package/dist/types/macros/commands/UnitControl.d.ts +3 -3
  115. package/dist/types/macros/commands/UnitLocate.d.ts +2 -2
  116. package/dist/types/macros/commands/index.d.ts +15 -0
  117. package/dist/types/macros/util.d.ts +18 -0
  118. package/dist/types/types.d.ts +14 -0
  119. package/dist/types/utils.d.ts +19 -2
  120. package/dist/types/values/BaseValue.d.ts +2 -0
  121. package/dist/types/values/FunctionValue.d.ts +1 -1
  122. package/dist/types/values/ObjectValue.d.ts +1 -1
  123. package/dist/types.d.ts +238 -0
  124. package/dist/utils.d.ts +47 -0
  125. package/dist/values/BaseValue.d.ts +9 -0
  126. package/dist/values/DestructuringValue.d.ts +17 -0
  127. package/dist/values/FunctionValue.d.ts +47 -0
  128. package/dist/values/LiteralValue.d.ts +13 -0
  129. package/dist/values/ObjectValue.d.ts +23 -0
  130. package/dist/values/SenseableValue.d.ts +23 -0
  131. package/dist/{types/values/StackValue.d.ts → values/StoreValue.d.ts} +5 -6
  132. package/dist/values/ValueOwner.d.ts +27 -0
  133. package/dist/values/VoidValue.d.ts +16 -0
  134. package/dist/values/index.d.ts +7 -0
  135. package/lib/commands.d.ts +849 -418
  136. package/lib/eslib/lib.es2015.core.d.ts +3 -0
  137. package/lib/globals.d.ts +331 -19
  138. package/lib/helpers.d.ts +14 -0
  139. package/lib/kinds.d.ts +3 -2
  140. package/lib/memory.d.ts +1 -1
  141. package/lib/traits.d.ts +6 -0
  142. package/lib/util.d.ts +16 -0
  143. package/package.json +15 -16
  144. package/build/Compiler.js +0 -105
  145. package/build/Compiler.js.map +0 -1
  146. package/build/CompilerError.js +0 -11
  147. package/build/CompilerError.js.map +0 -1
  148. package/build/Scope.js +0 -71
  149. package/build/Scope.js.map +0 -1
  150. package/build/bin.js +0 -75
  151. package/build/bin.js.map +0 -1
  152. package/build/handlers/BlockStatement.js +0 -14
  153. package/build/handlers/BlockStatement.js.map +0 -1
  154. package/build/handlers/CallExpression.js +0 -20
  155. package/build/handlers/CallExpression.js.map +0 -1
  156. package/build/handlers/File.js +0 -9
  157. package/build/handlers/File.js.map +0 -1
  158. package/build/handlers/ForStatement.js +0 -32
  159. package/build/handlers/ForStatement.js.map +0 -1
  160. package/build/handlers/Function.js +0 -47
  161. package/build/handlers/Function.js.map +0 -1
  162. package/build/handlers/Identifier.js +0 -8
  163. package/build/handlers/Identifier.js.map +0 -1
  164. package/build/handlers/IfStatement.js +0 -25
  165. package/build/handlers/IfStatement.js.map +0 -1
  166. package/build/handlers/Literal.js +0 -15
  167. package/build/handlers/Literal.js.map +0 -1
  168. package/build/handlers/Object.js +0 -55
  169. package/build/handlers/Object.js.map +0 -1
  170. package/build/handlers/OperationExpressions.js +0 -38
  171. package/build/handlers/OperationExpressions.js.map +0 -1
  172. package/build/handlers/Program.js +0 -9
  173. package/build/handlers/Program.js.map +0 -1
  174. package/build/handlers/Statements.js +0 -30
  175. package/build/handlers/Statements.js.map +0 -1
  176. package/build/handlers/TemplateExpression.js +0 -18
  177. package/build/handlers/TemplateExpression.js.map +0 -1
  178. package/build/handlers/VariableDeclaration.js +0 -72
  179. package/build/handlers/VariableDeclaration.js.map +0 -1
  180. package/build/handlers/WhileStatement.js +0 -23
  181. package/build/handlers/WhileStatement.js.map +0 -1
  182. package/build/handlers/index.js +0 -32
  183. package/build/handlers/index.js.map +0 -1
  184. package/build/index.js +0 -8
  185. package/build/index.js.map +0 -1
  186. package/build/initScope.js +0 -40
  187. package/build/initScope.js.map +0 -1
  188. package/build/instructions/AddressResolver.js +0 -31
  189. package/build/instructions/AddressResolver.js.map +0 -1
  190. package/build/instructions/ControlInstructions.js +0 -23
  191. package/build/instructions/ControlInstructions.js.map +0 -1
  192. package/build/instructions/EndInstruction.js +0 -11
  193. package/build/instructions/EndInstruction.js.map +0 -1
  194. package/build/instructions/InstructionBase.js +0 -21
  195. package/build/instructions/InstructionBase.js.map +0 -1
  196. package/build/instructions/JumpInstruction.js +0 -22
  197. package/build/instructions/JumpInstruction.js.map +0 -1
  198. package/build/instructions/OperationInstruction.js +0 -11
  199. package/build/instructions/OperationInstruction.js.map +0 -1
  200. package/build/instructions/SetCounterInstruction.js +0 -11
  201. package/build/instructions/SetCounterInstruction.js.map +0 -1
  202. package/build/instructions/SetInstruction.js +0 -11
  203. package/build/instructions/SetInstruction.js.map +0 -1
  204. package/build/instructions/ZeroSpaceInstruction.js +0 -11
  205. package/build/instructions/ZeroSpaceInstruction.js.map +0 -1
  206. package/build/instructions/index.js +0 -26
  207. package/build/instructions/index.js.map +0 -1
  208. package/build/macros/Building.js +0 -89
  209. package/build/macros/Building.js.map +0 -1
  210. package/build/macros/Function.js +0 -20
  211. package/build/macros/Function.js.map +0 -1
  212. package/build/macros/Math.js +0 -62
  213. package/build/macros/Math.js.map +0 -1
  214. package/build/macros/Memory.js +0 -63
  215. package/build/macros/Memory.js.map +0 -1
  216. package/build/macros/Namespace.js +0 -111
  217. package/build/macros/Namespace.js.map +0 -1
  218. package/build/macros/Other.js +0 -21
  219. package/build/macros/Other.js.map +0 -1
  220. package/build/macros/RawValue.js +0 -17
  221. package/build/macros/RawValue.js.map +0 -1
  222. package/build/macros/commands/Control.js +0 -26
  223. package/build/macros/commands/Control.js.map +0 -1
  224. package/build/macros/commands/Draw.js +0 -40
  225. package/build/macros/commands/Draw.js.map +0 -1
  226. package/build/macros/commands/DrawFlush.js +0 -18
  227. package/build/macros/commands/DrawFlush.js.map +0 -1
  228. package/build/macros/commands/GetLink.js +0 -25
  229. package/build/macros/commands/GetLink.js.map +0 -1
  230. package/build/macros/commands/Lookup.js +0 -25
  231. package/build/macros/commands/Lookup.js.map +0 -1
  232. package/build/macros/commands/Print.js +0 -18
  233. package/build/macros/commands/Print.js.map +0 -1
  234. package/build/macros/commands/PrintFlush.js +0 -18
  235. package/build/macros/commands/PrintFlush.js.map +0 -1
  236. package/build/macros/commands/Radar.js +0 -65
  237. package/build/macros/commands/Radar.js.map +0 -1
  238. package/build/macros/commands/Sensor.js +0 -21
  239. package/build/macros/commands/Sensor.js.map +0 -1
  240. package/build/macros/commands/UnitBind.js +0 -18
  241. package/build/macros/commands/UnitBind.js.map +0 -1
  242. package/build/macros/commands/UnitControl.js +0 -73
  243. package/build/macros/commands/UnitControl.js.map +0 -1
  244. package/build/macros/commands/UnitLocate.js +0 -76
  245. package/build/macros/commands/UnitLocate.js.map +0 -1
  246. package/build/macros/commands/UnitRadar.js +0 -48
  247. package/build/macros/commands/UnitRadar.js.map +0 -1
  248. package/build/macros/commands/Wait.js +0 -19
  249. package/build/macros/commands/Wait.js.map +0 -1
  250. package/build/macros/commands/index.js +0 -33
  251. package/build/macros/commands/index.js.map +0 -1
  252. package/build/macros/index.js +0 -40
  253. package/build/macros/index.js.map +0 -1
  254. package/build/operators.js +0 -102
  255. package/build/operators.js.map +0 -1
  256. package/build/types.js +0 -28
  257. package/build/types.js.map +0 -1
  258. package/build/utils.js +0 -18
  259. package/build/utils.js.map +0 -1
  260. package/build/values/BaseValue.js +0 -112
  261. package/build/values/BaseValue.js.map +0 -1
  262. package/build/values/FunctionValue.js +0 -116
  263. package/build/values/FunctionValue.js.map +0 -1
  264. package/build/values/LiteralValue.js +0 -89
  265. package/build/values/LiteralValue.js.map +0 -1
  266. package/build/values/ObjectValue.js +0 -55
  267. package/build/values/ObjectValue.js.map +0 -1
  268. package/build/values/StoreValue.js +0 -32
  269. package/build/values/StoreValue.js.map +0 -1
  270. package/build/values/TempValue.js +0 -78
  271. package/build/values/TempValue.js.map +0 -1
  272. package/build/values/VoidValue.js +0 -32
  273. package/build/values/VoidValue.js.map +0 -1
  274. package/build/values/index.js +0 -23
  275. package/build/values/index.js.map +0 -1
  276. package/dist/types/macros/Building.d.ts +0 -10
  277. package/dist/types/macros/Entities.d.ts +0 -11
  278. package/dist/types/values/TempValue.d.ts +0 -19
package/lib/commands.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import "./kind";
2
- import { TRadarFilter, TRadarSort, TUnitLocateBuildingGroup } from "./util";
2
+ import {
3
+ TRadarFilter,
4
+ TRadarSort,
5
+ TUnitEffect,
6
+ TUnitLocateBuildingGroup,
7
+ } from "./util";
3
8
  declare global {
4
9
  /**
5
10
  * Appends the items to the print buffer, calling this function
@@ -8,163 +13,186 @@ declare global {
8
13
  * To print the contents of the print buffer and empty it call `printFlush`.
9
14
  *
10
15
  * @param items The items to be added to the print buffer.
11
- */
12
- function print(...items: unknown[]): void;
13
-
14
- /**
15
- * Fills the screen with a color.
16
16
  *
17
- * Warning: nothing is drawn until `drawFlush` is called.
18
- */
19
- function draw(mode: "clear", r: number, g: number, b: number): void;
20
-
21
- /**
22
- * Sets the color for the next drawing operations.
17
+ * ```js
18
+ * // call normally
19
+ * print("a + b = ", left, " + ", right, " = ", left + right)
23
20
  *
24
- * Warning: nothing is drawn until `drawFlush` is called.
21
+ * // call with tagged string templates
22
+ * print`a + b = ${left} + ${right} = ${left + right}`
23
+ * ```
25
24
  */
26
- function draw(
27
- mode: "color",
28
- r: number,
29
- g: number,
30
- b: number,
31
- a?: number
32
- ): void;
25
+ function print(...items: unknown[]): void;
33
26
 
34
- /**
35
- * Sets the width of the next lines to be drawn.
36
- *
37
- * Warning: nothing is drawn until `drawFlush` is called.
38
- */
39
- function draw(mode: "stroke", width: number): void;
27
+ /** Contains the multiple variants of the `draw` instruction */
28
+ namespace draw {
29
+ /**
30
+ * Fills the screen with a color.
31
+ *
32
+ * Warning: nothing is drawn until `drawFlush` is called.
33
+ */
34
+ function clear(r: number, g: number, b: number): void;
35
+ /**
36
+ * Sets the color for the next drawing operations.
37
+ *
38
+ * Warning: nothing is drawn until `drawFlush` is called.
39
+ */
40
+ function color(r: number, g: number, b: number, a?: number): void;
40
41
 
41
- /**
42
- * Draws a line between two points.
43
- *
44
- * Warning: nothing is drawn until `drawFlush` is called.
45
- */
46
- function draw(
47
- mode: "line",
48
- x1: number,
49
- y1: number,
50
- x2: number,
51
- y2: number
52
- ): void;
42
+ /**
43
+ * Sets the width of the next lines to be drawn.
44
+ *
45
+ * Warning: nothing is drawn until `drawFlush` is called.
46
+ */
47
+ function stroke(width: number): void;
53
48
 
54
- /**
55
- * Draws a filled rectangle.
56
- *
57
- * Warning: nothing is drawn until `drawFlush` is called.
58
- */
59
- function draw(
60
- mode: "rect",
61
- x: number,
62
- y: number,
63
- width: number,
64
- height: number
65
- ): void;
49
+ /**
50
+ * Draws a line between two points.
51
+ *
52
+ * Warning: nothing is drawn until `drawFlush` is called.
53
+ */
54
+ function line(options: {
55
+ x: number;
56
+ y: number;
57
+ x2: number;
58
+ y2: number;
59
+ }): void;
66
60
 
67
- /**
68
- * Draws a rectangle outline.
69
- *
70
- * Warning: nothing is drawn until `drawFlush` is called.
71
- */
72
- function draw(
73
- mode: "lineRect",
74
- x: number,
75
- y: number,
76
- width: number,
77
- height: number
78
- ): void;
61
+ /**
62
+ * Draws a filled rectangle.
63
+ *
64
+ * Warning: nothing is drawn until `drawFlush` is called.
65
+ */
66
+ function rect(options: {
67
+ x: number;
68
+ y: number;
69
+ width: number;
70
+ height: number;
71
+ }): void;
79
72
 
80
- /**
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
85
- *
86
- * Warning: nothing is drawn until `drawFlush` is called.
87
- */
88
- function draw(
89
- mode: "poly",
90
- x: number,
91
- y: number,
92
- sides: number,
93
- radius: number,
94
- rotation: number
95
- ): void;
73
+ /**
74
+ * Draws a rectangle outline.
75
+ *
76
+ * Warning: nothing is drawn until `drawFlush` is called.
77
+ */
78
+ function lineRect(options: {
79
+ x: number;
80
+ y: number;
81
+ width: number;
82
+ height: number;
83
+ }): void;
96
84
 
97
- /**
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
102
- *
103
- *
104
- * Warning: nothing is drawn until `drawFlush` is called.
105
- */
106
- function draw(
107
- mode: "linePoly",
108
- x: number,
109
- y: number,
110
- sides: number,
111
- radius: number,
112
- rotation: number
113
- ): void;
85
+ /**
86
+ * Draws a filled, regular polygon.
87
+ * @param options.sides The number of sides the polygon should have
88
+ * @param options.radius The smallest distance between a line and the center of the polygon
89
+ * @param options.rotation The rotation of the polygon in degrees
90
+ *
91
+ * Warning: nothing is drawn until `drawFlush` is called.
92
+ */
93
+ function poly(options: {
94
+ x: number;
95
+ y: number;
96
+ /** The number of sides the polygon should have */
97
+ sides: number;
98
+ /** The smallest distance between a line and the center of the polygon */
99
+ radius: number;
100
+ /** The rotation of the polygon in degrees */
101
+ rotation: number;
102
+ }): void;
114
103
 
115
- /**
116
- * Draws a filled triangle.
117
- *
118
- * Warning: nothing is drawn until `drawFlush` is called.
119
- */
120
- function draw(
121
- mode: "triangle",
122
- x: number,
123
- y: number,
124
- x2: number,
125
- y2: number,
126
- x3: number,
127
- y3: number
128
- ): void;
104
+ /**
105
+ * Draws the outline of a regular polygon.
106
+ * @param options.sides The number of sides the polygon should have
107
+ * @param options.radius The smallest distance between a line and the center of the polygon
108
+ * @param options.rotation The rotation of the polygon in degrees
109
+ *
110
+ *
111
+ * Warning: nothing is drawn until `drawFlush` is called.
112
+ */
113
+ function linePoly(options: {
114
+ x: number;
115
+ y: number;
116
+ /** The number of sides the polygon should have */
117
+ sides: number;
118
+ /** The smallest distance between a line and the center of the polygon */
119
+ radius: number;
120
+ /** The rotation of the polygon in degrees */
121
+ rotation: number;
122
+ }): void;
129
123
 
130
- /**
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);
141
- *
142
- * // draw the unit bound to the processor
143
- * draw("image", 60, 60, Vars.unit.type, 15, 0);
144
- * ```
145
- */
146
- function draw(
147
- mode: "image",
148
- x: number,
149
- y: number,
150
- image: symbol,
151
- size: number,
152
- rotation: number
153
- ): void;
124
+ /**
125
+ * Draws a filled triangle.
126
+ *
127
+ * Warning: nothing is drawn until `drawFlush` is called.
128
+ */
129
+ function triangle(options: {
130
+ x: number;
131
+ y: number;
132
+ x2: number;
133
+ y2: number;
134
+ x3: number;
135
+ y3: number;
136
+ }): void;
137
+
138
+ /**
139
+ * Draws an image of the respective content. (like `Units.dagger` and `Blocks.router`)
140
+ *
141
+ * Warning: nothing is drawn until `drawFlush` is called.
142
+ * @param options.image The symbol for the image to be drawn.
143
+ * @param options.rotation The rotation of the image in degrees.
144
+ *
145
+ * Example:
146
+ * ```js
147
+ * // draw a router
148
+ * draw({
149
+ * mode: "image",
150
+ * x: 30,
151
+ * y: 30,
152
+ * image: Blocks.router,
153
+ * size: 15,
154
+ * rotation: 0
155
+ * });
156
+ *
157
+ * // draw the unit bound to the processor
158
+ * draw({
159
+ * mode: "image",
160
+ * x: 60,
161
+ * y: 60,
162
+ * image: Vars.unit.type,
163
+ * size: 15,
164
+ * rotation: 0
165
+ * });
166
+ * ```
167
+ */
168
+ function image(options: {
169
+ x: number;
170
+ y: number;
171
+ /** The symbol for the image to be drawn. */
172
+ image: symbol;
173
+ size: number;
174
+ /** The rotation of the image in degrees. */
175
+ rotation: number;
176
+ }): void;
177
+ }
154
178
 
155
179
  /**
156
180
  * Writes the contents of the print buffer into the target message
157
181
  * and clears the buffer afterwards.
158
- * @param target
182
+ * @param target The message building to write to. Writes to `message1` by default.
183
+ *
184
+ * Note that the default value only applies if you don't pass any parameter to this function.
159
185
  */
160
- function printFlush(target: BasicBuilding): void;
186
+ function printFlush(target?: BasicBuilding): void;
161
187
 
162
188
  /**
163
189
  * Writes the contents of the draw buffer into the target display
164
190
  * and clears the buffer afterwards.
165
- * @param target
191
+ * @param target The display building to write to. Writes to `display1` by default.
192
+ *
193
+ * Note that the default value only applies if you don't pass any parameter to this function.
166
194
  */
167
- function drawFlush(target: BasicBuilding): void;
195
+ function drawFlush(target?: BasicBuilding): void;
168
196
 
169
197
  /**
170
198
  * Gets a block link by its index.
@@ -182,86 +210,89 @@ declare global {
182
210
  */
183
211
  function getLink<T extends BasicBuilding = AnyBuilding>(index: number): T;
184
212
 
185
- /**
186
- * Sets whether the building is enabled or disabled.
187
- */
188
- function control(
189
- kind: "enabled",
190
- building: BasicBuilding,
191
- value: boolean
192
- ): void;
213
+ /** Contains the multiple variants of the `control` instruction */
214
+ namespace control {
215
+ /**
216
+ * Sets whether the building is enabled or disabled.
217
+ */
218
+ function enabled(building: BasicBuilding, value: boolean): void;
193
219
 
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
- */
199
- function control(
200
- kind: "shoot",
201
- building: BasicBuilding & Shooting,
202
- x: number,
203
- y: number,
204
- shoot: boolean
205
- ): void;
220
+ /**
221
+ * Makes the building shoot or aim at the given position
222
+ * @param options.building The shooting building
223
+ * @param options.shoot `true` to shoot, `false` to just aim at the position
224
+ */
225
+ function shoot(options: {
226
+ /** The shooting building */
227
+ building: BasicBuilding & Shooting;
228
+ x: number;
229
+ y: number;
230
+ /** `true` to shoot, `false` to just aim at the position */
231
+ shoot: boolean;
232
+ }): void;
206
233
 
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
- */
213
- function control(
214
- kind: "shootp",
215
- building: BasicBuilding & Shooting,
216
- unit: BasicUnit,
217
- shoot: boolean
218
- ): void;
234
+ /**
235
+ * Shoot at an unit with velocity prediction
236
+ * @param options.building The shooting building
237
+ * @param options.unit The target unit
238
+ * @param options.shoot `true` to shoot, `false` to just aim
239
+ */
240
+ function shootp(options: {
241
+ /** The shooting building */
242
+ building: BasicBuilding & Shooting;
243
+ /** The target unit */
244
+ unit: BasicUnit;
245
+ /** `true` to shoot, `false` to just aim */
246
+ shoot: boolean;
247
+ }): void;
219
248
 
220
- /**
221
- * Sets the config of a block (like the item of a sorter)
222
- */
223
- function control(
224
- kind: "config",
225
- building: BasicBuilding,
226
- value: symbol
227
- ): void;
249
+ /**
250
+ * Sets the config of a block (like the item of a sorter)
251
+ */
252
+ function config(building: BasicBuilding, value: symbol): void;
228
253
 
229
- /**
230
- * Sets the color of an illuminator
231
- */
232
- function control(
233
- kind: "color",
234
- building: BasicBuilding,
235
- r: number,
236
- g: number,
237
- b: number
238
- ): void;
254
+ /**
255
+ * Sets the color of an illuminator
256
+ */
257
+ function color(
258
+ building: BasicBuilding,
259
+ r: number,
260
+ g: number,
261
+ b: number
262
+ ): void;
263
+ }
239
264
 
240
265
  /**
241
266
  * Detects an unit nearby this `building`.
242
- * @param building The building used to detect potential targets
243
- * @param filter1 First filter for selecting a target. Setting it to "any" ignores it
244
- * @param filter2 Second filter for selecting a target. Setting it to "any" ignores it
245
- * @param filter3 Third filter for selecting a target. Setting it to "any" ignores it
246
- * @param order The n th unit that fits these requirements based on the sorting method
267
+ * @param options.building The building used to detect potential targets
268
+ * @param options.filters The filters for selecting a target. Use "any" for any target.
269
+ * @param options.order The n th unit that fits these requirements based on the sorting method
247
270
  * (1 => first unit, 2 => second unit and so on)
248
- * @param sort The method on which the results should be sorted
271
+ * @param options.sort The method on which the results should be sorted
249
272
  *
250
273
  * Example:
251
274
  * ```js
252
275
  * const turret = getBuilding("cyclone1")
253
276
  * // returns the second nearest enemy unit
254
- * const result = radar(turret, "enemy", "any", "any", 2, "distance")
277
+ * const result = radar({
278
+ * building: turret,
279
+ * filters: ["enemy", "any", "any"],
280
+ * order: 2,
281
+ * sort: "distance"
282
+ * });
255
283
  * ```
256
284
  */
257
- function radar<T extends BasicUnit = AnyUnit>(
258
- building: BasicBuilding,
259
- filter1: TRadarFilter,
260
- filter2: TRadarFilter,
261
- filter3: TRadarFilter,
262
- order: number,
263
- sort: TRadarSort
264
- ): T;
285
+ function radar<T extends BasicUnit = AnyUnit>(options: {
286
+ /** The building used to detect potential targets */
287
+ building: BasicBuilding;
288
+ /** The filters for selecting a target. Use "any" for any target. */
289
+ filters: [TRadarFilter, TRadarFilter, TRadarFilter];
290
+ /** The n th unit that fits these requirements based on the sorting method
291
+ * (1 => first unit, 2 => second unit and so on) */
292
+ order: number;
293
+ /** The method on which the results should be sorted */
294
+ sort: TRadarSort;
295
+ }): T;
265
296
 
266
297
  /**
267
298
  * Alternate way to access special properties on objects.
@@ -287,246 +318,646 @@ declare global {
287
318
  */
288
319
  function wait(seconds: number): void;
289
320
 
321
+ namespace lookup {
322
+ /**
323
+ * Looks up a block symbol by it's index on the content registry.
324
+ *
325
+ * Use `Vars.blockCount` to check the maximum index allowed.
326
+ *
327
+ * Example:
328
+ * ```js
329
+ * if(index < Vars.blockCount) {
330
+ * let blockKind = lookup.block(index);
331
+ * }
332
+ * ```
333
+ */
334
+ function block(index: number): BlockSymbol;
335
+
336
+ /**
337
+ * Looks up an unit symbol by it's index on the content registry.
338
+ *
339
+ * Use `Vars.unitCount` to check the maximum index allowed.
340
+ *
341
+ * Example:
342
+ * ```js
343
+ * if(index < Vars.unitCount) {
344
+ * let unitKind = lookup.unit(index);
345
+ * }
346
+ * ```
347
+ */
348
+ function unit(index: number): UnitSymbol | null;
349
+
350
+ /**
351
+ * Looks up an item symbol by it's index on the content registry.
352
+ *
353
+ * Use `Vars.itemCount` to check the maximum index allowed.
354
+ *
355
+ * Example:
356
+ * ```js
357
+ * if(index < Vars.itemCount) {
358
+ * let itemKind = lookup.item(index);
359
+ * }
360
+ * ```
361
+ */
362
+ function item(index: number): ItemSymbol | null;
363
+
364
+ /**
365
+ * Looks up a liquid symbol by it's index on the content registry.
366
+ *
367
+ * Use `Vars.liquidCount` to check the maximum index allowed.
368
+ *
369
+ * Example:
370
+ * ```js
371
+ * if(index < Vars.liquidCount) {
372
+ * let liquidKind = lookup.liquid(index);
373
+ * }
374
+ * ```
375
+ */
376
+ function liquid(index: number): LiquidSymbol | null;
377
+ }
378
+
290
379
  /**
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
- */
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
- */
328
- function lookup(kind: "item", index: number): ItemSymbol | null;
329
- /**
330
- * Looks up a liquid symbol by it's index on the content registry.
380
+ * Packs RGBA color information into a single number.
331
381
  *
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
- * ```
382
+ * Each paremeter must range from `0` to `1`.
340
383
  */
341
- function lookup(kind: "liquid", index: number): LiquidSymbol | null;
384
+ function packColor(r: number, g: number, b: number, a: number): number;
342
385
 
343
386
  /**
344
387
  * Binds an unit to the this processor. The unit is accessible at `Vars.unit`
345
388
  */
346
389
  function unitBind(type: UnitSymbol): void;
347
390
 
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
- */
352
- function unitControl(mode: "idle"): void;
353
- /**
354
- * Makes the unit bound to this processor stop mining, building and moving
355
- */
356
- function unitControl(mode: "stop"): void;
357
- /**
358
- * Makes the unit bound to this processor move to the given position
359
- */
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
- */
365
- function unitControl(
366
- mode: "approach",
367
- x: number,
368
- y: number,
369
- radius: number
370
- ): void;
371
- /**
372
- * Whether the unit bound to this processor should be boosted (floating)
373
- */
374
- function unitControl(mode: "boost", enable: boolean): void;
375
- /**
376
- * Makes the unit bound to this processor move to the enemy spawn
377
- */
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
- */
383
- function unitControl(
384
- mode: "target",
385
- x: number,
386
- y: number,
387
- shoot: boolean
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
- */
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
- */
400
- function unitControl(
401
- mode: "itemDrop",
402
- target: BasicBuilding | typeof Blocks.air,
403
- amount: number
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
- */
411
- function unitControl(
412
- mode: "itemTake",
413
- target: BasicBuilding,
414
- item: ItemSymbol,
415
- amount: number
416
- ): void;
417
- /**
418
- * Makes the unit bound to this processor drop one entity from it's payload
419
- */
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
- */
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
- */
430
- function unitControl(mode: "payEnter"): void;
431
- /**
432
- * Makes the unit bound to this processor mine at the given position
433
- */
434
- function unitControl(mode: "mine", x: number, y: number): void;
435
- /**
436
- * Sets the numeric flag of the unit bound to this processor
437
- */
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
- */
446
- function unitControl(
447
- mode: "build",
448
- x: number,
449
- y: number,
450
- block: BlockSymbol,
451
- rotation: number,
452
- config: unknown
453
- ): void;
454
- /**
455
- * Makes the unit bound to this processor data about a block at the given position
456
- */
457
- function unitControl<T extends BasicBuilding = AnyBuilding>(
458
- mode: "getBlock",
459
- x: number,
460
- y: number
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
- */
465
- function unitControl(
466
- mode: "within",
467
- x: number,
468
- y: number,
469
- radius: number
470
- ): boolean;
391
+ namespace unitControl {
392
+ /**
393
+ * Makes the unit bound to this processor stop moving but
394
+ * allows it to keep doing it's action (like mining or building)
395
+ */
396
+ function idle(): void;
397
+
398
+ /**
399
+ * Makes the unit bound to this processor stop mining, building and moving
400
+ */
401
+ function stop(): void;
402
+
403
+ /**
404
+ * Makes the unit bound to this processor move to the given position
405
+ */
406
+ function move(x: number, y: number): void;
407
+
408
+ /**
409
+ * Makes the unit bound to this processor approach the given position at the given radius
410
+ * @param options.radius How distant to the position the unit can be
411
+ */
412
+ function approach(options: {
413
+ x: number;
414
+ y: number;
415
+ /** How distant to the position the unit can be */
416
+ radius: number;
417
+ }): void;
418
+
419
+ /**
420
+ * Whether the unit bound to this processor should be boosted (floating)
421
+ */
422
+ function boost(enable: boolean): void;
423
+
424
+ /**
425
+ * Makes the unit bound to this processor move to the enemy spawn
426
+ */
427
+ function pathfind(): void;
428
+
429
+ /**
430
+ * Makes the unit bound to this processor shoot/aim at the given position
431
+ * @param options.shoot `true` to shoot, `false` to just aim
432
+ */
433
+ function target(options: {
434
+ x: number;
435
+ y: number;
436
+ /** `true` to shoot, `false` to just aim */
437
+ shoot: boolean;
438
+ }): void;
439
+
440
+ /**
441
+ * Makes the unit bound to this processor target an unit with velocity prediction
442
+ * @param options.unit The shoot target
443
+ * @param options.shoot `true` to shoot, `false` to just aim
444
+ */
445
+ function targetp(options: {
446
+ /** The shoot target */
447
+ unit: BasicUnit;
448
+ /** `true` to shoot, `false` to just aim */
449
+ shoot: boolean;
450
+ }): void;
451
+
452
+ /**
453
+ * 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 `EnvBlocks.air`, the unit will throw it's items away
455
+ * @param amount How many items should be dropped
456
+ */
457
+ function itemDrop(
458
+ target: BasicBuilding | typeof Blocks.air,
459
+ amount: number
460
+ ): void;
461
+
462
+ /**
463
+ * Makes the unit bound to this processor take items from a building
464
+ * @param target The building that will have it's items taken
465
+ * @param item The kind of item to take
466
+ * @param amount How many items should be taken
467
+ */
468
+ function itemTake(
469
+ target: BasicBuilding,
470
+ item: ItemSymbol,
471
+ amount: number
472
+ ): void;
473
+
474
+ /**
475
+ * Makes the unit bound to this processor drop one entity from it's payload
476
+ */
477
+ function payDrop(): void;
478
+
479
+ /**
480
+ * Makes the unit bound to this processor take an entity into it's payload
481
+ * @param options.takeUnits Whether to take units or buildings
482
+ */
483
+ function payTake(options: {
484
+ /** Whether to take units or buildings */
485
+ takeUnits: boolean;
486
+ }): void;
487
+
488
+ /**
489
+ * Makes the unit bound to this processor enter/land on the
490
+ * payload block the unit is on
491
+ */
492
+ function payEnter(): void;
493
+
494
+ /**
495
+ * Makes the unit bound to this processor mine at the given position
496
+ */
497
+ function mine(x: number, y: number): void;
498
+
499
+ /**
500
+ * Sets the numeric flag of the unit bound to this processor
501
+ */
502
+ function flag(value: number): void;
503
+
504
+ /**
505
+ * Makes the unit bound to this processor build a building with the
506
+ * given properties
507
+ * @param options.block The kind of building to build
508
+ * @param options.rotation The rotation of the building, ranges from 0 to 3
509
+ * @param options.config The config of the building
510
+ */
511
+ function build(options: {
512
+ x: number;
513
+ y: number;
514
+ block: BuildingSymbol;
515
+ rotation: number;
516
+ config?: unknown;
517
+ }): void;
518
+
519
+ /**
520
+ * Makes the unit bound to this processor data about a block at the given position
521
+ */
522
+ function getBlock<T extends BasicBuilding = AnyBuilding>(
523
+ x: number,
524
+ y: number
525
+ ): [type: BlockSymbol | null, building: T | null];
526
+
527
+ /**
528
+ * Checks if the unit bound to this processor is within a radius of a given position.
529
+ */
530
+ function within(options: { x: number; y: number; radius: number }): boolean;
531
+ }
471
532
 
472
533
  /**
473
534
  * 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
535
+ * @param options.filters The filters for selecting a target. Use "any" for any target.
536
+ * @param options.order The n th unit that fits these requirements based on the sorting method
478
537
  * (1 => first unit, 2 => second unit and so on)
479
- * @param sort The method on which the results should be sorted
538
+ * @param options.sort The method on which the results should be sorted
480
539
  *
481
540
  * Example:
482
541
  * ```js
483
542
  * // returns the second nearest enemy unit
484
- * const result = unitRadar("enemy", "any", "any", 2, "distance")
543
+ * const result = unitRadar({
544
+ * filters: ["enemy", "any", "any"],
545
+ * order: 2,
546
+ * sort: "distance",
547
+ * });
485
548
  * ```
486
549
  */
487
- function unitRadar<T extends BasicUnit = AnyUnit>(
488
- filter1: TRadarFilter,
489
- filter2: TRadarFilter,
490
- filter3: TRadarFilter,
491
- order: number,
492
- sort: TRadarSort
493
- ): T;
550
+ function unitRadar<T extends BasicUnit = AnyUnit>(options: {
551
+ /** The filters for selecting a target. Use "any" for any target. */
552
+ filters: [TRadarFilter, TRadarFilter, TRadarFilter];
553
+ /** The n th unit that fits these requirements based on the sorting method
554
+ * (1 => first unit, 2 => second unit and so on) */
555
+ order: number;
556
+ /** The method on which the results should be sorted */
557
+ sort: TRadarSort;
558
+ }): T;
559
+
560
+ namespace unitLocate {
561
+ /**
562
+ * Uses the unit bound to this processor to find an ore vein anywhere on the map
563
+ * @param ore The kind of item the ore should contain
564
+ */
565
+ function ore(
566
+ ore: ItemSymbol
567
+ ): [found: false] | [found: true, x: number, y: number];
568
+
569
+ /**
570
+ * Uses the unit bound to this processor to find a building anywhere on the map
571
+ * @param options.group The group that the building belongs to
572
+ * @param options.enemy Whether it should be an enemy building or an ally one
573
+ */
574
+ function building<T extends BasicBuilding = AnyBuilding>(options: {
575
+ /** The group that the building belongs to */
576
+ group: TUnitLocateBuildingGroup;
577
+ /** Whether it should be an enemy building or an ally one */
578
+ enemy: boolean;
579
+ }): [found: false] | [found: true, x: number, y: number, building: T];
580
+
581
+ /**
582
+ * Uses the unit bound to this processor to find an enemy spawn anywhere on the map.
583
+ *
584
+ * May return a building (a core) or a position
585
+ */
586
+ function spawn<T extends BasicBuilding = AnyBuilding>():
587
+ | [found: false]
588
+ | [found: true, x: number, y: number, building: T];
589
+
590
+ /**
591
+ * Uses the unit bound to this processor to find a damaged ally buildings anywhere on the map
592
+ */
593
+ function damaged<T extends BasicBuilding = AnyBuilding>():
594
+ | [found: false]
595
+ | [found: true, x: number, y: number, building: T];
596
+ }
597
+
598
+ /**Jumps to the top of the instruction stack*/
599
+ function endScript(): never;
600
+
601
+ /** Halts the execution of this processor */
602
+ function stopScript(): never;
603
+
604
+ /** Gets block data from the map. Available ONLY for world processors. */
605
+ namespace getBlock {
606
+ /** Gets the floor type on the given location */
607
+ function floor(x: number, y: number): EnvBlockSymbol;
608
+
609
+ /** Gets the ore type on the given location. `Blocks.air` if there is no ore */
610
+ function ore(x: number, y: number): OreSymbol | typeof Blocks.air;
611
+
612
+ /** Gets the block type on the give location. `Blocks.air` if there is no block. */
613
+ function block(x: number, y: number): BlockSymbol;
614
+
615
+ /** Gets the building on the given location. `null` if there is no building. */
616
+ function building<T extends BasicBuilding = AnyBuilding>(
617
+ x: number,
618
+ y: number
619
+ ): T | null;
620
+ }
621
+
622
+ namespace setBlock {
623
+ // TODO: maybe have a separate floor symbol type?
624
+ /** Sets the floor of the tile at the given location. */
625
+ function floor(x: number, y: number, to: EnvBlockSymbol): void;
626
+
627
+ /** Sets the ore at the given location. Use `Blocks.air` to remove any ore. */
628
+ function ore(x: number, y: number, to: OreSymbol | typeof Blocks.air): void;
629
+
630
+ /** Sets the block at a given location, it can be a regular building or an environment block. */
631
+ function block(options: {
632
+ x: number;
633
+ y: number;
634
+ to: EnvBlockSymbol | BuildingSymbol;
635
+ team: TeamSymbol;
636
+ rotation: number;
637
+ }): void;
638
+ }
639
+
640
+ /** Spawns an unit at the given location */
641
+ function spawnUnit<T extends BasicUnit = AnyUnit>(options: {
642
+ type: UnitSymbol;
643
+ x: number;
644
+ y: number;
645
+ team: TeamSymbol;
646
+ rotation?: number;
647
+ }): T;
648
+
649
+ /** Contains the variants for the `applyStatus` instruction. World processor ONLY. */
650
+ namespace applyStatus {
651
+ /**
652
+ * Applies a status effect to the given unit.
653
+ *
654
+ * The only status effects that don't require a duration are `overdrive` and `boss`.
655
+ */
656
+ function apply(
657
+ status: Exclude<TUnitEffect, "overdrive" | "boss">,
658
+ unit: BasicUnit,
659
+ duration: number
660
+ ): void;
661
+
662
+ function apply(status: "overdrive" | "boss", unit: BasicUnit): void;
663
+
664
+ /**
665
+ * Removes a status effect to the given unit.
666
+ */
667
+ function clear(status: TUnitEffect, unit: BasicUnit): void;
668
+ }
494
669
 
495
670
  /**
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
- */
499
- function unitLocate(
500
- find: "ore",
501
- ore: ItemSymbol
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
- */
508
- function unitLocate<T extends BasicBuilding = AnyBuilding>(
509
- find: "building",
510
- group: TUnitLocateBuildingGroup,
511
- enemy: boolean
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.
671
+ * Spawns an enemy wave, can be used even if there is an already active wave.
515
672
  *
516
- * May return a building (a core) or a position
517
- * @param find
673
+ * World processor ONLY.
518
674
  */
519
- function unitLocate<T extends BasicBuilding = AnyBuilding>(
520
- find: "spawn"
521
- ): [found: false] | [found: true, x: number, y: number, building: T];
675
+ function spawnWave(natural: true): void;
676
+ function spawnWave(natural: false, x: number, y: number): void;
677
+
678
+ /** Contains the multiple variants of the `set rule` instruction. World processor ONLY. */
679
+ namespace setRule {
680
+ /** Sets the wave countdown in seconds. */
681
+ function currentWaveTime(seconds: number): void;
682
+
683
+ /** Enables/disables the wave timer. */
684
+ function waveTimer(enabled: boolean): void;
685
+
686
+ /** Allows or prevents waves from spawning. */
687
+ function waves(enabled: boolean): void;
688
+
689
+ /** Sets the current wave number. */
690
+ function wave(number: number): void;
691
+
692
+ /** Sets the time between waves in seconds. */
693
+ function waveSpacing(seconds: number): void;
694
+
695
+ /** Sets wether waves can be manually summoned by pressing the play button. */
696
+ function waveSending(enabled: boolean): void;
697
+
698
+ /** Sets wether the gamemode is the attack mode */
699
+ function attackMode(enabled: boolean): void;
700
+
701
+ /** Sets the radius of the no-build zone around enemy cores. */
702
+ function enemyCoreBuildRadius(radius: number): void;
703
+
704
+ /** Sets the radius around enemy wave drop zones. */
705
+ function dropZoneRadius(radius: number): void;
706
+
707
+ /** Sets the base unit cap. */
708
+ function unitCap(cap: number): void;
709
+
710
+ /** Sets the playable map area. Blocks that are out of the new bounds will be removed. */
711
+ function mapArea(options: {
712
+ x: number;
713
+ y: number;
714
+ width: number;
715
+ height: number;
716
+ }): void;
717
+
718
+ /** Sets wether ambient lighting is enabled */
719
+ function lighting(enabled: boolean): void;
720
+
721
+ /**
722
+ * Sets the ambient light color.
723
+ *
724
+ * `packColor` can be used to get the rgba data recevied by this function.
725
+ *
726
+ *
727
+ * ```js
728
+ * // enables lighting and sets the color to gray
729
+ * setRule("lighting", true);
730
+ * setRule("ambientLight", packColor(0.5, 0.5, 0.5, 1));
731
+ * ```
732
+ */
733
+ function ambientLight(rgbaData: number): void;
734
+
735
+ /** Sets the multiplier for the energy output of solar panels. */
736
+ function solarMultiplier(multiplier: number): void;
737
+
738
+ /**
739
+ * Sets the build speed multiplier of a team.
740
+ * The multiplier will always be clamped between `0.001` and `50`.
741
+ */
742
+ function buildSpeed(team: TeamSymbol, multiplier: number): void;
743
+
744
+ /**
745
+ * Sets the speed multiplier for unit factories.
746
+ * The multiplier will always be clamped between `0` and `50`.
747
+ */
748
+ function unitBuildSpeed(team: TeamSymbol, multiplier: number): void;
749
+
750
+ /** Sets the damage multiplier for units on a given team. */
751
+
752
+ function unitDamage(team: TeamSymbol, multiplier: number): void;
753
+ /** Sets the block health multiplier for a given team. */
754
+
755
+ function blockHealth(team: TeamSymbol, multiplier: number): void;
756
+
757
+ /** Sets the block damage multiplier for a given team. */
758
+ function blockDamage(team: TeamSymbol, multiplier: number): void;
759
+
760
+ /**
761
+ * Sets the Real Time Strategy minimum weight for a team.
762
+ *
763
+ * In other words it, sets the minimum "advantage" needed for a squad to attack.
764
+ * The higher the value, the more cautious the squad is.
765
+ */
766
+
767
+ function rtsMinWeight(team: TeamSymbol, value: number): void;
768
+
769
+ /**
770
+ * Sets the Real Time Strategy minimum size of attack squads of a team.
771
+ *
772
+ * The higher the value, the more units are required before a squad attacks.
773
+ */
774
+ function rtsMinSquad(team: TeamSymbol, value: number): void;
775
+ }
776
+
522
777
  /**
523
- * Uses the unit bound to this processor to find a damaged ally buildings anywhere on the map
524
- * @param find
778
+ * Writes the contents of the print buffer in the selected mode
779
+ * and clears the buffer afterwards. World processor ONLY.
780
+ *
781
+ * ```js
782
+ * print("Hello");
783
+ * flushMessage.announce(4); // lasts 4 seconds
784
+ * wait(5);
785
+ * print("World");
786
+ * flushMessage.toast(4);
787
+ * wait(5);
788
+ * ```
525
789
  */
526
- function unitLocate<T extends BasicBuilding = AnyBuilding>(
527
- find: "damaged"
528
- ): [found: false] | [found: true, x: number, y: number, building: T];
790
+ namespace flushMessage {
791
+ /** Shows a nofication at the top of the screen */
792
+ function notify(): void;
793
+ /** Puts the content on the top left corner of the screen */
794
+ function mission(): void;
795
+ /**
796
+ * Puts the content on the middle of the screen
797
+ *
798
+ * @param duration The duration, in seconds
799
+ */
800
+ function announce(duration: number): void;
801
+ /**
802
+ * Puts the content on the middle top of the screen
803
+ *
804
+ * @param duration The duration, in seconds
805
+ */
806
+ function toast(duration: number): void;
807
+ }
529
808
 
530
- /** Ends the execution of this script */
531
- function endScript(): never;
809
+ namespace cutscene {
810
+ /** Moves the player's camera to the given location. */
811
+ function pan(options: { x: number; y: number; speed: number }): void;
812
+ /** Zooms the player camera to the desired level */
813
+ function zoom(level: number): void;
814
+ /** Gives the camera control back to the player */
815
+ function stop(): void;
816
+ }
817
+
818
+ /** Creates an explosion */
819
+ function explosion(options: {
820
+ team: TeamSymbol;
821
+ x: number;
822
+ y: number;
823
+ radius: number;
824
+ damage: number;
825
+ air: boolean;
826
+ ground: boolean;
827
+ pierce: boolean;
828
+ }): void;
829
+
830
+ /** Sets the speed of this world processor in instructions per tick. */
831
+ function setRate(ipt: number): void;
832
+
833
+ /** Contains the variants of the `fetch` instruction. World processor ONLY. */
834
+ namespace fetch {
835
+ /**
836
+ * Gets an unit from the given team
837
+ *
838
+ * The index starts at 0.
839
+ *
840
+ * ```js
841
+ * const count = fetch.unitCount();
842
+ * for(let i = 0; i < count; i++) {
843
+ * const unit = fetch.unit(Teams.sharded, i);
844
+ * print`x: ${unit.x}, y: ${unit.y}\n`;
845
+ * }
846
+ * printFlush();
847
+ * ```
848
+ */
849
+ function unit<T extends BasicUnit = AnyUnit>(
850
+ team: TeamSymbol,
851
+ index: number
852
+ ): T;
853
+ /**
854
+ * Gets the amount of units existing on a given team.
855
+ *
856
+ * ```js
857
+ * const count = fetch.unitCount();
858
+ * for(let i = 0; i < count; i++) {
859
+ * const unit = fetch.unit(Teams.sharded, i);
860
+ * print`x: ${unit.x}, y: ${unit.y}\n`;
861
+ * }
862
+ * printFlush();
863
+ * ```
864
+ */
865
+ function unitCount(team: TeamSymbol): number;
866
+ /**
867
+ * Gets a player from a team.
868
+ *
869
+ * The index starts at 0.
870
+ *
871
+ * ```js
872
+ * const count = fetch.playerCount();
873
+ * for(let i = 0; i < count; i++) {
874
+ * const player = fetch.player(Teams.sharded, i);
875
+ * print`x: ${player.x}, y: ${player.y}\n`;
876
+ * }
877
+ * printFlush();
878
+ * ```
879
+ */
880
+ function player<T extends BasicUnit = AnyUnit>(
881
+ team: TeamSymbol,
882
+ index: number
883
+ ): T;
884
+ /**
885
+ * Gets the amount of players existing on a given team.
886
+ *
887
+ * ```js
888
+ * const count = fetch.playerCount();
889
+ * for(let i = 0; i < count; i++) {
890
+ * const player = fetch.player(Teams.sharded, i);
891
+ * print`x: ${player.x}, y: ${player.y}\n`;
892
+ * }
893
+ * printFlush();
894
+ * ```
895
+ */
896
+ function playerCount(team: TeamSymbol): number;
897
+ /**
898
+ * Gets a core from a team.
899
+ *
900
+ * The index of the starts at 0.
901
+ *
902
+ * ```js
903
+ * const count = fetch.coreCount();
904
+ * for(let i = 0; i < count; i++) {
905
+ * const core = fetch.core(Teams.sharded, i);
906
+ * print`x: ${core.x}, y: ${core.y}\n`;
907
+ * }
908
+ * printFlush();
909
+ * ```
910
+ */
911
+ function core(team: TeamSymbol, index: number): AnyBuilding;
912
+ /**
913
+ * Gets the amount of cores existing on a given team.
914
+ * ```js
915
+ * const count = fetch.coreCount();
916
+ * for(let i = 0; i < count; i++) {
917
+ * const core = fetch.core(Teams.sharded, i);
918
+ * print`x: ${core.x}, y: ${core.y}\n`;
919
+ * }
920
+ * printFlush();
921
+ * ```
922
+ */
923
+ function coreCount(team: TeamSymbol): number;
924
+ /**
925
+ * Gets a building from a team.
926
+ *
927
+ * The index starts at 0.
928
+ *
929
+ * ```js
930
+ * const count = fetch.buildCount();
931
+ * for(let i = 0; i < count; i++) {
932
+ * const router = fetch.build(Teams.sharded, i, Blocks.router);
933
+ * print`x: ${router.x}, y: ${router.y}\n`;
934
+ * }
935
+ * printFlush();
936
+ * ```
937
+ */
938
+ function build<T extends BasicBuilding = AnyBuilding>(
939
+ team: TeamSymbol,
940
+ index: number,
941
+ block: BuildingSymbol
942
+ ): T;
943
+ /**
944
+ * Gets the amount of buildings existing on a given team.
945
+ *
946
+ * ```js
947
+ * const count = fetch.buildCount();
948
+ * for(let i = 0; i < count; i++) {
949
+ * const router = fetch.build(Teams.sharded, i, Blocks.router)
950
+ * print`x: ${router.x}, y: ${router.y}\n`
951
+ * }
952
+ * printFlush()
953
+ * ```
954
+ */
955
+ function buildCount(team: TeamSymbol, block: BuildingSymbol): number;
956
+ }
957
+
958
+ /** Checks if a global flag is set. World processor ONLY. */
959
+ function getFlag(flag: string): boolean;
960
+
961
+ /** Sets a global flag. World processor ONLY. */
962
+ function setFlag(flag: string, value: boolean): void;
532
963
  }