typed-factorio 0.14.1 → 0.15.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.
@@ -101,16 +101,20 @@ type PositionArray = readonly [x: int, y: int]
101
101
  */
102
102
  type Position = PositionTable | PositionArray
103
103
 
104
+ interface MapPositionTable {
105
+ readonly x: double
106
+ readonly y: double
107
+ }
108
+
109
+ type MapPositionArray = readonly [x: double, y: double]
110
+
104
111
  /**
105
112
  * Coordinates of an entity on a map. This uses the same format as {@link Position}, meaning it can be specified either
106
113
  * with or without explicit keys.
107
114
  *
108
115
  * {@link https://lua-api.factorio.com/latest/Concepts.html#MapPosition View documentation}
109
116
  */
110
- interface MapPosition {
111
- readonly x: double
112
- readonly y: double
113
- }
117
+ type MapPosition = MapPositionTable | MapPositionArray
114
118
 
115
119
  interface ChunkPositionTable {
116
120
  readonly x: int
@@ -167,7 +171,7 @@ type GuiLocation = GuiLocationTable | GuiLocationArray
167
171
  interface ChunkPositionAndArea {
168
172
  readonly x: int
169
173
  readonly y: int
170
- readonly area: BoundingBox
174
+ readonly area: BoundingBoxRead
171
175
  }
172
176
 
173
177
  /**
@@ -201,7 +205,7 @@ interface TabAndContent {
201
205
 
202
206
  interface OldTileAndPosition {
203
207
  readonly old_tile: LuaTilePrototype
204
- readonly position: TilePosition
208
+ readonly position: TilePositionTable
205
209
  }
206
210
 
207
211
  /**
@@ -230,7 +234,7 @@ interface SmokeSource {
230
234
  readonly east_position?: PositionTable
231
235
  readonly south_position?: PositionTable
232
236
  readonly west_position?: PositionTable
233
- readonly deviation?: Position
237
+ readonly deviation?: PositionTable
234
238
  readonly starting_frame_speed: uint16
235
239
  readonly starting_frame_speed_deviation: double
236
240
  readonly starting_frame: uint16
@@ -285,6 +289,13 @@ type BoundingBoxArray = readonly [left_top: Position, right_bottom: Position, or
285
289
  */
286
290
  type BoundingBox = BoundingBoxTable | BoundingBoxArray
287
291
 
292
+ /** @addAfter BoundingBox */
293
+ interface BoundingBoxRead extends BoundingBoxTable {
294
+ readonly left_top: PositionTable
295
+ readonly right_bottom: PositionTable
296
+ readonly orientation?: RealOrientation
297
+ }
298
+
288
299
  /**
289
300
  * An area defined using the map editor.
290
301
  *
@@ -297,6 +308,11 @@ interface ScriptArea {
297
308
  readonly id: uint
298
309
  }
299
310
 
311
+ interface ScriptAreaRead extends ScriptArea {
312
+ readonly area: BoundingBoxRead
313
+ readonly color: ColorTable
314
+ }
315
+
300
316
  /**
301
317
  * A position defined using the map editor.
302
318
  *
@@ -309,6 +325,11 @@ interface ScriptPosition {
309
325
  readonly id: uint
310
326
  }
311
327
 
328
+ interface ScriptPositionRead extends ScriptPosition {
329
+ readonly position: PositionTable
330
+ readonly color: ColorTable
331
+ }
332
+
312
333
  interface ColorTable {
313
334
  readonly r?: float
314
335
  readonly g?: float
@@ -368,7 +389,7 @@ interface Alert {
368
389
  readonly tick: uint
369
390
  readonly target?: LuaEntity
370
391
  readonly prototype?: LuaEntityPrototype
371
- readonly position?: Position
392
+ readonly position?: PositionTable
372
393
  /** The SignalID used for a custom alert. Only present for custom alerts. */
373
394
  readonly icon?: SignalID
374
395
  /** The message for a custom alert. Only present for custom alerts. */
@@ -388,7 +409,7 @@ interface ScriptRenderVertexTarget {
388
409
 
389
410
  interface PathfinderWaypoint {
390
411
  /** The position of the waypoint on its surface. */
391
- readonly position: Position
412
+ readonly position: PositionTable
392
413
  /** `true` if the path from the previous waypoint to this one goes through an entity that must be destroyed. */
393
414
  readonly needs_destroy_to_reach: boolean
394
415
  }
@@ -414,7 +435,7 @@ interface Decorative {
414
435
  }
415
436
 
416
437
  interface DecorativeResult {
417
- readonly position: TilePosition
438
+ readonly position: TilePositionTable
418
439
  readonly decorative: LuaDecorativePrototype
419
440
  readonly amount: uint
420
441
  }
@@ -900,7 +921,7 @@ interface MapAndDifficultySettings {
900
921
  */
901
922
  interface MapExchangeStringData {
902
923
  readonly map_settings: MapAndDifficultySettings
903
- readonly map_gen_settings: MapGenSettings
924
+ readonly map_gen_settings: MapGenSettingsRead
904
925
  }
905
926
 
906
927
  interface BlueprintItemIcon {
@@ -998,6 +1019,11 @@ interface BlueprintEntity {
998
1019
  readonly schedule?: TrainScheduleRecord[]
999
1020
  }
1000
1021
 
1022
+ interface BlueprintEntityRead extends BlueprintEntity {
1023
+ /** The position of the entity. */
1024
+ readonly position: PositionTable
1025
+ }
1026
+
1001
1027
  interface Tile {
1002
1028
  /** The position of the tile. */
1003
1029
  readonly position: Position
@@ -1005,6 +1031,11 @@ interface Tile {
1005
1031
  readonly name: string
1006
1032
  }
1007
1033
 
1034
+ interface TileRead extends Tile {
1035
+ /** The position of the tile. */
1036
+ readonly position: PositionTable
1037
+ }
1038
+
1008
1039
  interface Fluid {
1009
1040
  /** Fluid prototype name of the fluid. */
1010
1041
  readonly name: string
@@ -1600,6 +1631,11 @@ interface MapGenSettings {
1600
1631
  readonly property_expression_names: Record<string, string>
1601
1632
  }
1602
1633
 
1634
+ interface MapGenSettingsRead extends MapGenSettings {
1635
+ /** Positions of the starting areas. */
1636
+ readonly starting_points: PositionTable[]
1637
+ }
1638
+
1603
1639
  interface SignalID {
1604
1640
  /** `"item"`, `"fluid"`, or `"virtual"`. */
1605
1641
  readonly type: "item" | "fluid" | "virtual"
@@ -1864,6 +1900,15 @@ interface GoToLocationCommand extends BaseCommand {
1864
1900
  readonly radius?: double
1865
1901
  }
1866
1902
 
1903
+ interface GoToLocationCommandRead extends BaseCommand, GoToLocationCommand {
1904
+ readonly type: defines.command.go_to_location
1905
+ /**
1906
+ * The position to path to. Either this or `destination_entity` need to be specified. If both are,
1907
+ * `destination_entity` is used.
1908
+ */
1909
+ readonly destination?: PositionTable
1910
+ }
1911
+
1867
1912
  interface CompoundCommand extends BaseCommand {
1868
1913
  readonly type: defines.command.compound
1869
1914
  /** How the commands should be chained together. */
@@ -1872,6 +1917,12 @@ interface CompoundCommand extends BaseCommand {
1872
1917
  readonly commands: Command[]
1873
1918
  }
1874
1919
 
1920
+ interface CompoundCommandRead extends BaseCommand, CompoundCommand {
1921
+ readonly type: defines.command.compound
1922
+ /** The sub-commands. */
1923
+ readonly commands: CommandRead[]
1924
+ }
1925
+
1875
1926
  interface GroupCommand extends BaseCommand {
1876
1927
  readonly type: defines.command.group
1877
1928
  /** The group whose command to follow. */
@@ -1892,6 +1943,12 @@ interface AttackAreaCommand extends BaseCommand {
1892
1943
  readonly distraction?: defines.distraction
1893
1944
  }
1894
1945
 
1946
+ interface AttackAreaCommandRead extends BaseCommand, AttackAreaCommand {
1947
+ readonly type: defines.command.attack_area
1948
+ /** Center of the attack area. */
1949
+ readonly destination: PositionTable
1950
+ }
1951
+
1895
1952
  interface WanderCommand extends BaseCommand {
1896
1953
  readonly type: defines.command.wander
1897
1954
  /** Defaults to `defines.distraction.by_enemy`. */
@@ -1938,6 +1995,23 @@ interface BuildBaseCommand extends BaseCommand {
1938
1995
  readonly ignore_planner?: boolean
1939
1996
  }
1940
1997
 
1998
+ interface BuildBaseCommandRead extends BaseCommand, BuildBaseCommand {
1999
+ readonly type: defines.command.build_base
2000
+ /** Where to build the base. */
2001
+ readonly destination: PositionTable
2002
+ }
2003
+
2004
+ type CommandRead =
2005
+ | AttackCommand
2006
+ | GoToLocationCommandRead
2007
+ | CompoundCommandRead
2008
+ | GroupCommand
2009
+ | AttackAreaCommandRead
2010
+ | WanderCommand
2011
+ | StopCommand
2012
+ | FleeCommand
2013
+ | BuildBaseCommandRead
2014
+
1941
2015
  /**
1942
2016
  * Commands can be given to enemies and unit groups.
1943
2017
  *
@@ -2259,7 +2333,7 @@ interface BeamTarget {
2259
2333
  /** The target entity. */
2260
2334
  readonly entity?: LuaEntity
2261
2335
  /** The target position. */
2262
- readonly position?: Position
2336
+ readonly position?: PositionTable
2263
2337
  }
2264
2338
 
2265
2339
  interface RidingState {
@@ -2853,7 +2927,7 @@ interface SelectedPrototypeData {
2853
2927
  interface ScriptRenderTarget {
2854
2928
  readonly entity?: LuaEntity
2855
2929
  readonly entity_offset?: Vector
2856
- readonly position?: Position
2930
+ readonly position?: PositionTable
2857
2931
  }
2858
2932
 
2859
2933
  type MouseButtonFlag =
@@ -6565,6 +6639,17 @@ type StyleValuesArray =
6565
6639
 
6566
6640
  type SizeArray = readonly [width: int, height: int]
6567
6641
 
6642
+ type RaiseableEvents =
6643
+ | typeof defines.events.on_console_chat
6644
+ | typeof defines.events.on_player_crafted_item
6645
+ | typeof defines.events.on_player_fast_transferred
6646
+ | typeof defines.events.on_biter_base_built
6647
+ | typeof defines.events.on_market_item_purchased
6648
+ | typeof defines.events.script_raised_built
6649
+ | typeof defines.events.script_raised_destroy
6650
+ | typeof defines.events.script_raised_revive
6651
+ | typeof defines.events.script_raised_set_tiles
6652
+
6568
6653
  /**
6569
6654
  * A map gen preset. Used in {@link https://wiki.factorio.com/Prototype/MapGenPresets Prototype/MapGenPresets}.
6570
6655
  *
@@ -13,7 +13,7 @@ interface CustomInputEvent extends EventData {
13
13
  /** The prototype name of the custom input that was activated. */
14
14
  readonly input_name: string
15
15
  /** The mouse cursor position when the custom input was activated. */
16
- readonly cursor_position: Position
16
+ readonly cursor_position: PositionTable
17
17
  /** Information about the prototype that is selected when the custom input is used. `nil` if none is selected. */
18
18
  readonly selected_prototype?: SelectedPrototypeData
19
19
  /** Identifier of the event */
@@ -46,9 +46,9 @@ interface OnAiCommandCompletedEvent extends EventData {
46
46
  */
47
47
  interface OnAreaClonedEvent extends EventData {
48
48
  readonly source_surface: LuaSurface
49
- readonly source_area: BoundingBox
49
+ readonly source_area: BoundingBoxRead
50
50
  readonly destination_surface: LuaSurface
51
- readonly destination_area: BoundingBox
51
+ readonly destination_area: BoundingBoxRead
52
52
  readonly destination_force?: LuaForce
53
53
  readonly clone_tiles: boolean
54
54
  readonly clone_entities: boolean
@@ -84,10 +84,10 @@ interface OnBiterBaseBuiltEvent extends EventData {
84
84
  * {@link https://lua-api.factorio.com/latest/Events.html#on_brush_cloned View documentation}
85
85
  */
86
86
  interface OnBrushClonedEvent extends EventData {
87
- readonly source_offset: TilePosition
88
- readonly destination_offset: TilePosition
87
+ readonly source_offset: TilePositionTable
88
+ readonly destination_offset: TilePositionTable
89
89
  readonly source_surface: LuaSurface
90
- readonly source_positions: TilePosition[]
90
+ readonly source_positions: TilePositionTable[]
91
91
  readonly destination_surface: LuaSurface
92
92
  readonly destination_force?: LuaForce
93
93
  readonly clone_tiles: boolean
@@ -236,9 +236,9 @@ interface OnChartTagRemovedEvent extends EventData {
236
236
  */
237
237
  interface OnChunkChartedEvent extends EventData {
238
238
  readonly surface_index: uint
239
- readonly position: ChunkPosition
239
+ readonly position: ChunkPositionTable
240
240
  /** Area of the chunk. */
241
- readonly area: BoundingBox
241
+ readonly area: BoundingBoxRead
242
242
  readonly force: LuaForce
243
243
  /** Identifier of the event */
244
244
  readonly name: typeof defines.events.on_chunk_charted
@@ -254,7 +254,7 @@ interface OnChunkChartedEvent extends EventData {
254
254
  interface OnChunkDeletedEvent extends EventData {
255
255
  readonly surface_index: uint
256
256
  /** The chunks deleted. */
257
- readonly positions: ChunkPosition[]
257
+ readonly positions: ChunkPositionTable[]
258
258
  /** Identifier of the event */
259
259
  readonly name: typeof defines.events.on_chunk_deleted
260
260
  /** Tick the event was generated. */
@@ -268,9 +268,9 @@ interface OnChunkDeletedEvent extends EventData {
268
268
  */
269
269
  interface OnChunkGeneratedEvent extends EventData {
270
270
  /** Area of the chunk. */
271
- readonly area: BoundingBox
271
+ readonly area: BoundingBoxRead
272
272
  /** Position of the chunk. */
273
- readonly position: ChunkPosition
273
+ readonly position: ChunkPositionTable
274
274
  /** The surface the chunk is on. */
275
275
  readonly surface: LuaSurface
276
276
  /** Identifier of the event */
@@ -748,7 +748,7 @@ interface OnGuiClosedEvent extends EventData {
748
748
  /** The technology that was automatically selected when opening the research GUI */
749
749
  readonly technology?: LuaTechnology
750
750
  /** The tile position that was open */
751
- readonly tile_position?: TilePosition
751
+ readonly tile_position?: TilePositionTable
752
752
  /** Identifier of the event */
753
753
  readonly name: typeof defines.events.on_gui_closed
754
754
  /** Tick the event was generated. */
@@ -1120,7 +1120,7 @@ interface OnPlayerAltSelectedAreaEvent extends EventData {
1120
1120
  /** The surface selected. */
1121
1121
  readonly surface: LuaSurface
1122
1122
  /** The area selected. */
1123
- readonly area: BoundingBox
1123
+ readonly area: BoundingBoxRead
1124
1124
  /** The item used to select the area. */
1125
1125
  readonly item: string
1126
1126
  /** The entities selected. */
@@ -1307,7 +1307,7 @@ interface OnPlayerClickedGpsTagEvent extends EventData {
1307
1307
  /** Index of the player */
1308
1308
  readonly player_index: uint
1309
1309
  /** Map position contained in gps tag */
1310
- readonly position: Position
1310
+ readonly position: PositionTable
1311
1311
  /** Surface name contained in gps tag, even when such surface does not exists */
1312
1312
  readonly surface: string
1313
1313
  /** Identifier of the event */
@@ -1402,7 +1402,7 @@ interface OnPlayerDeconstructedAreaEvent extends EventData {
1402
1402
  /** The surface selected. */
1403
1403
  readonly surface: LuaSurface
1404
1404
  /** The area selected. */
1405
- readonly area: BoundingBox
1405
+ readonly area: BoundingBoxRead
1406
1406
  /** The item used to select the area. */
1407
1407
  readonly item: string
1408
1408
  /** If normal selection or alt selection was used. */
@@ -1824,7 +1824,7 @@ interface OnPlayerSelectedAreaEvent extends EventData {
1824
1824
  /** The surface selected. */
1825
1825
  readonly surface: LuaSurface
1826
1826
  /** The area selected. */
1827
- readonly area: BoundingBox
1827
+ readonly area: BoundingBoxRead
1828
1828
  /** The item used to select the area. */
1829
1829
  readonly item: string
1830
1830
  /** The entities selected. */
@@ -1861,7 +1861,7 @@ interface OnPlayerSetupBlueprintEvent extends EventData {
1861
1861
  /** The surface selected. */
1862
1862
  readonly surface: LuaSurface
1863
1863
  /** The area selected. */
1864
- readonly area: BoundingBox
1864
+ readonly area: BoundingBoxRead
1865
1865
  /** The item used to select the area. */
1866
1866
  readonly item: string
1867
1867
  /** If normal selection or alt selection was used. */
@@ -1963,7 +1963,7 @@ interface OnPlayerUsedCapsuleEvent extends EventData {
1963
1963
  /** The capsule item used. */
1964
1964
  readonly item: LuaItemPrototype
1965
1965
  /** The position the capsule was used. */
1966
- readonly position: Position
1966
+ readonly position: PositionTable
1967
1967
  /** Identifier of the event */
1968
1968
  readonly name: typeof defines.events.on_player_used_capsule
1969
1969
  /** Tick the event was generated. */
@@ -1981,7 +1981,7 @@ interface OnPlayerUsedSpiderRemoteEvent extends EventData {
1981
1981
  /** Spider vehicle which was requested to move. */
1982
1982
  readonly vehicle: LuaEntity
1983
1983
  /** Goal position to which spidertron was sent to. */
1984
- readonly position: Position
1984
+ readonly position: PositionTable
1985
1985
  /** If the use was successful. It may fail when spidertron has different driver or when player is on different surface. */
1986
1986
  readonly success: boolean
1987
1987
  /** Identifier of the event */
@@ -2001,7 +2001,7 @@ interface OnPostEntityDiedEvent extends EventData {
2001
2001
  /** The force that did the killing if any. */
2002
2002
  readonly force?: LuaForce
2003
2003
  /** Position where the entity died. */
2004
- readonly position: Position
2004
+ readonly position: PositionTable
2005
2005
  /** The entity prototype of the entity that died. */
2006
2006
  readonly prototype: LuaEntityPrototype
2007
2007
  /** The damage type if any. */
@@ -2027,7 +2027,7 @@ interface OnPreBuildEvent extends EventData {
2027
2027
  /** The player who did the placing. */
2028
2028
  readonly player_index: uint
2029
2029
  /** Where the item was placed. */
2030
- readonly position: Position
2030
+ readonly position: PositionTable
2031
2031
  /** Item was placed using shift building. */
2032
2032
  readonly shift_build: boolean
2033
2033
  /** The direction the item was facing when placed. */
@@ -2052,7 +2052,7 @@ interface OnPreBuildEvent extends EventData {
2052
2052
  interface OnPreChunkDeletedEvent extends EventData {
2053
2053
  readonly surface_index: uint
2054
2054
  /** The chunks to be deleted. */
2055
- readonly positions: ChunkPosition[]
2055
+ readonly positions: ChunkPositionTable[]
2056
2056
  /** Identifier of the event */
2057
2057
  readonly name: typeof defines.events.on_pre_chunk_deleted
2058
2058
  /** Tick the event was generated. */
@@ -2574,9 +2574,9 @@ interface OnScriptTriggerEffectEvent extends EventData {
2574
2574
  readonly effect_id: string
2575
2575
  /** The surface the effect happened on. */
2576
2576
  readonly surface_index: uint
2577
- readonly source_position?: Position
2577
+ readonly source_position?: PositionTable
2578
2578
  readonly source_entity?: LuaEntity
2579
- readonly target_position?: Position
2579
+ readonly target_position?: PositionTable
2580
2580
  readonly target_entity?: LuaEntity
2581
2581
  /** Identifier of the event */
2582
2582
  readonly name: typeof defines.events.on_script_trigger_effect
@@ -2594,9 +2594,9 @@ interface OnSectorScannedEvent extends EventData {
2594
2594
  /** The radar that did the scanning. */
2595
2595
  readonly radar: LuaEntity
2596
2596
  /** The chunk scanned. */
2597
- readonly chunk_position: ChunkPosition
2597
+ readonly chunk_position: ChunkPositionTable
2598
2598
  /** Area of the scanned chunk. */
2599
- readonly area: BoundingBox
2599
+ readonly area: BoundingBoxRead
2600
2600
  /** Identifier of the event */
2601
2601
  readonly name: typeof defines.events.on_sector_scanned
2602
2602
  /** Tick the event was generated. */
@@ -2958,7 +2958,7 @@ interface ScriptRaisedSetTilesEvent extends EventData {
2958
2958
  /** The surface whose tiles were changed. */
2959
2959
  readonly surface_index: uint
2960
2960
  /** The tiles that were changed. */
2961
- readonly tiles: Tile[]
2961
+ readonly tiles: TileRead[]
2962
2962
  /** Identifier of the event */
2963
2963
  readonly name: typeof defines.events.script_raised_set_tiles
2964
2964
  /** Tick the event was generated. */
@@ -2,8 +2,8 @@
2
2
 
3
3
  ///<reference types="lua-types/5.2" />
4
4
  ///<reference path="builtin-types.d.ts" />
5
+ ///<reference path="global-objects.d.ts" />
5
6
  ///<reference path="defines.d.ts" />
6
7
  ///<reference path="events.d.ts" />
7
8
  ///<reference path="classes.d.ts" />
8
9
  ///<reference path="concepts.d.ts" />
9
- ///<reference path="global-objects.d.ts" />
@@ -0,0 +1,9 @@
1
+ declare module "typescript" {
2
+ interface JSDocContainer {
3
+ jsDoc?: JSDoc[]
4
+ }
5
+ interface Node {
6
+ emitNode?: unknown
7
+ }
8
+ }
9
+ export {}
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "typed-factorio",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
5
  "keywords": [
6
- "factorio",
7
- "types",
8
- "typescript-to-lua",
9
- "tstl"
6
+ "factorio", "types", "typescript-to-lua", "tstl"
10
7
  ],
11
8
  "repository": "https://github.com/GlassBricks/typed-factorio",
12
9
  "license": "MIT",
package/runtime/util.d.ts CHANGED
@@ -33,11 +33,7 @@ declare module "util" {
33
33
  direction: defines.direction.north | defines.direction.east | defines.direction.south | defines.direction.west,
34
34
  distance: number
35
35
  ): Position
36
- function moveposition(
37
- position: Position,
38
- direction: defines.direction, //todo: cardinal only
39
- distance: number
40
- ): Position | undefined
36
+ function moveposition(position: Position, direction: defines.direction, distance: number): Position | undefined
41
37
 
42
38
  function oppositedirection(direction: defines.direction): defines.direction
43
39