typed-factorio 1.14.0 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * The template can contain placeholders such as `__1__` or `__2__`. These will be replaced by the respective parameter in the LocalisedString. The parameters themselves can be other localised strings, which will be processed recursively in the same fashion. Localised strings can not be recursed deeper than 20 levels and can not have more than 20 parameters.
11
11
  *
12
- * As a special case, when the key is just the empty string, all the parameters will be concatenated (after processing, if any are localised strings). If there is only one parameter, it will be used as is.
12
+ * There are two special flags for the localised string, indicated by the key being a particular string. First, if the key is the empty string (`""`), then all parameters will be concatenated (after processing, if any are localised strings themselves). Second, if the key is a question mark (`"?"`), then the first valid parameter will be used. A parameter can be invalid if its name doesn't match any string template. If no parameters are valid, the last one is returned. This is useful to implement a fallback for missing locale templates.
13
13
  *
14
14
  * Furthermore, when an API function expects a localised string, it will also accept a regular string (i.e. not a table) which will not be translated, as well as a number, boolean or `nil`, which will be converted to their textual representation.
15
15
  * @example In the English translation, this will print `"No ammo"`; in the Czech translation, it will print `"Bez munice"`:
@@ -34,6 +34,13 @@
34
34
  * ```
35
35
  * game.print({"", {"item-name.iron-plate"}, ": ", 60})
36
36
  * ```
37
+ * @example As an example of a localised string with fallback, consider this:
38
+ *
39
+ * ```
40
+ * {"?", {"", {"entity-description.furnace"}, "\n"}, {"item-description.furnace"}, "optional fallback"}
41
+ * ```
42
+ *
43
+ * If `entity-description.furnace` exists, it is concatenated with `"\n"` and returned. Otherwise, if `item-description.furnace` exists, it is returned as-is. Otherwise, `"optional fallback"` is returned. If this value wasn't specified, the translation result would be `"Unknown key: 'item-description.furnace'"`.
37
44
  * @see {@link https://lua-api.factorio.com/latest/Concepts.html#LocalisedString Online documentation}
38
45
  */
39
46
  type LocalisedString = string | number | boolean | LuaObject | nil | readonly [string, ...LocalisedString[]]
@@ -291,7 +298,7 @@ interface SmokeSource {
291
298
  type Vector = MapPositionArray
292
299
 
293
300
  /**
294
- * Two positions, specifying the top-left and bottom-right corner of the box respectively. Like with {@link MapPosition}, the names of the members may be omitted. When read from the game, the third member `orientation` is present if it is non-zero, however it is ignored when provided to the game.
301
+ * Two positions, specifying the top-left and bottom-right corner of the box respectively. Like with {@link MapPosition}, the names of the members may be omitted. When read from the game, the third member `orientation` is present if it is non-zero.
295
302
  * @see BoundingBoxArray
296
303
  * @example Explicit definition:
297
304
  *
@@ -793,26 +800,26 @@ interface EnemyExpansionMapSettings {
793
800
  */
794
801
  readonly settler_group_max_size: uint
795
802
  /**
796
- * The minimum time between expansions in ticks. The actual cooldown is adjusted to the current evolution levels. Defaults to `4*3,600=14,400` ticks.
803
+ * The minimum time between expansions in ticks. The actual cooldown is adjusted to the current evolution levels. Defaults to `4*3'600=14'400` ticks.
797
804
  */
798
805
  readonly min_expansion_cooldown: uint
799
806
  /**
800
- * The maximum time between expansions in ticks. The actual cooldown is adjusted to the current evolution levels. Defaults to `60*3,600=216,000` ticks.
807
+ * The maximum time between expansions in ticks. The actual cooldown is adjusted to the current evolution levels. Defaults to `60*3'600=216'000` ticks.
801
808
  */
802
809
  readonly max_expansion_cooldown: uint
803
810
  }
804
811
 
805
812
  interface UnitGroupMapSettings {
806
813
  /**
807
- * The minimum amount of time in ticks a group will spend gathering before setting off. The actual time is a random time between the minimum and maximum times. Defaults to `3,600` ticks.
814
+ * The minimum amount of time in ticks a group will spend gathering before setting off. The actual time is a random time between the minimum and maximum times. Defaults to `3'600` ticks.
808
815
  */
809
816
  readonly min_group_gathering_time: uint
810
817
  /**
811
- * The maximum amount of time in ticks a group will spend gathering before setting off. The actual time is a random time between the minimum and maximum times. Defaults to `10*3,600=36,000` ticks.
818
+ * The maximum amount of time in ticks a group will spend gathering before setting off. The actual time is a random time between the minimum and maximum times. Defaults to `10*3'600=36'000` ticks.
812
819
  */
813
820
  readonly max_group_gathering_time: uint
814
821
  /**
815
- * After gathering has finished, the group is allowed to wait this long in ticks for delayed members. New members are not accepted anymore however. Defaults to `2*3,600=7,200` ticks.
822
+ * After gathering has finished, the group is allowed to wait this long in ticks for delayed members. New members are not accepted anymore however. Defaults to `2*3'600=7'200` ticks.
816
823
  */
817
824
  readonly max_wait_time_for_late_members: uint
818
825
  /**
@@ -882,11 +889,11 @@ interface PathFinderMapSettings {
882
889
  */
883
890
  readonly goal_pressure_ratio: double
884
891
  /**
885
- * The maximum number of nodes that are expanded per tick. Defaults to `1,000`.
892
+ * The maximum number of nodes that are expanded per tick. Defaults to `1'000`.
886
893
  */
887
894
  readonly max_steps_worked_per_tick: double
888
895
  /**
889
- * The maximum amount of work each pathfinding job is allowed to do per tick. Defaults to `8,000`.
896
+ * The maximum amount of work each pathfinding job is allowed to do per tick. Defaults to `8'000`.
890
897
  */
891
898
  readonly max_work_done_per_tick: uint
892
899
  /**
@@ -1073,17 +1080,6 @@ interface MapExchangeStringData {
1073
1080
  readonly map_gen_settings: MapGenSettings
1074
1081
  }
1075
1082
 
1076
- interface BlueprintItemIcon {
1077
- /**
1078
- * Name of the item prototype whose icon should be used.
1079
- */
1080
- readonly name: string
1081
- /**
1082
- * Index of the icon in the blueprint icons slots. Has to be an integer in the range [1, 4].
1083
- */
1084
- readonly index: uint
1085
- }
1086
-
1087
1083
  interface BlueprintSignalIcon {
1088
1084
  /**
1089
1085
  * The icon to use. It can be any item icon as well as any virtual signal icon.
@@ -2631,7 +2627,7 @@ interface CircuitConnectionDefinition {
2631
2627
 
2632
2628
  interface WireConnectionDefinition {
2633
2629
  /**
2634
- * Wire color, either {@link defines.wire_type.red} or {@link defines.wire_type.green}.
2630
+ * The type of wire used.
2635
2631
  */
2636
2632
  readonly wire: defines.wire_type
2637
2633
  /**
@@ -4144,7 +4140,9 @@ type CapsuleAction =
4144
4140
  * - `"entity-with-force"`: Deprecated. Replaced by `is-military-target`.
4145
4141
  * - `"is-military-target"`: Selects entities that are {@link LuaEntity#is_military_target military targets}.
4146
4142
  * - `"entity-with-owner"`: Selects entities that are {@link LuaEntity#is_entity_with_owner entities with owner}.
4147
- * - `"avoid-rolling-stock"`: Selects entities that are not `rolling-stocks`.
4143
+ * - `"avoid-rolling-stock"`: Selects entities that are not `rolling-stock`s.
4144
+ * - `"entity-ghost"`: Selects entities that are `entity-ghost`s.
4145
+ * - `"tile-ghost"`: Selects entities that are `tile-ghost`s.
4148
4146
  * @see {@link https://lua-api.factorio.com/latest/Concepts.html#SelectionModeFlags Online documentation}
4149
4147
  */
4150
4148
  interface SelectionModeFlags {
@@ -4233,9 +4231,17 @@ interface SelectionModeFlags {
4233
4231
  */
4234
4232
  readonly "entity-with-owner"?: true
4235
4233
  /**
4236
- * Selects entities that are not `rolling-stocks`.
4234
+ * Selects entities that are not `rolling-stock`s.
4237
4235
  */
4238
4236
  readonly "avoid-rolling-stock"?: true
4237
+ /**
4238
+ * Selects entities that are `entity-ghost`s.
4239
+ */
4240
+ readonly "entity-ghost"?: true
4241
+ /**
4242
+ * Selects entities that are `tile-ghost`s.
4243
+ */
4244
+ readonly "tile-ghost"?: true
4239
4245
  }
4240
4246
 
4241
4247
  interface LogisticFilter {
@@ -4253,10 +4259,6 @@ interface LogisticFilter {
4253
4259
  readonly count: uint
4254
4260
  }
4255
4261
 
4256
- /**
4257
- * @remarks Runtime settings can be changed through console commands and by the mod that owns the settings by writing a new table to the ModSetting.
4258
- * @see {@link https://lua-api.factorio.com/latest/Concepts.html#ModSetting Online documentation}
4259
- */
4260
4262
  interface ModSetting {
4261
4263
  /**
4262
4264
  * The value of the mod setting. The type depends on the kind of setting.
@@ -1333,6 +1333,30 @@ declare namespace defines {
1333
1333
  * Event type: {@link OnPlayerAltReverseSelectedAreaEvent}
1334
1334
  */
1335
1335
  const on_player_alt_reverse_selected_area: EventId<OnPlayerAltReverseSelectedAreaEvent>
1336
+ /**
1337
+ * Event type: {@link OnGuiHoverEvent}
1338
+ */
1339
+ const on_gui_hover: EventId<OnGuiHoverEvent>
1340
+ /**
1341
+ * Event type: {@link OnGuiLeaveEvent}
1342
+ */
1343
+ const on_gui_leave: EventId<OnGuiLeaveEvent>
1344
+ /**
1345
+ * Event type: {@link OnEntityColorChangedEvent}
1346
+ */
1347
+ const on_entity_color_changed: EventId<OnEntityColorChangedEvent>
1348
+ /**
1349
+ * Event type: {@link OnCutsceneStartedEvent}
1350
+ */
1351
+ const on_cutscene_started: EventId<OnCutsceneStartedEvent>
1352
+ /**
1353
+ * Event type: {@link OnCutsceneFinishedEvent}
1354
+ */
1355
+ const on_cutscene_finished: EventId<OnCutsceneFinishedEvent>
1356
+ /**
1357
+ * Event type: {@link OnPlayerInputMethodChangedEvent}
1358
+ */
1359
+ const on_player_input_method_changed: EventId<OnPlayerInputMethodChangedEvent>
1336
1360
  }
1337
1361
  /**
1338
1362
  * See the {@linkplain https://lua-api.factorio.com/latest/events.html events page} for more info on what events contain and when they get raised.
@@ -1349,6 +1373,23 @@ declare namespace defines {
1349
1373
  two_hundred_fifty_hours,
1350
1374
  one_thousand_hours,
1351
1375
  }
1376
+ enum game_controller_interaction {
1377
+ /**
1378
+ * Game controller will always hover this element regardless of type or state.
1379
+ * @see {@link https://lua-api.factorio.com/latest/defines.html#defines.game_controller_interaction.always Online documentation}
1380
+ */
1381
+ always,
1382
+ /**
1383
+ * Hover according to the element type and implementation.
1384
+ * @see {@link https://lua-api.factorio.com/latest/defines.html#defines.game_controller_interaction.never Online documentation}
1385
+ */
1386
+ never,
1387
+ /**
1388
+ * Never hover this element with a game controller.
1389
+ * @see {@link https://lua-api.factorio.com/latest/defines.html#defines.game_controller_interaction.normal Online documentation}
1390
+ */
1391
+ normal,
1392
+ }
1352
1393
  enum group_state {
1353
1394
  gathering,
1354
1395
  moving,
@@ -1458,6 +1499,8 @@ declare namespace defines {
1458
1499
  gui_click,
1459
1500
  gui_confirmed,
1460
1501
  gui_elem_changed,
1502
+ gui_hover,
1503
+ gui_leave,
1461
1504
  gui_location_changed,
1462
1505
  gui_selected_tab_changed,
1463
1506
  gui_selection_state_changed,
@@ -19,6 +19,10 @@ interface CustomInputEvent extends EventData {
19
19
  * The mouse cursor position when the custom input was activated.
20
20
  */
21
21
  readonly cursor_position: MapPosition
22
+ /**
23
+ * The mouse cursor display location when the custom input was activated.
24
+ */
25
+ readonly cursor_display_location: GuiLocation
22
26
  /**
23
27
  * Information about the prototype that is selected when the custom input is used. Needs to be enabled on the custom input's prototype. `nil` if none is selected.
24
28
  */
@@ -449,6 +453,44 @@ interface OnCutsceneCancelledEvent extends EventData {
449
453
  readonly tick: uint
450
454
  }
451
455
 
456
+ /**
457
+ * Called when a cutscene finishes naturally (was not cancelled).
458
+ * @see {@link https://lua-api.factorio.com/latest/events.html#on_cutscene_finished Online documentation}
459
+ */
460
+ interface OnCutsceneFinishedEvent extends EventData {
461
+ /**
462
+ * The player the cutscene was shown to.
463
+ */
464
+ readonly player_index: PlayerIndex
465
+ /**
466
+ * Identifier of the event
467
+ */
468
+ readonly name: typeof defines.events.on_cutscene_finished
469
+ /**
470
+ * Tick the event was generated.
471
+ */
472
+ readonly tick: uint
473
+ }
474
+
475
+ /**
476
+ * Called when a cutscene starts.
477
+ * @see {@link https://lua-api.factorio.com/latest/events.html#on_cutscene_started Online documentation}
478
+ */
479
+ interface OnCutsceneStartedEvent extends EventData {
480
+ /**
481
+ * The player the cutscene is being shown to.
482
+ */
483
+ readonly player_index: PlayerIndex
484
+ /**
485
+ * Identifier of the event
486
+ */
487
+ readonly name: typeof defines.events.on_cutscene_started
488
+ /**
489
+ * Tick the event was generated.
490
+ */
491
+ readonly tick: uint
492
+ }
493
+
452
494
  /**
453
495
  * Called when a cutscene is playing, each time it reaches a waypoint in that cutscene.
454
496
  *
@@ -510,6 +552,25 @@ interface OnEntityClonedEvent extends EventData {
510
552
  readonly tick: uint
511
553
  }
512
554
 
555
+ /**
556
+ * Called after an entity has been recolored either by the player or through script.
557
+ * @see {@link https://lua-api.factorio.com/latest/events.html#on_entity_color_changed Online documentation}
558
+ */
559
+ interface OnEntityColorChangedEvent extends EventData {
560
+ /**
561
+ * The entity that was recolored.
562
+ */
563
+ readonly entity: LuaEntity
564
+ /**
565
+ * Identifier of the event
566
+ */
567
+ readonly name: typeof defines.events.on_entity_color_changed
568
+ /**
569
+ * Tick the event was generated.
570
+ */
571
+ readonly tick: uint
572
+ }
573
+
513
574
  /**
514
575
  * Called when an entity is damaged. Can be filtered using {@link LuaEntityDamagedEventFilter}.
515
576
  * @remarks This is not called when an entities health is set directly by another mod.
@@ -945,6 +1006,10 @@ interface OnGuiClickEvent extends EventData {
945
1006
  * The mouse button used if any.
946
1007
  */
947
1008
  readonly button: defines.mouse_button_type
1009
+ /**
1010
+ * The display location of the player's cursor.
1011
+ */
1012
+ readonly cursor_display_location: GuiLocation
948
1013
  /**
949
1014
  * If alt was pressed.
950
1015
  */
@@ -1083,6 +1148,52 @@ interface OnGuiElemChangedEvent extends EventData {
1083
1148
  readonly tick: uint
1084
1149
  }
1085
1150
 
1151
+ /**
1152
+ * Called when {@link LuaGuiElement} is hovered by the mouse.
1153
+ * @see {@link https://lua-api.factorio.com/latest/events.html#on_gui_hover Online documentation}
1154
+ */
1155
+ interface OnGuiHoverEvent extends EventData {
1156
+ /**
1157
+ * The element that is being hovered over.
1158
+ */
1159
+ readonly element: LuaGuiElement
1160
+ /**
1161
+ * The player whose cursor is hovering.
1162
+ */
1163
+ readonly player_index: PlayerIndex
1164
+ /**
1165
+ * Identifier of the event
1166
+ */
1167
+ readonly name: typeof defines.events.on_gui_hover
1168
+ /**
1169
+ * Tick the event was generated.
1170
+ */
1171
+ readonly tick: uint
1172
+ }
1173
+
1174
+ /**
1175
+ * Called when the player's cursor leaves a {@link LuaGuiElement} that was previously hovered.
1176
+ * @see {@link https://lua-api.factorio.com/latest/events.html#on_gui_leave Online documentation}
1177
+ */
1178
+ interface OnGuiLeaveEvent extends EventData {
1179
+ /**
1180
+ * The element that was being hovered.
1181
+ */
1182
+ readonly element: LuaGuiElement
1183
+ /**
1184
+ * The player whose cursor was hovering.
1185
+ */
1186
+ readonly player_index: PlayerIndex
1187
+ /**
1188
+ * Identifier of the event
1189
+ */
1190
+ readonly name: typeof defines.events.on_gui_leave
1191
+ /**
1192
+ * Tick the event was generated.
1193
+ */
1194
+ readonly tick: uint
1195
+ }
1196
+
1086
1197
  /**
1087
1198
  * Called when {@link LuaGuiElement} element location is changed (related to frames in `player.gui.screen`).
1088
1199
  * @see {@link https://lua-api.factorio.com/latest/events.html#on_gui_location_changed Online documentation}
@@ -1962,7 +2073,7 @@ interface OnPlayerCreatedEvent extends EventData {
1962
2073
  }
1963
2074
 
1964
2075
  /**
1965
- * Called after a players cursorstack changed in some way.
2076
+ * Called after a player's {@link LuaControl#cursor_stack cursor stack} changed in some way.
1966
2077
  * @see {@link https://lua-api.factorio.com/latest/events.html#on_player_cursor_stack_changed Online documentation}
1967
2078
  */
1968
2079
  interface OnPlayerCursorStackChangedEvent extends EventData {
@@ -2217,6 +2328,26 @@ interface OnPlayerGunInventoryChangedEvent extends EventData {
2217
2328
  readonly tick: uint
2218
2329
  }
2219
2330
 
2331
+ /**
2332
+ * Called when a player's input method changes.
2333
+ * @remarks See {@link LuaPlayer#input_method LuaPlayer::input_method}.
2334
+ * @see {@link https://lua-api.factorio.com/latest/events.html#on_player_input_method_changed Online documentation}
2335
+ */
2336
+ interface OnPlayerInputMethodChangedEvent extends EventData {
2337
+ /**
2338
+ * The player whose input method changed.
2339
+ */
2340
+ readonly player_index: PlayerIndex
2341
+ /**
2342
+ * Identifier of the event
2343
+ */
2344
+ readonly name: typeof defines.events.on_player_input_method_changed
2345
+ /**
2346
+ * Tick the event was generated.
2347
+ */
2348
+ readonly tick: uint
2349
+ }
2350
+
2220
2351
  /**
2221
2352
  * Called after a player joins the game. This is not called when loading a save file in singleplayer, as the player doesn't actually leave the game, and the save is just on pause until they rejoin.
2222
2353
  * @see {@link https://lua-api.factorio.com/latest/events.html#on_player_joined_game Online documentation}
@@ -2455,12 +2586,12 @@ interface OnPlayerPromotedEvent extends EventData {
2455
2586
  }
2456
2587
 
2457
2588
  /**
2458
- * Called when a player is removed (deleted) from the game. Not to be confused with the player logging of this is different in that the player is deleted as if he never existed in the save file.
2589
+ * Called when a player is removed (deleted) from the game. This is markedly different from a player temporarily {@link OnPlayerLeftGameEvent leaving} the game, and instead behaves like the player never existed in the save file.
2459
2590
  * @see {@link https://lua-api.factorio.com/latest/events.html#on_player_removed Online documentation}
2460
2591
  */
2461
2592
  interface OnPlayerRemovedEvent extends EventData {
2462
2593
  /**
2463
- * The player index that was removed
2594
+ * The index of the removed player.
2464
2595
  */
2465
2596
  readonly player_index: PlayerIndex
2466
2597
  /**
@@ -3158,12 +3289,12 @@ interface OnPrePlayerMinedItemEvent extends EventData {
3158
3289
  }
3159
3290
 
3160
3291
  /**
3161
- * Called before a player is removed (deleted) from the game. Not to be confused with the player logging of this is different in that the player is deleted as if he never existed in the save file.
3292
+ * Called before a player is removed (deleted) from the game. This is markedly different from a player temporarily {@link OnPlayerLeftGameEvent leaving} the game, and instead behaves like the player never existed in the save file.
3162
3293
  * @see {@link https://lua-api.factorio.com/latest/events.html#on_pre_player_removed Online documentation}
3163
3294
  */
3164
3295
  interface OnPrePlayerRemovedEvent extends EventData {
3165
3296
  /**
3166
- * The player index that will be removed
3297
+ * The index of the removed player.
3167
3298
  */
3168
3299
  readonly player_index: PlayerIndex
3169
3300
  /**
@@ -3886,7 +4017,7 @@ interface OnSurfaceDeletedEvent extends EventData {
3886
4017
  }
3887
4018
 
3888
4019
  /**
3889
- * Called after a surface is imported.
4020
+ * Called after a surface is imported via the map editor.
3890
4021
  * @see {@link https://lua-api.factorio.com/latest/events.html#on_surface_imported Online documentation}
3891
4022
  */
3892
4023
  interface OnSurfaceImportedEvent extends EventData {