isaacscript-common 31.5.0 → 31.7.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.
Files changed (140) hide show
  1. package/dist/index.rollup.d.ts +34 -6
  2. package/dist/isaacscript-common.lua +641 -655
  3. package/dist/src/classes/DefaultMap.d.ts +2 -0
  4. package/dist/src/classes/DefaultMap.d.ts.map +1 -1
  5. package/dist/src/classes/ModFeature.d.ts.map +1 -1
  6. package/dist/src/classes/ModFeature.lua +5 -9
  7. package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
  8. package/dist/src/classes/ModUpgraded.lua +8 -14
  9. package/dist/src/classes/callbacks/PostNewRoomEarly.lua +2 -2
  10. package/dist/src/classes/features/callbackLogic/CustomGridEntities.d.ts.map +1 -1
  11. package/dist/src/classes/features/callbackLogic/CustomGridEntities.lua +3 -3
  12. package/dist/src/classes/features/other/CharacterHealthConversion.lua +1 -1
  13. package/dist/src/classes/features/other/CustomItemPools.d.ts.map +1 -1
  14. package/dist/src/classes/features/other/CustomItemPools.lua +12 -6
  15. package/dist/src/classes/features/other/CustomStages.d.ts.map +1 -1
  16. package/dist/src/classes/features/other/CustomStages.lua +12 -14
  17. package/dist/src/classes/features/other/CustomTrapdoors.d.ts.map +1 -1
  18. package/dist/src/classes/features/other/CustomTrapdoors.lua +6 -8
  19. package/dist/src/classes/features/other/DeployJSONRoom.d.ts.map +1 -1
  20. package/dist/src/classes/features/other/DeployJSONRoom.lua +15 -15
  21. package/dist/src/classes/features/other/DisableInputs.d.ts.map +1 -1
  22. package/dist/src/classes/features/other/DisableInputs.lua +4 -6
  23. package/dist/src/classes/features/other/ModdedElementSets.d.ts.map +1 -1
  24. package/dist/src/classes/features/other/ModdedElementSets.lua +21 -12
  25. package/dist/src/classes/features/other/Pause.d.ts.map +1 -1
  26. package/dist/src/classes/features/other/Pause.lua +4 -6
  27. package/dist/src/classes/features/other/SaveDataManager.d.ts.map +1 -1
  28. package/dist/src/classes/features/other/SaveDataManager.lua +5 -9
  29. package/dist/src/classes/features/other/customStages/backdrop.lua +9 -10
  30. package/dist/src/classes/features/other/saveDataManager/restoreDefaults.lua +1 -1
  31. package/dist/src/functions/array.d.ts +3 -0
  32. package/dist/src/functions/array.d.ts.map +1 -1
  33. package/dist/src/functions/array.lua +9 -3
  34. package/dist/src/functions/bitSet128.d.ts.map +1 -1
  35. package/dist/src/functions/bitSet128.lua +4 -6
  36. package/dist/src/functions/bitwise.d.ts.map +1 -1
  37. package/dist/src/functions/bitwise.lua +7 -3
  38. package/dist/src/functions/color.d.ts.map +1 -1
  39. package/dist/src/functions/color.lua +5 -9
  40. package/dist/src/functions/deepCopy.lua +23 -31
  41. package/dist/src/functions/entities.d.ts.map +1 -1
  42. package/dist/src/functions/entities.lua +20 -18
  43. package/dist/src/functions/entitiesSpecific.d.ts.map +1 -1
  44. package/dist/src/functions/entitiesSpecific.lua +11 -27
  45. package/dist/src/functions/enums.d.ts +6 -4
  46. package/dist/src/functions/enums.d.ts.map +1 -1
  47. package/dist/src/functions/enums.lua +13 -9
  48. package/dist/src/functions/gridEntities.d.ts.map +1 -1
  49. package/dist/src/functions/gridEntities.lua +18 -11
  50. package/dist/src/functions/gridEntitiesSpecific.d.ts.map +1 -1
  51. package/dist/src/functions/gridEntitiesSpecific.lua +16 -28
  52. package/dist/src/functions/input.d.ts +5 -2
  53. package/dist/src/functions/input.d.ts.map +1 -1
  54. package/dist/src/functions/input.lua +25 -18
  55. package/dist/src/functions/jsonRoom.d.ts.map +1 -1
  56. package/dist/src/functions/jsonRoom.lua +35 -23
  57. package/dist/src/functions/kColor.d.ts.map +1 -1
  58. package/dist/src/functions/kColor.lua +6 -12
  59. package/dist/src/functions/map.d.ts.map +1 -1
  60. package/dist/src/functions/map.lua +3 -3
  61. package/dist/src/functions/minimap.d.ts.map +1 -1
  62. package/dist/src/functions/minimap.lua +17 -9
  63. package/dist/src/functions/playerDataStructures.d.ts +2 -0
  64. package/dist/src/functions/playerDataStructures.d.ts.map +1 -1
  65. package/dist/src/functions/playerDataStructures.lua +2 -0
  66. package/dist/src/functions/players.d.ts.map +1 -1
  67. package/dist/src/functions/players.lua +17 -22
  68. package/dist/src/functions/rng.d.ts.map +1 -1
  69. package/dist/src/functions/rng.lua +3 -3
  70. package/dist/src/functions/roomShapeWalls.d.ts.map +1 -1
  71. package/dist/src/functions/roomShapeWalls.lua +7 -3
  72. package/dist/src/functions/roomTransition.d.ts.map +1 -1
  73. package/dist/src/functions/roomTransition.lua +7 -3
  74. package/dist/src/functions/rooms.d.ts.map +1 -1
  75. package/dist/src/functions/rooms.lua +8 -5
  76. package/dist/src/functions/serialization.d.ts.map +1 -1
  77. package/dist/src/functions/serialization.lua +8 -18
  78. package/dist/src/functions/sprites.d.ts +2 -0
  79. package/dist/src/functions/sprites.d.ts.map +1 -1
  80. package/dist/src/functions/sprites.lua +2 -0
  81. package/dist/src/functions/table.d.ts.map +1 -1
  82. package/dist/src/functions/table.lua +6 -12
  83. package/dist/src/functions/tstlClass.d.ts.map +1 -1
  84. package/dist/src/functions/tstlClass.lua +3 -3
  85. package/dist/src/functions/utils.d.ts +9 -0
  86. package/dist/src/functions/utils.d.ts.map +1 -1
  87. package/dist/src/functions/utils.lua +14 -6
  88. package/dist/src/functions/vector.d.ts.map +1 -1
  89. package/dist/src/functions/vector.lua +4 -6
  90. package/dist/src/functions/weighted.d.ts.map +1 -1
  91. package/dist/src/functions/weighted.lua +7 -3
  92. package/dist/src/sets/bossSets.d.ts.map +1 -1
  93. package/dist/src/sets/bossSets.lua +3 -3
  94. package/package.json +2 -2
  95. package/src/classes/DefaultMap.ts +2 -0
  96. package/src/classes/ModFeature.ts +16 -12
  97. package/src/classes/ModUpgraded.ts +19 -16
  98. package/src/classes/callbacks/PostNewRoomEarly.ts +2 -2
  99. package/src/classes/features/callbackLogic/CustomGridEntities.ts +2 -3
  100. package/src/classes/features/other/CharacterHealthConversion.ts +1 -1
  101. package/src/classes/features/other/CustomItemPools.ts +9 -8
  102. package/src/classes/features/other/CustomStages.ts +9 -10
  103. package/src/classes/features/other/CustomTrapdoors.ts +9 -10
  104. package/src/classes/features/other/DeployJSONRoom.ts +21 -21
  105. package/src/classes/features/other/DisableInputs.ts +6 -5
  106. package/src/classes/features/other/ModdedElementSets.ts +18 -21
  107. package/src/classes/features/other/Pause.ts +9 -6
  108. package/src/classes/features/other/SaveDataManager.ts +14 -16
  109. package/src/classes/features/other/customStages/backdrop.ts +5 -6
  110. package/src/classes/features/other/saveDataManager/restoreDefaults.ts +1 -1
  111. package/src/functions/array.ts +8 -6
  112. package/src/functions/bitSet128.ts +9 -10
  113. package/src/functions/bitwise.ts +6 -3
  114. package/src/functions/color.ts +13 -15
  115. package/src/functions/deepCopy.ts +18 -24
  116. package/src/functions/deepCopyTests.ts +5 -6
  117. package/src/functions/entities.ts +22 -20
  118. package/src/functions/entitiesSpecific.ts +10 -27
  119. package/src/functions/enums.ts +29 -17
  120. package/src/functions/gridEntities.ts +14 -16
  121. package/src/functions/gridEntitiesSpecific.ts +15 -28
  122. package/src/functions/input.ts +15 -7
  123. package/src/functions/jsonRoom.ts +39 -27
  124. package/src/functions/kColor.ts +17 -20
  125. package/src/functions/map.ts +5 -5
  126. package/src/functions/minimap.ts +16 -15
  127. package/src/functions/playerDataStructures.ts +2 -0
  128. package/src/functions/players.ts +7 -10
  129. package/src/functions/rng.ts +5 -5
  130. package/src/functions/roomShapeWalls.ts +3 -4
  131. package/src/functions/roomTransition.ts +5 -5
  132. package/src/functions/rooms.ts +5 -6
  133. package/src/functions/serialization.ts +25 -30
  134. package/src/functions/sprites.ts +2 -0
  135. package/src/functions/table.ts +18 -20
  136. package/src/functions/tstlClass.ts +5 -5
  137. package/src/functions/utils.ts +27 -6
  138. package/src/functions/vector.ts +9 -10
  139. package/src/functions/weighted.ts +5 -5
  140. package/src/sets/bossSets.ts +5 -5
@@ -1194,6 +1194,16 @@ export declare function asPillEffect(num: number): PillEffect;
1194
1194
  */
1195
1195
  export declare function asPlayerType(num: number): PlayerType;
1196
1196
 
1197
+ /**
1198
+ * Helper function to throw an error (using the `error` Lua function) if the provided value is equal
1199
+ * to `undefined`.
1200
+ *
1201
+ * This is useful to have TypeScript narrow a `T | undefined` value to `T` in a concise way.
1202
+ */
1203
+ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends [T] ? [string] : [
1204
+ "The assertion is useless because the provided value does not contain undefined."
1205
+ ]): asserts value is Exclude<T, undefined>;
1206
+
1197
1207
  /**
1198
1208
  * Helper function to safely cast an enum to a `string`. (This is better than using the `as`
1199
1209
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
@@ -1530,6 +1540,8 @@ export declare function clearRoomDisplayFlags(roomGridIndex: int): void;
1530
1540
  * This function will still work identically if PNG file does not exist, but it will cause a
1531
1541
  * spurious error to appear in the "log.txt" file. If silencing these errors is desired, you can
1532
1542
  * create a transparent 1 pixel PNG file in your mod's resources folder at `EMPTY_PNG_PATH`.
1543
+ *
1544
+ * @allowEmptyVariadic
1533
1545
  */
1534
1546
  export declare function clearSprite(sprite: Sprite, ...layerIDs: int[]): void;
1535
1547
 
@@ -3347,6 +3359,8 @@ export declare class DefaultMap<Key, Value, Args extends unknown[] = []> extends
3347
3359
  /**
3348
3360
  * If the key exists, this will return the same thing as the normal `Map.get` method. Otherwise,
3349
3361
  * it will set a default value for the provided key, and then return the default value.
3362
+ *
3363
+ * @allowEmptyVariadic
3350
3364
  */
3351
3365
  getAndSetDefault(key: Key, ...args: Args): Value;
3352
3366
  /**
@@ -3410,6 +3424,8 @@ export declare function defaultMapGetNPC<V, Args extends unknown[]>(map: Default
3410
3424
  * player.MoveSpeed = defaultMapGetPlayer(v.run.playersSpeedBoost, player);
3411
3425
  * }
3412
3426
  * ```
3427
+ *
3428
+ * @allowEmptyVariadic
3413
3429
  */
3414
3430
  export declare function defaultMapGetPlayer<V, Args extends unknown[]>(map: DefaultMap<PlayerIndex, V, Args>, player: EntityPlayer, ...extraArgs: Args): V;
3415
3431
 
@@ -5263,10 +5279,10 @@ export declare function getEnumEntries<T>(transpiledEnum: T): Array<[key: string
5263
5279
  * For a more in depth explanation, see:
5264
5280
  * https://isaacscript.github.io/main/gotchas#iterating-over-enums
5265
5281
  */
5266
- export declare function getEnumKeys<T>(transpiledEnum: T): string[];
5282
+ export declare function getEnumKeys(transpiledEnum: Record<string | number, string | number>): string[];
5267
5283
 
5268
5284
  /** Helper function to get the amount of entries inside of an enum. */
5269
- export declare function getEnumLength<T>(transpiledEnum: T): int;
5285
+ export declare function getEnumLength(transpiledEnum: Record<string | number, string | number>): int;
5270
5286
 
5271
5287
  /**
5272
5288
  * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
@@ -5486,8 +5502,8 @@ export declare function getHeartsUIWidth(): int;
5486
5502
  /**
5487
5503
  * Helper function to get the enum value with the highest value.
5488
5504
  *
5489
- * Note that this is not necessarily the enum value that is declared last, since there is no way to
5490
- * infer that at run-time.
5505
+ * Note that this is not necessarily the enum value that is declared last in the code, since there
5506
+ * is no way to infer that at run-time.
5491
5507
  */
5492
5508
  export declare function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T];
5493
5509
 
@@ -5628,6 +5644,9 @@ export declare function getLasers(laserVariant?: LaserVariant | -1, subType?: nu
5628
5644
  * Helper function to return the last element of an array.
5629
5645
  *
5630
5646
  * If the array is empty, this will return undefined.
5647
+ *
5648
+ * (Note that TSTL does not support `Array.at(-1)`, which would make this helper function largely
5649
+ * unnecessary.)
5631
5650
  */
5632
5651
  export declare function getLastElement<T>(array: T[]): T | undefined;
5633
5652
 
@@ -5673,7 +5692,7 @@ export declare function getMapPartialMatch<T>(searchText: string, map: ReadonlyM
5673
5692
  */
5674
5693
  export declare function getMatchingGridEntities(gridEntityType: GridEntityType, variant: int): GridEntity[];
5675
5694
 
5676
- export declare function getMoveActions(): ReadonlySet<ButtonAction>;
5695
+ export declare function getMoveActions(controllerIndex: ControllerIndex): ButtonAction[];
5677
5696
 
5678
5697
  /**
5679
5698
  * Helper function to get the corresponding music value for a stage and stage type combination.
@@ -6918,7 +6937,7 @@ export declare function getScreenTopRightPos(): Readonly<Vector>;
6918
6937
  */
6919
6938
  export declare function getSetCombinations<T>(set: Set<T> | ReadonlySet<T>, includeEmptyArray: boolean): ReadonlyArray<ReadonlySet<T>>;
6920
6939
 
6921
- export declare function getShootActions(): ReadonlySet<ButtonAction>;
6940
+ export declare function getShootActions(controllerIndex: ControllerIndex): ButtonAction[];
6922
6941
 
6923
6942
  /**
6924
6943
  * Helper function to get the corresponding "Siren Helper" entity for a stolen familiar.
@@ -8281,6 +8300,9 @@ export declare function isEntity(variable: unknown): variable is Entity;
8281
8300
  */
8282
8301
  export declare function isEntityMoving(entity: Entity, threshold?: number): boolean;
8283
8302
 
8303
+ /** Helper function to validate that a particular value exists inside of an enum. */
8304
+ export declare function isEnumValue(value: number | string, transpiledEnum: Record<string | number, string | number>): boolean;
8305
+
8284
8306
  export declare function isEven(num: int): boolean;
8285
8307
 
8286
8308
  /** Helper function to detect if a variable is of type `EntityFamiliar`. */
@@ -13053,6 +13075,8 @@ export declare class ModFeature {
13053
13075
  uninit(): void;
13054
13076
  }
13055
13077
 
13078
+ export declare const MODIFIER_KEYS: readonly [Keyboard.LEFT_SHIFT, Keyboard.LEFT_CONTROL, Keyboard.LEFT_ALT, Keyboard.LEFT_SUPER, Keyboard.RIGHT_SHIFT, Keyboard.RIGHT_CONTROL, Keyboard.RIGHT_ALT, Keyboard.RIGHT_SUPER];
13079
+
13056
13080
  /**
13057
13081
  * `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
13058
13082
  * hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
@@ -13146,6 +13170,8 @@ export declare class ModUpgraded implements Mod {
13146
13170
  */
13147
13171
  declare type ModUpgradedWithFeatures<T extends readonly ISCFeature[] = []> = ModUpgraded & ISCFeaturesToKeys<T>;
13148
13172
 
13173
+ export declare const MOVEMENT_ACTIONS: readonly [ButtonAction.LEFT, ButtonAction.RIGHT, ButtonAction.UP, ButtonAction.DOWN];
13174
+
13149
13175
  export declare const MOVEMENT_ACTIONS_SET: ReadonlySet<ButtonAction>;
13150
13176
 
13151
13177
  /**
@@ -16004,6 +16030,8 @@ export declare function setUnseeded(): void;
16004
16030
  */
16005
16031
  export declare const sfxManager: SFXManager;
16006
16032
 
16033
+ export declare const SHOOTING_ACTIONS: readonly [ButtonAction.SHOOT_LEFT, ButtonAction.SHOOT_RIGHT, ButtonAction.SHOOT_UP, ButtonAction.SHOOT_DOWN];
16034
+
16007
16035
  export declare const SHOOTING_ACTIONS_SET: ReadonlySet<ButtonAction>;
16008
16036
 
16009
16037
  declare function shouldFireCollectibleType(fireArgs: [player: EntityPlayer, collectibleType: CollectibleType], optionalArgs: [collectibleType?: CollectibleType]): boolean;