typed-factorio 0.15.0 → 0.18.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.
@@ -1382,7 +1382,8 @@ interface LuaControl {
1382
1382
  *
1383
1383
  * {@link https://lua-api.factorio.com/latest/LuaControl.html#LuaControl.force View documentation}
1384
1384
  */
1385
- force: ForceIdentification
1385
+ get force(): LuaForce
1386
+ set force(value: ForceIdentification)
1386
1387
  /**
1387
1388
  * The currently selected entity; `nil` if none. Assigning an entity will select it if selectable otherwise clears selection.
1388
1389
  *
@@ -1532,7 +1533,8 @@ interface LuaControl {
1532
1533
  *
1533
1534
  * {@link https://lua-api.factorio.com/latest/LuaControl.html#LuaControl.cursor_ghost View documentation}
1534
1535
  */
1535
- cursor_ghost: ItemPrototypeIdentification
1536
+ get cursor_ghost(): LuaItemPrototype
1537
+ set cursor_ghost(value: ItemPrototypeIdentification)
1536
1538
  /**
1537
1539
  * `true` if the player is in a vehicle. Writing to this attribute puts the player in or out of a vehicle.
1538
1540
  *
@@ -1939,7 +1941,7 @@ interface LuaCustomInputPrototype {
1939
1941
  help(): string
1940
1942
  }
1941
1943
 
1942
- type CustomTableIndex<K extends keyof any, V>
1944
+ type CustomTableIndex<K extends string | number, V>
1943
1945
  /**
1944
1946
  * Access an element of this custom table.
1945
1947
  *
@@ -2012,7 +2014,9 @@ interface LuaCustomTableMembers {
2012
2014
  * global.p = game.players -- This has high potential to make the game unsaveable
2013
2015
  * ```
2014
2016
  */
2015
- type LuaCustomTable<K extends keyof any, V> = LuaCustomTableMembers & CustomTableIndex<K, V>
2017
+ type LuaCustomTable<K extends string | number, V> = LuaCustomTableMembers &
2018
+ CustomTableIndex<K, V> &
2019
+ LuaPairsIterable<[number] extends [K] ? number : K, V>
2016
2020
 
2017
2021
  /**
2018
2022
  * Prototype of a damage.
@@ -2314,7 +2318,7 @@ interface LuaEntity extends LuaControl {
2314
2318
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
2315
2319
  * @returns `true` if this entity has the given flag set.
2316
2320
  */
2317
- has_flag(flag: string): boolean
2321
+ has_flag(flag: keyof EntityPrototypeFlags): boolean
2318
2322
  /**
2319
2323
  * Same as {@link LuaEntity.has_flag LuaEntity::has_flag}, but targets the inner entity on a entity ghost.
2320
2324
  *
@@ -2325,7 +2329,7 @@ interface LuaEntity extends LuaControl {
2325
2329
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
2326
2330
  * @returns `true` if the entity has the given flag set.
2327
2331
  */
2328
- ghost_has_flag(flag: string): boolean
2332
+ ghost_has_flag(flag: keyof EntityPrototypeFlags): boolean
2329
2333
  /**
2330
2334
  * Offer a thing on the market.
2331
2335
  *
@@ -3256,8 +3260,8 @@ interface LuaEntity extends LuaControl {
3256
3260
  is_registered_for_construction(): boolean
3257
3261
  /**
3258
3262
  * Is this entity registered for deconstruction with this force? If false, it means a construction robot has been
3259
- * dispatched to deconstruct it, or it is not marked for deconstruction. This is worst-case O(N) complexity where N
3260
- * is the current number of things in the deconstruct queue.
3263
+ * dispatched to deconstruct it, or it is not marked for deconstruction. The complexity is effectively O(1) - it
3264
+ * depends on the number of objects targeting this entity which should be small enough.
3261
3265
  *
3262
3266
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.is_registered_for_deconstruction View documentation}
3263
3267
  *
@@ -3315,6 +3319,14 @@ interface LuaEntity extends LuaControl {
3315
3319
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.disconnect_linked_belts View documentation}
3316
3320
  */
3317
3321
  disconnect_linked_belts(): void
3322
+ /**
3323
+ * Gets legs of given SpiderVehicle.
3324
+ *
3325
+ * *Can only be used if this is SpiderVehicle*
3326
+ *
3327
+ * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.get_spider_legs View documentation}
3328
+ */
3329
+ get_spider_legs(): LuaEntity[]
3318
3330
  /**
3319
3331
  * Name of the entity prototype. E.g. "inserter" or "filter-inserter".
3320
3332
  *
@@ -3669,6 +3681,8 @@ interface LuaEntity extends LuaControl {
3669
3681
  * - When called on an underground transport belt, this is the other end of the underground belt connection, or `nil` if none.
3670
3682
  * - When called on a wall-connectable entity or reactor, this is a dictionary of all connections indexed by the
3671
3683
  * connection direction "north", "south", "east", and "west".
3684
+ * - When called on a cliff entity, this is a dictionary of all connections indexed by the connection direction
3685
+ * "north", "south", "east", and "west".
3672
3686
  *
3673
3687
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.neighbours View documentation}
3674
3688
  */
@@ -4398,7 +4412,8 @@ interface LuaEntity extends LuaControl {
4398
4412
  *
4399
4413
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_to_forces View documentation}
4400
4414
  */
4401
- render_to_forces: ForceIdentification[] | undefined
4415
+ get render_to_forces(): LuaForce[] | undefined
4416
+ set render_to_forces(value: ForceIdentification[] | undefined)
4402
4417
  /**
4403
4418
  * The rail target of this pump or `nil`.
4404
4419
  *
@@ -4549,11 +4564,18 @@ interface LuaEntity extends LuaControl {
4549
4564
  */
4550
4565
  trains_limit: uint
4551
4566
  /**
4552
- * If this entity is EntityWithForce
4567
+ * (deprecated by 1.1.51) If this entity is a MilitaryTarget. Returns same value as LuaEntity::is_military_target
4553
4568
  *
4554
4569
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.is_entity_with_force View documentation}
4555
4570
  */
4556
4571
  readonly is_entity_with_force: boolean
4572
+ /**
4573
+ * If this entity is a MilitaryTarget. Can be written to if
4574
+ * LuaEntityPrototype::allow_run_time_change_of_is_military_target returns true
4575
+ *
4576
+ * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.is_military_target View documentation}
4577
+ */
4578
+ is_military_target: boolean
4557
4579
  /**
4558
4580
  * If this entity is EntityWithOwner
4559
4581
  *
@@ -4721,7 +4743,7 @@ interface BaseEntity extends LuaControl {
4721
4743
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
4722
4744
  * @returns `true` if this entity has the given flag set.
4723
4745
  */
4724
- has_flag(flag: string): boolean
4746
+ has_flag(flag: keyof EntityPrototypeFlags): boolean
4725
4747
  /**
4726
4748
  * Connect two devices with a circuit wire or copper cable. Depending on which type of connection should be made,
4727
4749
  * there are different procedures:
@@ -5240,8 +5262,8 @@ interface BaseEntity extends LuaControl {
5240
5262
  is_registered_for_construction(): boolean
5241
5263
  /**
5242
5264
  * Is this entity registered for deconstruction with this force? If false, it means a construction robot has been
5243
- * dispatched to deconstruct it, or it is not marked for deconstruction. This is worst-case O(N) complexity where N
5244
- * is the current number of things in the deconstruct queue.
5265
+ * dispatched to deconstruct it, or it is not marked for deconstruction. The complexity is effectively O(1) - it
5266
+ * depends on the number of objects targeting this entity which should be small enough.
5245
5267
  *
5246
5268
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.is_registered_for_deconstruction View documentation}
5247
5269
  *
@@ -5445,6 +5467,8 @@ interface BaseEntity extends LuaControl {
5445
5467
  * - When called on an underground transport belt, this is the other end of the underground belt connection, or `nil` if none.
5446
5468
  * - When called on a wall-connectable entity or reactor, this is a dictionary of all connections indexed by the
5447
5469
  * connection direction "north", "south", "east", and "west".
5470
+ * - When called on a cliff entity, this is a dictionary of all connections indexed by the connection direction
5471
+ * "north", "south", "east", and "west".
5448
5472
  *
5449
5473
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.neighbours View documentation}
5450
5474
  */
@@ -5779,7 +5803,8 @@ interface BaseEntity extends LuaControl {
5779
5803
  *
5780
5804
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_to_forces View documentation}
5781
5805
  */
5782
- render_to_forces: ForceIdentification[] | undefined
5806
+ get render_to_forces(): LuaForce[] | undefined
5807
+ set render_to_forces(value: ForceIdentification[] | undefined)
5783
5808
  /**
5784
5809
  * Returns the id of the electric network that this entity is connected to or `nil`.
5785
5810
  *
@@ -5824,11 +5849,18 @@ interface BaseEntity extends LuaControl {
5824
5849
  */
5825
5850
  tags: Tags | undefined
5826
5851
  /**
5827
- * If this entity is EntityWithForce
5852
+ * (deprecated by 1.1.51) If this entity is a MilitaryTarget. Returns same value as LuaEntity::is_military_target
5828
5853
  *
5829
5854
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.is_entity_with_force View documentation}
5830
5855
  */
5831
5856
  readonly is_entity_with_force: boolean
5857
+ /**
5858
+ * If this entity is a MilitaryTarget. Can be written to if
5859
+ * LuaEntityPrototype::allow_run_time_change_of_is_military_target returns true
5860
+ *
5861
+ * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.is_military_target View documentation}
5862
+ */
5863
+ is_military_target: boolean
5832
5864
  /**
5833
5865
  * If this entity is EntityWithOwner
5834
5866
  *
@@ -5988,7 +6020,7 @@ interface EntityGhostEntity extends BaseEntity {
5988
6020
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
5989
6021
  * @returns `true` if the entity has the given flag set.
5990
6022
  */
5991
- ghost_has_flag(flag: string): boolean
6023
+ ghost_has_flag(flag: keyof EntityPrototypeFlags): boolean
5992
6024
  /**
5993
6025
  * The unit number of the entity contained in this ghost or nil if the entity doesn't have one.
5994
6026
  *
@@ -6685,6 +6717,14 @@ interface SpiderVehicleEntity extends BaseEntity {
6685
6717
  * @param position - The position the spidertron should move to.
6686
6718
  */
6687
6719
  add_autopilot_destination(position: MapPosition): void
6720
+ /**
6721
+ * Gets legs of given SpiderVehicle.
6722
+ *
6723
+ * *Can only be used if this is SpiderVehicle*
6724
+ *
6725
+ * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.get_spider_legs View documentation}
6726
+ */
6727
+ get_spider_legs(): LuaEntity[]
6688
6728
  /**
6689
6729
  * The torso orientation of this spider vehicle.
6690
6730
  *
@@ -7281,7 +7321,7 @@ interface LuaEntityPrototype {
7281
7321
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
7282
7322
  * @returns `true` if this prototype has the given flag set.
7283
7323
  */
7284
- has_flag(flag: string): boolean
7324
+ has_flag(flag: keyof EntityPrototypeFlags): boolean
7285
7325
  /**
7286
7326
  * Gets the base size of the given inventory on this entity or `nil` if the given inventory doesn't exist.
7287
7327
  *
@@ -8168,6 +8208,12 @@ interface LuaEntityPrototype {
8168
8208
  * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.timeout View documentation}
8169
8209
  */
8170
8210
  readonly timeout: uint
8211
+ /**
8212
+ * Collision mask entity must collide with to make landmine blowup
8213
+ *
8214
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.trigger_collision_mask View documentation}
8215
+ */
8216
+ readonly trigger_collision_mask: CollisionMask
8171
8217
  /**
8172
8218
  * The fluidbox prototypes for this entity.
8173
8219
  *
@@ -8468,6 +8514,35 @@ interface LuaEntityPrototype {
8468
8514
  * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.inserter_stack_size_bonus View documentation}
8469
8515
  */
8470
8516
  readonly inserter_stack_size_bonus: double | undefined
8517
+ /**
8518
+ * True if this entity prototype should be included during tile collision checks with
8519
+ * {@link LuaTilePrototype.check_collision_with_entities LuaTilePrototype::check_collision_with_entities} enabled.
8520
+ *
8521
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.protected_from_tile_building View documentation}
8522
+ */
8523
+ readonly protected_from_tile_building: boolean
8524
+ /**
8525
+ * True if this is entity-with-owner
8526
+ *
8527
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.is_entity_with_owner View documentation}
8528
+ */
8529
+ readonly is_entity_with_owner: boolean
8530
+ /**
8531
+ * True if this entity-with-owner is military target
8532
+ *
8533
+ * *Can only be used if this is EntityWithOwnerPrototype*
8534
+ *
8535
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.is_military_target View documentation}
8536
+ */
8537
+ readonly is_military_target: boolean
8538
+ /**
8539
+ * True if this entity-with-owner's is_military_target can be changed run-time (on the entity, not on the prototype itself)
8540
+ *
8541
+ * *Can only be used if this is EntityWithOwnerPrototype*
8542
+ *
8543
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.allow_run_time_change_of_is_military_target View documentation}
8544
+ */
8545
+ readonly allow_run_time_change_of_is_military_target: boolean
8471
8546
  /**
8472
8547
  * Gets the current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.
8473
8548
  *
@@ -8586,7 +8661,7 @@ interface BaseEntityPrototype {
8586
8661
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
8587
8662
  * @returns `true` if this prototype has the given flag set.
8588
8663
  */
8589
- has_flag(flag: string): boolean
8664
+ has_flag(flag: keyof EntityPrototypeFlags): boolean
8590
8665
  /**
8591
8666
  * Gets the base size of the given inventory on this entity or `nil` if the given inventory doesn't exist.
8592
8667
  *
@@ -9473,6 +9548,12 @@ interface BaseEntityPrototype {
9473
9548
  * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.timeout View documentation}
9474
9549
  */
9475
9550
  readonly timeout: uint
9551
+ /**
9552
+ * Collision mask entity must collide with to make landmine blowup
9553
+ *
9554
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.trigger_collision_mask View documentation}
9555
+ */
9556
+ readonly trigger_collision_mask: CollisionMask
9476
9557
  /**
9477
9558
  * The fluidbox prototypes for this entity.
9478
9559
  *
@@ -9711,6 +9792,19 @@ interface BaseEntityPrototype {
9711
9792
  * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.inserter_stack_size_bonus View documentation}
9712
9793
  */
9713
9794
  readonly inserter_stack_size_bonus: double | undefined
9795
+ /**
9796
+ * True if this entity prototype should be included during tile collision checks with
9797
+ * {@link LuaTilePrototype.check_collision_with_entities LuaTilePrototype::check_collision_with_entities} enabled.
9798
+ *
9799
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.protected_from_tile_building View documentation}
9800
+ */
9801
+ readonly protected_from_tile_building: boolean
9802
+ /**
9803
+ * True if this is entity-with-owner
9804
+ *
9805
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.is_entity_with_owner View documentation}
9806
+ */
9807
+ readonly is_entity_with_owner: boolean
9714
9808
  /**
9715
9809
  * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that
9716
9810
  * the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the
@@ -9801,6 +9895,25 @@ interface TransportBeltEntityPrototype extends BaseEntityPrototype {
9801
9895
  readonly related_underground_belt: LuaEntityPrototype
9802
9896
  }
9803
9897
 
9898
+ interface EntityWithOwnerEntityPrototype extends BaseEntityPrototype {
9899
+ /**
9900
+ * True if this entity-with-owner is military target
9901
+ *
9902
+ * *Can only be used if this is EntityWithOwnerPrototype*
9903
+ *
9904
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.is_military_target View documentation}
9905
+ */
9906
+ readonly is_military_target: boolean
9907
+ /**
9908
+ * True if this entity-with-owner's is_military_target can be changed run-time (on the entity, not on the prototype itself)
9909
+ *
9910
+ * *Can only be used if this is EntityWithOwnerPrototype*
9911
+ *
9912
+ * {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.allow_run_time_change_of_is_military_target View documentation}
9913
+ */
9914
+ readonly allow_run_time_change_of_is_military_target: boolean
9915
+ }
9916
+
9804
9917
  interface CharacterEntityPrototype extends BaseEntityPrototype {
9805
9918
  /**
9806
9919
  * Gets the current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.
@@ -15459,7 +15572,7 @@ interface LuaItemPrototype {
15459
15572
  * @param flag - The flag to test. See {@link ItemPrototypeFlags} for a list of flags.
15460
15573
  * @returns `true` if this prototype has the given flag set.
15461
15574
  */
15462
- has_flag(flag: string): boolean
15575
+ has_flag(flag: keyof ItemPrototypeFlags): boolean
15463
15576
  /**
15464
15577
  * Type of this ammo prototype or `nil` if this is not an ammo prototype.
15465
15578
  *
@@ -15998,7 +16111,7 @@ interface BaseItemPrototype {
15998
16111
  * @param flag - The flag to test. See {@link ItemPrototypeFlags} for a list of flags.
15999
16112
  * @returns `true` if this prototype has the given flag set.
16000
16113
  */
16001
- has_flag(flag: string): boolean
16114
+ has_flag(flag: keyof ItemPrototypeFlags): boolean
16002
16115
  /**
16003
16116
  * Type of this ammo prototype or `nil` if this is not an ammo prototype.
16004
16117
  *
@@ -23892,12 +24005,12 @@ interface LuaSurface {
23892
24005
  readonly condition: ForceCondition
23893
24006
  }): LuaEntity[]
23894
24007
  /**
23895
- * Find the enemy entity-with-force ({@link https://wiki.factorio.com/Military_units_and_structures military entity})
24008
+ * Find the enemy military target ({@link https://wiki.factorio.com/Military_units_and_structures military entity})
23896
24009
  * closest to the given position.
23897
24010
  *
23898
24011
  * {@link https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.find_nearest_enemy View documentation}
23899
24012
  *
23900
- * @returns The nearest enemy entity-with-force or `nil` if no enemy could be found within the given area.
24013
+ * @returns The nearest enemy military target or `nil` if no enemy could be found within the given area.
23901
24014
  */
23902
24015
  find_nearest_enemy(params: {
23903
24016
  /** Center of the search area. */
@@ -24654,7 +24767,7 @@ interface LuaSurface {
24654
24767
  */
24655
24768
  calculate_tile_properties(property_names: readonly string[], positions: readonly Position[]): Record<string, double[]>
24656
24769
  /**
24657
- * Returns all the entities with force on this chunk for the given force.
24770
+ * Returns all the military targets (entities with force) on this chunk for the given force.
24658
24771
  *
24659
24772
  * {@link https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.get_entities_with_force View documentation}
24660
24773
  *
@@ -3227,7 +3227,7 @@ interface TypeItemPrototypeFilter extends BaseItemPrototypeFilter {
3227
3227
  interface FlagItemPrototypeFilter extends BaseItemPrototypeFilter {
3228
3228
  readonly filter: "flag"
3229
3229
  /** One of the values in {@link ItemPrototypeFlags}. */
3230
- readonly flag: string
3230
+ readonly flag: keyof ItemPrototypeFlags
3231
3231
  }
3232
3232
 
3233
3233
  interface SubgroupItemPrototypeFilter extends BaseItemPrototypeFilter {
@@ -4079,7 +4079,7 @@ interface CollisionMaskEntityPrototypeFilter extends BaseEntityPrototypeFilter {
4079
4079
  interface FlagEntityPrototypeFilter extends BaseEntityPrototypeFilter {
4080
4080
  readonly filter: "flag"
4081
4081
  /** One of the values in {@link EntityPrototypeFlags}. */
4082
- readonly flag: string
4082
+ readonly flag: keyof EntityPrototypeFlags
4083
4083
  }
4084
4084
 
4085
4085
  interface BuildBaseEvolutionRequirementEntityPrototypeFilter extends BaseEntityPrototypeFilter {