typed-factorio 0.8.1 → 0.11.0-packagetypes-1

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,6 +1,21 @@
1
+ # v0.11.0
2
+
3
+ - Update to factorio version 1.1.46
4
+
5
+ # v0.10.0
6
+
7
+ - LuaGuiElement.style and LuaControl.opened now have different get/set types (more specific get type).
8
+ - The array form of LocalizedString is now readonly.
9
+
10
+ # v0.9.0
11
+
12
+ - Update to factorio version 1.1.43
13
+ - The `defines.events `_type_ was renamed to `defines.Events`, to reduce confusion between the namespace/type
14
+
1
15
  # v0.8.0
16
+
2
17
  - All event types now explicitly extend `EventData`
3
- - Variant parameter groups without additional fields now have their own type, instead of all being grouped into `Other<Type>`
18
+ - Variant parameter groups without additional fields now have their own type, instead of all being grouped into `Other`
4
19
 
5
20
  # v0.7.3
6
21
 
@@ -28,8 +43,7 @@
28
43
  # v0.5.0
29
44
 
30
45
  - Updated to factorio version 1.1.39
31
- - Documentation links now point to the new API docs website. More info
32
- here: https://forums.factorio.com/viewtopic.php?f=34&t=99797
46
+ - Documentation links now point to the new API docs website. More info here: https://forums.factorio.com/viewtopic.php?f=34&t=99797
33
47
 
34
48
  # v0.4.1
35
49
 
@@ -1349,10 +1349,12 @@ interface LuaControl {
1349
1349
  */
1350
1350
  clear_vehicle_logistic_slot(slot_index: uint): void
1351
1351
  /**
1352
- * Returns whether the player is holding a blueprint, it takes into account a blueprint as an item as well as
1353
- * blueprint from the blueprint record from the blueprint library. Note that the is_cursor_blueprint and
1354
- * get_cursor_blueprint_entities refer to the currently selected blueprint, so it returns blueprint related
1355
- * information also when holding a blueprint book with a blueprint being selected in it.
1352
+ * Returns whether the player is holding a blueprint. This takes both blueprint items as well as blueprint records
1353
+ * from the blueprint library into account.
1354
+ *
1355
+ * **Note**: Both this method and {@link LuaControl.get_blueprint_entities LuaControl::get_blueprint_entities} refer
1356
+ * to the currently selected blueprint, meaning a blueprint book with a selected blueprint will return the
1357
+ * information as well.
1356
1358
  *
1357
1359
  * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.is_cursor_blueprint View documentation}
1358
1360
  */
@@ -1415,15 +1417,18 @@ interface LuaControl {
1415
1417
  *
1416
1418
  * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.opened View documentation}
1417
1419
  */
1418
- opened:
1419
- | LuaEntity
1420
- | LuaItemStack
1421
- | LuaEquipment
1422
- | LuaEquipmentGrid
1423
- | LuaPlayer
1424
- | LuaGuiElement
1425
- | defines.gui_type
1426
- | undefined
1420
+ set opened(
1421
+ value:
1422
+ | LuaEntity
1423
+ | LuaItemStack
1424
+ | LuaEquipment
1425
+ | LuaEquipmentGrid
1426
+ | LuaPlayer
1427
+ | LuaGuiElement
1428
+ | defines.gui_type
1429
+ | undefined
1430
+ )
1431
+ get opened(): LuaEntity | LuaEquipment | LuaEquipmentGrid | LuaPlayer | LuaGuiElement | undefined
1427
1432
  /**
1428
1433
  * Size of the crafting queue.
1429
1434
  *
@@ -2297,24 +2302,24 @@ interface LuaEntity extends LuaControl {
2297
2302
  */
2298
2303
  die(force?: ForceIdentification, cause?: LuaEntity): boolean
2299
2304
  /**
2300
- * Test whether this entity's prototype has a flag set.
2305
+ * Test whether this entity's prototype has a certain flag set.
2301
2306
  *
2302
2307
  * **Note**: `entity.has_flag(f)` is a shortcut for `entity.prototype.has_flag(f)`.
2303
2308
  *
2304
2309
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.has_flag View documentation}
2305
2310
  *
2306
- * @param flag - The flag to test
2307
- * @returns `true` if the entity has the given flag set.
2311
+ * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
2312
+ * @returns `true` if this entity has the given flag set.
2308
2313
  */
2309
2314
  has_flag(flag: string): boolean
2310
2315
  /**
2311
- * Same as {@link LuaEntity.has_flag LuaEntity::has_flag} but targets the inner entity on a entity ghost.
2316
+ * Same as {@link LuaEntity.has_flag LuaEntity::has_flag}, but targets the inner entity on a entity ghost.
2312
2317
  *
2313
2318
  * *Can only be used if this is EntityGhost*
2314
2319
  *
2315
2320
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ghost_has_flag View documentation}
2316
2321
  *
2317
- * @param flag - The flag to test
2322
+ * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
2318
2323
  * @returns `true` if the entity has the given flag set.
2319
2324
  */
2320
2325
  ghost_has_flag(flag: string): boolean
@@ -2556,7 +2561,7 @@ interface LuaEntity extends LuaControl {
2556
2561
  *
2557
2562
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_transport_line View documentation}
2558
2563
  *
2559
- * @param index - Index of the requested transport line.
2564
+ * @param index - Index of the requested transport line. Transport lines are 1-indexed.
2560
2565
  */
2561
2566
  get_transport_line(index: uint): LuaTransportLine
2562
2567
  /**
@@ -3007,6 +3012,9 @@ interface LuaEntity extends LuaControl {
3007
3012
  /**
3008
3013
  * Get the amount of all or some fluid in this entity.
3009
3014
  *
3015
+ * **Note**: If information about fluid temperatures is required, {@link LuaEntity.fluidbox LuaEntity::fluidbox}
3016
+ * should be used instead.
3017
+ *
3010
3018
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_fluid_count View documentation}
3011
3019
  *
3012
3020
  * @param fluid - Prototype name of the fluid to count. If not specified, count all fluids.
@@ -3015,6 +3023,9 @@ interface LuaEntity extends LuaControl {
3015
3023
  /**
3016
3024
  * Get amounts of all fluids in this entity.
3017
3025
  *
3026
+ * **Note**: If information about fluid temperatures is required, {@link LuaEntity.fluidbox LuaEntity::fluidbox}
3027
+ * should be used instead.
3028
+ *
3018
3029
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_fluid_contents View documentation}
3019
3030
  *
3020
3031
  * @returns The amounts, indexed by fluid names.
@@ -3567,21 +3578,26 @@ interface LuaEntity extends LuaControl {
3567
3578
  */
3568
3579
  pickup_position: Position
3569
3580
  /**
3570
- * The entity this entity is putting its stuff to or `nil` if there is no such entity.
3581
+ * The entity this entity is putting its items to, or `nil` if there is no such entity. If there are multiple
3582
+ * possible entities at the drop-off point, writing to this attribute allows a mod to choose which one to drop off
3583
+ * items to. The entity needs to collide with the tile box under the drop-off position.
3571
3584
  *
3572
- * **Note**: Meaningful only for entities that put stuff somewhere, such as mining drills or inserters.
3585
+ * **Note**: Meaningful only for entities that put items somewhere, such as mining drills or inserters. Returns
3586
+ * `nil` for any other entity.
3573
3587
  *
3574
3588
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.drop_target View documentation}
3575
3589
  */
3576
3590
  drop_target: LuaEntity | undefined
3577
3591
  /**
3578
- * The entity the inserter will attempt to pick up from. For example, this can be a transport belt or a storage chest.
3592
+ * The entity this inserter will attempt to pick up items from, or `nil` if there is no such entity. If there are
3593
+ * multiple possible entities at the pick-up point, writing to this attribute allows a mod to choose which one to
3594
+ * pick up items from. The entity needs to collide with the tile box under the pick-up position.
3579
3595
  *
3580
3596
  * *Can only be used if this is Inserter*
3581
3597
  *
3582
3598
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.pickup_target View documentation}
3583
3599
  */
3584
- pickup_target: LuaEntity
3600
+ pickup_target: LuaEntity | undefined
3585
3601
  /**
3586
3602
  * Index of the currently selected weapon slot of this character, car, or spidertron, or `nil` if the car/spidertron
3587
3603
  * doesn't have guns.
@@ -4290,6 +4306,14 @@ interface LuaEntity extends LuaControl {
4290
4306
  * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.connected_rail View documentation}
4291
4307
  */
4292
4308
  readonly connected_rail: LuaEntity | undefined
4309
+ /**
4310
+ * Rail direction to which this train stop is binding. This returns a value even when no rails are present.
4311
+ *
4312
+ * *Can only be used if this is TrainStop*
4313
+ *
4314
+ * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.connected_rail_direction View documentation}
4315
+ */
4316
+ readonly connected_rail_direction: defines.rail_direction
4293
4317
  /**
4294
4318
  * The number of trains in this rail block for this rail entity.
4295
4319
  *
@@ -4614,42 +4638,14 @@ interface LuaEntity extends LuaControl {
4614
4638
  */
4615
4639
  interface LuaEntityPrototype {
4616
4640
  /**
4617
- * Does this prototype have a flag enabled?
4641
+ * Test whether this entity prototype has a certain flag set.
4618
4642
  *
4619
4643
  * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.has_flag View documentation}
4620
4644
  *
4621
- * @param flag - The flag to check. Must be one of - `"not-rotatable"` - `"placeable-neutral"` -
4622
- * `"placeable-player"` - `"placeable-enemy"` - `"placeable-off-grid"` - `"player-creation"` -
4623
- * `"building-direction-8-way"` - `"filter-directions"` - `"fast-replaceable-no-build-while-moving"` -
4624
- * `"breaths-air"` - `"not-repairable"` - `"not-on-map"` - `"not-deconstructable"` - `"not-blueprintable"` -
4625
- * `"hide-from-bonus-gui"` - `"hide-alt-info"` - `"fast-replaceable-no-cross-type-while-moving"` -
4626
- * `"no-gap-fill-while-building"` - `"not-flammable"` - `"no-automated-item-removal"` -
4627
- * `"no-automated-item-insertion"` - `"not-upgradable"`
4628
- */
4629
- has_flag(
4630
- flag:
4631
- | "not-rotatable"
4632
- | "placeable-neutral"
4633
- | "placeable-player"
4634
- | "placeable-enemy"
4635
- | "placeable-off-grid"
4636
- | "player-creation"
4637
- | "filter-directions"
4638
- | "fast-replaceable-no-build-while-moving"
4639
- | "breaths-air"
4640
- | "not-repairable"
4641
- | "not-on-map"
4642
- | "not-deconstructable"
4643
- | "not-blueprintable"
4644
- | "hide-from-bonus-gui"
4645
- | "hide-alt-info"
4646
- | "fast-replaceable-no-cross-type-while-moving"
4647
- | "no-gap-fill-while-building"
4648
- | "not-flammable"
4649
- | "no-automated-item-removal"
4650
- | "no-automated-item-insertion"
4651
- | "not-upgradable"
4652
- ): boolean
4645
+ * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
4646
+ * @returns `true` if this prototype has the given flag set.
4647
+ */
4648
+ has_flag(flag: string): boolean
4653
4649
  /**
4654
4650
  * Gets the base size of the given inventory on this entity or `nil` if the given inventory doesn't exist.
4655
4651
  *
@@ -4964,7 +4960,7 @@ interface LuaEntityPrototype {
4964
4960
  */
4965
4961
  readonly max_underground_distance: uint8 | undefined
4966
4962
  /**
4967
- * The entity prototype flags for this entity.
4963
+ * The flags for this entity prototype.
4968
4964
  *
4969
4965
  * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.flags View documentation}
4970
4966
  */
@@ -9645,6 +9641,15 @@ interface BaseGuiElement {
9645
9641
  * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_index_in_parent View documentation}
9646
9642
  */
9647
9643
  get_index_in_parent(): uint
9644
+ /**
9645
+ * Swaps the children at the given indices in this element.
9646
+ *
9647
+ * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.swap_children View documentation}
9648
+ *
9649
+ * @param index_1 - The index of the first child.
9650
+ * @param index_2 - The index of the second child.
9651
+ */
9652
+ swap_children(index_1: uint, index_2: uint): void
9648
9653
  /**
9649
9654
  * Focuses this GUI element if possible.
9650
9655
  *
@@ -9704,7 +9709,8 @@ interface BaseGuiElement {
9704
9709
  *
9705
9710
  * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.style View documentation}
9706
9711
  */
9707
- style: LuaStyle | string
9712
+ set style(style: LuaStyle | string)
9713
+ get style(): LuaStyle
9708
9714
  /**
9709
9715
  * Sets whether this GUI element is visible or completely hidden, taking no space in the layout.
9710
9716
  *
@@ -11492,13 +11498,12 @@ interface LuaInventory extends ReadonlyArray<LuaItemStack> {
11492
11498
  */
11493
11499
  interface LuaItemPrototype {
11494
11500
  /**
11495
- * Does this prototype have a flag enabled?
11496
- *
11497
- * Any other value will cause an error.
11501
+ * Test whether this item prototype has a certain flag set.
11498
11502
  *
11499
11503
  * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.has_flag View documentation}
11500
11504
  *
11501
- * @param flag - The flag to check. Can be one of {@link ItemPrototypeFlags}
11505
+ * @param flag - The flag to test. See {@link ItemPrototypeFlags} for a list of flags.
11506
+ * @returns `true` if this prototype has the given flag set.
11502
11507
  */
11503
11508
  has_flag(flag: string): boolean
11504
11509
  /**
@@ -11621,7 +11626,7 @@ interface LuaItemPrototype {
11621
11626
  */
11622
11627
  readonly group: LuaGroup
11623
11628
  /**
11624
- * The item prototype flags for this item prototype.
11629
+ * The flags for this item prototype.
11625
11630
  *
11626
11631
  * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.flags View documentation}
11627
11632
  */
@@ -19645,7 +19650,7 @@ interface LuaTrain {
19645
19650
  /**
19646
19651
  * The players killed by this train.
19647
19652
  *
19648
- * The keys are the player indexes, the values are how often this train killed that player.
19653
+ * The keys are the player indices, the values are how often this train killed that player.
19649
19654
  *
19650
19655
  * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.killed_players View documentation}
19651
19656
  */
@@ -47,7 +47,7 @@
47
47
  * game.print({"", {"item-name.iron-plate"}, ": ", 60})
48
48
  * ```
49
49
  */
50
- type LocalisedString = [string, ...LocalisedString[]] | string | number
50
+ type LocalisedString = readonly [string, ...LocalisedString[]] | string | number
51
51
 
52
52
  interface DisplayResolution {
53
53
  readonly width: uint
@@ -2111,6 +2111,12 @@ interface TrainScheduleRecord {
2111
2111
  readonly station?: string
2112
2112
  /** Rail to path to. Ignored if `station` is present. */
2113
2113
  readonly rail?: LuaEntity
2114
+ /**
2115
+ * When a train is allowed to reach rail target from any direction it will be `nil`. If rail has to be reached from
2116
+ * specific direction, this value allows to choose the direction. This value corresponds to
2117
+ * {@link LuaEntity.connected_rail_direction LuaEntity::connected_rail_direction} of a TrainStop.
2118
+ */
2119
+ readonly rail_direction?: defines.rail_direction
2114
2120
  readonly wait_conditions?: WaitCondition[]
2115
2121
  /** Only present when the station is temporary, the value is then always `true`. */
2116
2122
  readonly temporary?: boolean
@@ -2366,6 +2372,7 @@ interface EntityPrototypeFlags {
2366
2372
  readonly "no-copy-paste"?: boolean
2367
2373
  readonly "not-selectable-in-game"?: boolean
2368
2374
  readonly "not-upgradable"?: boolean
2375
+ readonly "not-in-kill-statistics"?: boolean
2369
2376
  }
2370
2377
 
2371
2378
  /**
@@ -2386,6 +2393,7 @@ interface ItemPrototypeFlags {
2386
2393
  readonly "primary-place-result"?: boolean
2387
2394
  readonly "mod-openable"?: boolean
2388
2395
  readonly "only-in-cursor"?: boolean
2396
+ readonly spawnable?: boolean
2389
2397
  }
2390
2398
 
2391
2399
  /**
@@ -3014,6 +3022,12 @@ interface VehicleAutomaticTargetingParameters {
3014
3022
  readonly auto_target_with_gunner: boolean
3015
3023
  }
3016
3024
 
3025
+ /**
3026
+ * Defines which slider in the game's sound settings affects the volume of this sound. Furthermore, some sound types are
3027
+ * mixed differently than others, e.g. zoom level effects are applied.
3028
+ *
3029
+ * {@link https://lua-api.factorio.com/next/Concepts.html#SoundType View documentation}
3030
+ */
3017
3031
  type SoundType = "game-effect" | "gui-effect" | "ambient" | "environment" | "walking" | "alert" | "wind"
3018
3032
 
3019
3033
  interface BaseItemPrototypeFilter {
@@ -1087,7 +1087,7 @@ declare namespace defines {
1087
1087
  *
1088
1088
  * {@link https://lua-api.factorio.com/next/defines.html#defines.events View documentation}
1089
1089
  */
1090
- type events = typeof events[keyof typeof events]
1090
+ type Events = typeof events[keyof typeof events]
1091
1091
  enum flow_precision_index {
1092
1092
  five_seconds,
1093
1093
  one_minute,
@@ -667,6 +667,8 @@ interface OnForcesMergingEvent extends EventData {
667
667
  * Called when a game is created from a scenario. This is fired for every mod, even when the scenario's save data
668
668
  * already includes it. In those cases however, {@link LuaBootstrap.on_init LuaBootstrap::on_init} is not fired.
669
669
  *
670
+ * **Note**: This event is not fired when the scenario is loaded via the map editor.
671
+ *
670
672
  * {@link https://lua-api.factorio.com/next/Events.html#on_game_created_from_scenario View documentation}
671
673
  */
672
674
  interface OnGameCreatedFromScenarioEvent extends EventData {
@@ -2968,7 +2970,7 @@ type EventId<T extends table, F = unknown> = uint & {
2968
2970
  }
2969
2971
 
2970
2972
  /**
2971
- * An event id generated by {@link LuaBootstrap.generate_event_name LuaBootstrap::generate_event_name} and raisable via
2973
+ * An event id generated by {@link LuaBootstrap.generate_event_name LuaBootstrap::generate_event_name} and raiseable via
2972
2974
  * {@link LuaBootstrap.raise_event LuaBootstrap::raise_event}.
2973
2975
  */
2974
2976
  type CustomEventId<T extends table> = EventId<T> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-factorio",
3
- "version": "0.8.1",
3
+ "version": "0.11.0-packagetypes-1",
4
4
  "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
5
  "keywords": [
6
6
  "factorio",
@@ -13,6 +13,7 @@
13
13
  "files": [
14
14
  "**/*.d.ts"
15
15
  ],
16
+ "types": "runtime/index.d.ts",
16
17
  "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
17
18
  "scripts": {
18
19
  "gen": "ts-node generator/index.ts",