typed-factorio 0.11.0-packagetypes-1 → 0.13.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/Changelog.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v0.13.0
2
+
3
+ - Update to factorio version 1.1.49
4
+
5
+ # v0.12.0
6
+
7
+ - Update to factorio version 1.1.48
8
+
9
+ # v0.11.1
10
+
11
+ - Localised strings now accept boolean and undefined.
12
+
1
13
  # v0.11.0
2
14
 
3
15
  - Update to factorio version 1.1.46
@@ -1187,7 +1187,7 @@ interface LuaControl {
1187
1187
  * players, cars, and spidertrons can be teleported cross-surface.
1188
1188
  * @returns `true` when the entity was successfully teleported.
1189
1189
  */
1190
- teleport(position: Position, surface?: SurfaceIdentification): boolean
1190
+ teleport(position: MapPosition, surface?: SurfaceIdentification): boolean
1191
1191
  /**
1192
1192
  * Select an entity, as if by hovering the mouse above it.
1193
1193
  *
@@ -1195,7 +1195,7 @@ interface LuaControl {
1195
1195
  *
1196
1196
  * @param position - Position of the entity to select
1197
1197
  */
1198
- update_selected_entity(position: Position): void
1198
+ update_selected_entity(position: MapPosition): void
1199
1199
  /**
1200
1200
  * Unselect any selected entity.
1201
1201
  *
@@ -1291,47 +1291,41 @@ interface LuaControl {
1291
1291
  /**
1292
1292
  * Sets a personal logistic request and auto-trash slot to the given value.
1293
1293
  *
1294
- * **Note**: This will silently fail if personal logistics are not researched yet.
1295
- *
1296
1294
  * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.set_personal_logistic_slot View documentation}
1297
1295
  *
1298
1296
  * @param slot_index - The slot to set.
1299
1297
  * @param value - The logistic request parameters.
1300
- * @returns Whether the slot was set successfully.
1298
+ * @returns Whether the slot was set successfully. `false` if personal logistics are not researched yet.
1301
1299
  */
1302
- set_personal_logistic_slot(slot_index: uint, value: PersonalLogisticParameters): boolean
1300
+ set_personal_logistic_slot(slot_index: uint, value: LogisticParameters): boolean
1303
1301
  /**
1304
1302
  * Sets a vehicle logistic request and auto-trash slot to the given value.
1305
1303
  *
1306
- * **Note**: This will silently fail if the vehicle does not use logistics.
1307
- *
1308
1304
  * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.set_vehicle_logistic_slot View documentation}
1309
1305
  *
1310
1306
  * @param slot_index - The slot to set.
1311
1307
  * @param value - The logistic request parameters.
1312
- * @returns Whether the slot was set successfully.
1308
+ * @returns Whether the slot was set successfully. `false` if the vehicle does not use logistics.
1313
1309
  */
1314
- set_vehicle_logistic_slot(slot_index: uint, value: PersonalLogisticParameters): boolean
1310
+ set_vehicle_logistic_slot(slot_index: uint, value: LogisticParameters): boolean
1315
1311
  /**
1316
1312
  * Gets the parameters of a personal logistic request and auto-trash slot.
1317
1313
  *
1318
- * **Note**: This will silently return an empty value (`name` will be `nil`) if personal logistics are not researched yet.
1319
- *
1320
1314
  * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_personal_logistic_slot View documentation}
1321
1315
  *
1322
1316
  * @param slot_index - The slot to get.
1317
+ * @returns The logistic parameters. If personal logistics are not researched yet, their `name` will be `nil`.
1323
1318
  */
1324
- get_personal_logistic_slot(slot_index: uint): PersonalLogisticParameters
1319
+ get_personal_logistic_slot(slot_index: uint): LogisticParameters | undefined
1325
1320
  /**
1326
1321
  * Gets the parameters of a vehicle logistic request and auto-trash slot.
1327
1322
  *
1328
- * **Note**: This will silently return an empty value (`name` will be `nil`) if the vehicle does not use logistics.
1329
- *
1330
1323
  * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_vehicle_logistic_slot View documentation}
1331
1324
  *
1332
1325
  * @param slot_index - The slot to get.
1326
+ * @returns The logistic parameters. If the vehicle does not use logistics, their `name` will be `nil`.
1333
1327
  */
1334
- get_vehicle_logistic_slot(slot_index: uint): PersonalLogisticParameters
1328
+ get_vehicle_logistic_slot(slot_index: uint): LogisticParameters | undefined
1335
1329
  /**
1336
1330
  * **Note**: This will silently fail if personal logistics are not researched yet.
1337
1331
  *
@@ -1384,7 +1378,7 @@ interface LuaControl {
1384
1378
  *
1385
1379
  * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.position View documentation}
1386
1380
  */
1387
- readonly position: PositionTable
1381
+ readonly position: MapPosition
1388
1382
  /**
1389
1383
  * The vehicle the player is currently sitting in; `nil` if none.
1390
1384
  *
@@ -3002,7 +2996,7 @@ interface LuaEntity extends LuaControl {
3002
2996
  */
3003
2997
  clone(params: {
3004
2998
  /** The destination position */
3005
- readonly position: Position
2999
+ readonly position: MapPosition
3006
3000
  /** The destination surface */
3007
3001
  readonly surface?: LuaSurface
3008
3002
  readonly force?: ForceIdentification
@@ -3145,7 +3139,7 @@ interface LuaEntity extends LuaControl {
3145
3139
  * @param target
3146
3140
  * @param position
3147
3141
  */
3148
- can_shoot(target: LuaEntity, position: Position): boolean
3142
+ can_shoot(target: LuaEntity, position: MapPosition): boolean
3149
3143
  /**
3150
3144
  * Only works if the entity is a speech-bubble, with an "effect" defined in its wrapper_flow_style. Starts animating
3151
3145
  * the opacity of the speech bubble towards zero, and destroys the entity when it hits zero.
@@ -3285,7 +3279,7 @@ interface LuaEntity extends LuaControl {
3285
3279
  *
3286
3280
  * @param position - The position the spidertron should move to.
3287
3281
  */
3288
- add_autopilot_destination(position: Position): void
3282
+ add_autopilot_destination(position: MapPosition): void
3289
3283
  /**
3290
3284
  * Connects current linked belt with another one.
3291
3285
  *
@@ -4507,7 +4501,7 @@ interface LuaEntity extends LuaControl {
4507
4501
  *
4508
4502
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.autopilot_destination View documentation}
4509
4503
  */
4510
- autopilot_destination: Position | undefined
4504
+ autopilot_destination: MapPosition | undefined
4511
4505
  /**
4512
4506
  * The queued destination positions of spidertron's autopilot.
4513
4507
  *
@@ -4515,7 +4509,7 @@ interface LuaEntity extends LuaControl {
4515
4509
  *
4516
4510
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.autopilot_destinations View documentation}
4517
4511
  */
4518
- readonly autopilot_destinations: PositionTable[]
4512
+ readonly autopilot_destinations: MapPosition[]
4519
4513
  /**
4520
4514
  * Amount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds
4521
4515
  * a path to next target) and trains having this train stop as goal or waypoint. Writing nil will disable the limit
@@ -5834,6 +5828,12 @@ interface LuaEntityPrototype {
5834
5828
  * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.related_underground_belt View documentation}
5835
5829
  */
5836
5830
  readonly related_underground_belt: LuaEntityPrototype
5831
+ /**
5832
+ * Gets the built-in stack size bonus of this inserter prototype. `nil` if this is not an inserter.
5833
+ *
5834
+ * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.inserter_stack_size_bonus View documentation}
5835
+ */
5836
+ readonly inserter_stack_size_bonus: double | undefined
5837
5837
  /**
5838
5838
  * Gets the current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.
5839
5839
  *
@@ -6827,6 +6827,7 @@ interface LuaFluidEnergySourcePrototype {
6827
6827
  readonly effectivity: double
6828
6828
  readonly burns_fluid: boolean
6829
6829
  readonly scale_fluid_usage: boolean
6830
+ readonly destroy_non_fuel_fluid: boolean
6830
6831
  readonly fluid_usage_per_tick: double
6831
6832
  /**
6832
6833
  * The smoke sources for this prototype if any.
@@ -7824,6 +7825,12 @@ interface LuaGameScript {
7824
7825
  readonly can_continue: boolean
7825
7826
  readonly victorious_force: ForceIdentification
7826
7827
  }): void
7828
+ /**
7829
+ * Reset scenario state (game_finished, player_won, etc.).
7830
+ *
7831
+ * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.reset_game_state View documentation}
7832
+ */
7833
+ reset_game_state(): void
7827
7834
  /**
7828
7835
  * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_entity_by_tag View documentation}
7829
7836
  *
@@ -8833,11 +8840,17 @@ interface LuaGameScript {
8833
8840
  */
8834
8841
  ticks_to_run: uint
8835
8842
  /**
8836
- * Is the scenario finished?
8843
+ * True while the victory screen is shown.
8837
8844
  *
8838
8845
  * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.finished View documentation}
8839
8846
  */
8840
8847
  readonly finished: boolean
8848
+ /**
8849
+ * True after players finished the game and clicked "continue".
8850
+ *
8851
+ * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.finished_but_continuing View documentation}
8852
+ */
8853
+ readonly finished_but_continuing: boolean
8841
8854
  /**
8842
8855
  * Speed to update the map at. 1.0 is normal speed -- 60 UPS.
8843
8856
  *
@@ -12140,7 +12153,7 @@ interface LuaItemStack {
12140
12153
  */
12141
12154
  transfer_stack(stack: ItemStackIdentification): boolean
12142
12155
  /**
12143
- * Export a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) to a string
12156
+ * Export a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) to a string.
12144
12157
  *
12145
12158
  * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.export_stack View documentation}
12146
12159
  *
@@ -12148,7 +12161,7 @@ interface LuaItemStack {
12148
12161
  */
12149
12162
  export_stack(): string
12150
12163
  /**
12151
- * Import a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) from a string
12164
+ * Import a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) from a string.
12152
12165
  *
12153
12166
  * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.import_stack View documentation}
12154
12167
  *
@@ -12199,8 +12212,6 @@ interface LuaItemStack {
12199
12212
  */
12200
12213
  get_inventory(inventory: defines.inventory): LuaInventory | undefined
12201
12214
  /**
12202
- * Build this blueprint
12203
- *
12204
12215
  * **Note**: Built entities can be come invalid between the building of the blueprint and the function returning if
12205
12216
  * by_player or raise_built is used and one of those events invalidates the entity.
12206
12217
  *
@@ -13956,7 +13967,7 @@ interface LuaPlayer extends LuaControl {
13956
13967
  * Position at which cursor was clicked. Used only to decide which side of arithmetic combinator, decider
13957
13968
  * combinator or power switch is to be connected. Entity itself to be connected is based on the player's selected entity.
13958
13969
  */
13959
- readonly position: Position
13970
+ readonly position: MapPosition
13960
13971
  }): boolean
13961
13972
  /**
13962
13973
  * Disable recipe groups.
@@ -14162,7 +14173,7 @@ interface LuaPlayer extends LuaControl {
14162
14173
  /** Name of the entity to check */
14163
14174
  readonly name: string
14164
14175
  /** Where the entity would be placed */
14165
- readonly position: Position
14176
+ readonly position: MapPosition
14166
14177
  /** Direction the entity would be placed */
14167
14178
  readonly direction?: defines.direction
14168
14179
  }): boolean
@@ -14173,7 +14184,7 @@ interface LuaPlayer extends LuaControl {
14173
14184
  */
14174
14185
  can_build_from_cursor(params: {
14175
14186
  /** Where the entity would be placed */
14176
- readonly position: Position
14187
+ readonly position: MapPosition
14177
14188
  /** Direction the entity would be placed */
14178
14189
  readonly direction?: defines.direction
14179
14190
  /** If alt build should be used instead of normal build. Defaults to normal. */
@@ -14194,7 +14205,7 @@ interface LuaPlayer extends LuaControl {
14194
14205
  */
14195
14206
  build_from_cursor(params: {
14196
14207
  /** Where the entity would be placed */
14197
- readonly position: Position
14208
+ readonly position: MapPosition
14198
14209
  /** Direction the entity would be placed */
14199
14210
  readonly direction?: defines.direction
14200
14211
  /** If alt build should be used instead of normal build. Defaults to normal. */
@@ -14280,7 +14291,7 @@ interface LuaPlayer extends LuaControl {
14280
14291
  /** The flying text to show. */
14281
14292
  readonly text: LocalisedString
14282
14293
  /** The location on the map at which to show the flying text. */
14283
- readonly position?: Position
14294
+ readonly position?: MapPosition
14284
14295
  /** If `true`, the flying text is created at the player's cursor. Defaults to `false`. */
14285
14296
  readonly create_at_cursor?: boolean
14286
14297
  /** The color of the flying text. Defaults to white text. */
@@ -14351,7 +14362,7 @@ interface LuaPlayer extends LuaControl {
14351
14362
  * @param position
14352
14363
  * @param scale
14353
14364
  */
14354
- open_map(position: Position, scale?: double): void
14365
+ open_map(position: MapPosition, scale?: double): void
14355
14366
  /**
14356
14367
  * Queues a request to zoom to world at the specified position. If the player is already zooming to world, the
14357
14368
  * request will simply set the position (and scale). Render mode change requests are processed before rendering of
@@ -14362,7 +14373,7 @@ interface LuaPlayer extends LuaControl {
14362
14373
  * @param position
14363
14374
  * @param scale
14364
14375
  */
14365
- zoom_to_world(position: Position, scale?: double): void
14376
+ zoom_to_world(position: MapPosition, scale?: double): void
14366
14377
  /**
14367
14378
  * Queues request to switch to the normal game view from the map or zoom to world view. Render mode change requests
14368
14379
  * are processed before rendering of the next frame.
@@ -14500,7 +14511,7 @@ interface LuaPlayer extends LuaControl {
14500
14511
  * @param position - The position to start selection from.
14501
14512
  * @param selection_mode - The type of selection to start. Can be `select`, `alternative-select`, `reverse-select`.
14502
14513
  */
14503
- start_selection(position: Position, selection_mode: string): void
14514
+ start_selection(position: MapPosition, selection_mode: string): void
14504
14515
  /**
14505
14516
  * Clears the players selection tool selection position.
14506
14517
  *
@@ -14688,6 +14699,12 @@ interface LuaPlayer extends LuaControl {
14688
14699
  * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.spectator View documentation}
14689
14700
  */
14690
14701
  spectator: boolean
14702
+ /**
14703
+ * If `true`, circle and name of given player is rendered on the map/chart.
14704
+ *
14705
+ * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.show_on_map View documentation}
14706
+ */
14707
+ show_on_map: boolean
14691
14708
  /**
14692
14709
  * If items not included in this map editor infinity inventory filters should be removed.
14693
14710
  *
@@ -17239,6 +17256,12 @@ interface LuaStyle {
17239
17256
  * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.use_header_filler View documentation}
17240
17257
  */
17241
17258
  use_header_filler: boolean
17259
+ /**
17260
+ * *Can only be used if this is LuaProgressBarStyle*
17261
+ *
17262
+ * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.bar_width View documentation}
17263
+ */
17264
+ bar_width: uint
17242
17265
  /**
17243
17266
  * *Can only be used if this is LuaProgressBarStyle*
17244
17267
  *
@@ -18799,7 +18822,7 @@ interface LuaSurface {
18799
18822
  *
18800
18823
  * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.daytime View documentation}
18801
18824
  */
18802
- daytime: float
18825
+ daytime: double
18803
18826
  /**
18804
18827
  * Amount of darkness at the current time.
18805
18828
  *
@@ -9,13 +9,13 @@
9
9
  *
10
10
  * The template can contain placeholders such as `__1__` or `__2__`. These will be replaced by the respective parameter
11
11
  * in the LocalisedString. The parameters themselves can be other localised strings, which will be processed recursively
12
- * in the same fashion. Localised strings cannot be recursed deeper than 20 levels and cannot have more than 20 parameters.
12
+ * in the same fashion. Localised strings can not be recursed deeper than 20 levels and can not have more than 20 parameters.
13
13
  *
14
14
  * As a special case, when the key is just the empty string, all the parameters will be concatenated (after processing,
15
15
  * if any are localised strings). If there is only one parameter, it will be used as is.
16
16
  *
17
17
  * Furthermore, when an API function expects a localised string, it will also accept a regular string (i.e. not a table)
18
- * which will not be translated, or number which will be converted to its textual representation.
18
+ * which will not be translated, as well as a number or boolean, which will be converted to their textual representation.
19
19
  *
20
20
  * {@link https://lua-api.factorio.com/next/Concepts.html#LocalisedString View documentation}
21
21
  *
@@ -47,14 +47,14 @@
47
47
  * game.print({"", {"item-name.iron-plate"}, ": ", 60})
48
48
  * ```
49
49
  */
50
- type LocalisedString = readonly [string, ...LocalisedString[]] | string | number
50
+ type LocalisedString = readonly [string, ...LocalisedString[]] | string | number | boolean | undefined
51
51
 
52
52
  interface DisplayResolution {
53
53
  readonly width: uint
54
54
  readonly height: uint
55
55
  }
56
56
 
57
- interface PersonalLogisticParameters {
57
+ interface LogisticParameters {
58
58
  /** The item. `nil` clears the filter. */
59
59
  readonly name?: string
60
60
  readonly min?: uint
@@ -99,6 +99,17 @@ type PositionArray = readonly [x: int, y: int]
99
99
  */
100
100
  type Position = PositionTable | PositionArray
101
101
 
102
+ /**
103
+ * Coordinates of an entity on a map. This uses the same format as {@link Position}, meaning it can be specified either
104
+ * with or without explicit keys.
105
+ *
106
+ * {@link https://lua-api.factorio.com/next/Concepts.html#MapPosition View documentation}
107
+ */
108
+ interface MapPosition {
109
+ readonly x: double
110
+ readonly y: double
111
+ }
112
+
102
113
  interface ChunkPositionTable {
103
114
  readonly x: int
104
115
  readonly y: int
@@ -705,7 +716,10 @@ interface SteeringMapSettings {
705
716
  }
706
717
 
707
718
  interface PathFinderMapSettings {
708
- /** Determines whether forwards (`>1`), backwards (`<-1`), or symmetrical (`1`) search is preferred. Defaults to `5`. */
719
+ /**
720
+ * The pathfinder performs a step of the backward search every `fwd2bwd_ratio`'th step. The minimum allowed value is
721
+ * `2`, which means symmetric search. The default value is `5`.
722
+ */
709
723
  readonly fwd2bwd_ratio: uint
710
724
  /**
711
725
  * When looking at which node to check next, their heuristic value is multiplied by this ratio. The higher it is,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-factorio",
3
- "version": "0.11.0-packagetypes-1",
3
+ "version": "0.13.0",
4
4
  "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
5
  "keywords": [
6
6
  "factorio",
@@ -13,10 +13,9 @@
13
13
  "files": [
14
14
  "**/*.d.ts"
15
15
  ],
16
- "types": "runtime/index.d.ts",
17
16
  "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
18
17
  "scripts": {
19
- "gen": "ts-node generator/index.ts",
18
+ "gen": "ts-node -P generator/tsconfig.json generator/index.ts",
20
19
  "generate": "yarn run gen --in ./generatorSrc --out ./generated --warn-as-error",
21
20
  "generate:dev": "yarn run gen --in ./generatorSrc --out ./generated --no-format",
22
21
  "clean": "rimraf generated",
@@ -27,31 +26,33 @@
27
26
  "prepublishOnly": "yarn run check",
28
27
  "download-latest-runtime-api": "ts-node ./scripts/downloadLatest.ts"
29
28
  },
30
- "dependencies": {
31
- "lua-types": "^2.10.1",
29
+ "peerDependencies": {
30
+ "lua-types": "^2.11.0",
32
31
  "typescript-to-lua": "^1.0.0"
33
32
  },
34
33
  "devDependencies": {
35
- "@types/jest": "^26.0.24",
36
- "@types/node": "^16.7.1",
37
- "@types/prettier": "^2.3.2",
38
- "@typescript-eslint/eslint-plugin": "^4.27.0",
39
- "@typescript-eslint/parser": "^4.27.0",
40
- "chalk": "^4.1.2",
34
+ "@types/jest": "^27.0.3",
35
+ "@types/node": "^16.11.12",
36
+ "@types/prettier": "^2.4.2",
37
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
38
+ "@typescript-eslint/parser": "^5.6.0",
39
+ "chalk": "^3.0.0",
41
40
  "commander": "^8.3.0",
42
- "eslint": "^7.29.0",
41
+ "eslint": "^8.4.1",
43
42
  "eslint-config-prettier": "^8.3.0",
44
43
  "eslint-config-standard": "^16.0.3",
45
- "eslint-import-resolver-typescript": "^2.4.0",
46
- "eslint-plugin-import": "^2.23.4",
44
+ "eslint-import-resolver-typescript": "^2.5.0",
45
+ "eslint-plugin-import": "^2.25.3",
47
46
  "eslint-plugin-node": "^11.1.0",
48
- "eslint-plugin-prettier": "^3.4.0",
49
- "eslint-plugin-promise": "^5.1.0",
50
- "jest": "^27.0.6",
51
- "prettier": "^2.3.2",
52
- "prettier-plugin-jsdoc": "^0.3.23",
53
- "ts-jest": "^27.0.4",
54
- "ts-node": "^10.1.0",
55
- "typescript": "~4.3.5"
47
+ "eslint-plugin-prettier": "^4.0.0",
48
+ "eslint-plugin-promise": "^5.2.0",
49
+ "jest": "^27.4.3",
50
+ "lua-types": "^2.11.0",
51
+ "prettier": "^2.5.1",
52
+ "prettier-plugin-jsdoc": "^0.3.30",
53
+ "ts-jest": "^27.1.0",
54
+ "ts-node": "^10.4.0",
55
+ "typescript": "4.5.2",
56
+ "typescript-to-lua": "^1.2.0"
56
57
  }
57
58
  }