isaacscript-common 21.9.0 → 23.0.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 (45) hide show
  1. package/dist/index.rollup.d.ts +61 -45
  2. package/dist/isaacscript-common.lua +202 -177
  3. package/dist/lualib_bundle.lua +59 -100
  4. package/dist/src/functions/characters.d.ts +8 -1
  5. package/dist/src/functions/characters.d.ts.map +1 -1
  6. package/dist/src/functions/characters.lua +9 -0
  7. package/dist/src/functions/color.d.ts +1 -1
  8. package/dist/src/functions/color.d.ts.map +1 -1
  9. package/dist/src/functions/hex.d.ts +2 -2
  10. package/dist/src/functions/hex.d.ts.map +1 -1
  11. package/dist/src/functions/isaacAPIClass.d.ts +1 -1
  12. package/dist/src/functions/isaacAPIClass.d.ts.map +1 -1
  13. package/dist/src/functions/isaacAPIClass.lua +1 -1
  14. package/dist/src/functions/kColor.d.ts +1 -1
  15. package/dist/src/functions/kColor.d.ts.map +1 -1
  16. package/dist/src/functions/log.d.ts +1 -1
  17. package/dist/src/functions/log.d.ts.map +1 -1
  18. package/dist/src/functions/log.lua +5 -0
  19. package/dist/src/functions/players.d.ts +28 -21
  20. package/dist/src/functions/players.d.ts.map +1 -1
  21. package/dist/src/functions/players.lua +60 -51
  22. package/dist/src/functions/positionVelocity.d.ts +1 -1
  23. package/dist/src/functions/positionVelocity.d.ts.map +1 -1
  24. package/dist/src/functions/roomGrid.d.ts +5 -5
  25. package/dist/src/functions/roomGrid.d.ts.map +1 -1
  26. package/dist/src/functions/ui.d.ts +8 -8
  27. package/dist/src/functions/ui.d.ts.map +1 -1
  28. package/dist/src/functions/vector.d.ts +1 -1
  29. package/dist/src/functions/vector.d.ts.map +1 -1
  30. package/dist/src/objects/characterStartingCollectibles.d.ts +46 -0
  31. package/dist/src/objects/characterStartingCollectibles.d.ts.map +1 -0
  32. package/dist/src/objects/characterStartingCollectibles.lua +49 -0
  33. package/package.json +1 -1
  34. package/src/functions/characters.ts +14 -1
  35. package/src/functions/color.ts +1 -1
  36. package/src/functions/hex.ts +2 -2
  37. package/src/functions/isaacAPIClass.ts +1 -1
  38. package/src/functions/kColor.ts +1 -1
  39. package/src/functions/log.ts +7 -1
  40. package/src/functions/players.ts +72 -57
  41. package/src/functions/positionVelocity.ts +1 -1
  42. package/src/functions/roomGrid.ts +14 -5
  43. package/src/functions/ui.ts +8 -8
  44. package/src/functions/vector.ts +1 -1
  45. package/src/objects/characterStartingCollectibles.ts +144 -0
@@ -619,6 +619,14 @@ declare interface AddCallbackParametersCustom {
619
619
  */
620
620
  export declare function addCharge(player: EntityPlayer, activeSlot?: ActiveSlot, numCharges?: number, playSoundEffect?: boolean): int;
621
621
 
622
+ /**
623
+ * Helper function to add one or more collectibles to a player.
624
+ *
625
+ * This function is variadic, meaning that you can supply as many collectible types as you want to
626
+ * add.
627
+ */
628
+ export declare function addCollectible(player: EntityPlayer, ...collectibleTypes: CollectibleType[]): void;
629
+
622
630
  export declare function addCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType): void;
623
631
 
624
632
  /**
@@ -3876,7 +3884,7 @@ export declare function find<T>(array: T[], func: (value: T, index: number, arra
3876
3884
  * @param minimumDistance Optional. If specified, will ensure that the randomly generated position
3877
3885
  * is equal to or greater than the distance provided.
3878
3886
  */
3879
- export declare function findFreePosition(startingPosition: Vector, avoidActiveEntities?: boolean, minimumDistance?: float): Vector;
3887
+ export declare function findFreePosition(startingPosition: Vector, avoidActiveEntities?: boolean, minimumDistance?: float): Readonly<Vector>;
3880
3888
 
3881
3889
  declare type FireArgs<T extends ModCallbackCustom> = Parameters<AddCallbackParametersCustom[T][0]>;
3882
3890
 
@@ -4397,6 +4405,14 @@ export declare function getCharacterName(character: PlayerType): string;
4397
4405
  /** Helper function to get an array containing the characters of all of the current players. */
4398
4406
  export declare function getCharacters(): PlayerType[];
4399
4407
 
4408
+ /**
4409
+ * Helper function to get the collectibles that are granted to a particular character at the
4410
+ * beginning of a run.
4411
+ *
4412
+ * Note that this will return an empty array for Eden and Tainted Eden.
4413
+ */
4414
+ export declare function getCharacterStartingItems(character: PlayerType): readonly CollectibleType[];
4415
+
4400
4416
  /**
4401
4417
  * Helper function to get the amount of charges away from the maximum charge that a particular
4402
4418
  * player is.
@@ -5111,7 +5127,7 @@ export declare function getHorsePillColors(): PillColor[];
5111
5127
  * - If the user does not have a HUD offset configured, this function will return `Vector(0, 0)`.
5112
5128
  * - If the user has a HUD offset of 1.0 configured, this function will return `Vector(20, 12)`.
5113
5129
  */
5114
- export declare function getHUDOffsetVector(): Vector;
5130
+ export declare function getHUDOffsetVector(): Readonly<Vector>;
5115
5131
 
5116
5132
  /**
5117
5133
  * Helper function to get the name of a class from the Isaac API. This is contained within the
@@ -5871,7 +5887,7 @@ export declare function getRandomArrayIndex<T>(array: T[] | readonly T[], seedOr
5871
5887
  * `RNG.Next` method will be called. Default is `getRandomSeed()`.
5872
5888
  * @param alpha Optional. The alpha value to use. Default is 1.
5873
5889
  */
5874
- export declare function getRandomColor(seedOrRNG?: Seed | RNG, alpha?: number): Color;
5890
+ export declare function getRandomColor(seedOrRNG?: Seed | RNG, alpha?: number): Readonly<Color>;
5875
5891
 
5876
5892
  /**
5877
5893
  * Helper function to get a random value from the provided enum.
@@ -5985,7 +6001,7 @@ export declare function getRandomJSONRoom(jsonRooms: JSONRoom[], seedOrRNG?: See
5985
6001
  * `RNG.Next` method will be called. Default is `getRandomSeed()`.
5986
6002
  * @param alpha Optional. The alpha value to use. Default is 1.
5987
6003
  */
5988
- export declare function getRandomKColor(seedOrRNG?: Seed | RNG, alpha?: number): KColor;
6004
+ export declare function getRandomKColor(seedOrRNG?: Seed | RNG, alpha?: number): Readonly<KColor>;
5989
6005
 
5990
6006
  /**
5991
6007
  * Helper function to get a random `Seed` value to be used in spawning entities and so on. Use this
@@ -6014,7 +6030,7 @@ export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, see
6014
6030
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
6015
6031
  * `RNG.Next` method will be called. Default is `getRandomSeed()`.
6016
6032
  */
6017
- export declare function getRandomVector(seedOrRNG?: Seed | RNG): Vector;
6033
+ export declare function getRandomVector(seedOrRNG?: Seed | RNG): Readonly<Vector>;
6018
6034
 
6019
6035
  /**
6020
6036
  * Helper function to get a read-only copy of the room descriptor for every room on the level. This
@@ -6443,19 +6459,19 @@ export declare function getRoomVisitedCount(roomGridIndex?: int): int;
6443
6459
  */
6444
6460
  export declare function getSacks(sackSubType?: SackSubType): EntityPickupSack[];
6445
6461
 
6446
- export declare function getScreenBottomCenterPos(): Vector;
6462
+ export declare function getScreenBottomCenterPos(): Readonly<Vector>;
6447
6463
 
6448
- export declare function getScreenBottomLeftPos(): Vector;
6464
+ export declare function getScreenBottomLeftPos(): Readonly<Vector>;
6449
6465
 
6450
- export declare function getScreenBottomRightPos(): Vector;
6466
+ export declare function getScreenBottomRightPos(): Readonly<Vector>;
6451
6467
 
6452
- export declare function getScreenCenterPos(): Vector;
6468
+ export declare function getScreenCenterPos(): Readonly<Vector>;
6453
6469
 
6454
- export declare function getScreenTopCenterPos(): Vector;
6470
+ export declare function getScreenTopCenterPos(): Readonly<Vector>;
6455
6471
 
6456
- export declare function getScreenTopLeftPos(): Vector;
6472
+ export declare function getScreenTopLeftPos(): Readonly<Vector>;
6457
6473
 
6458
- export declare function getScreenTopRightPos(): Vector;
6474
+ export declare function getScreenTopRightPos(): Readonly<Vector>;
6459
6475
 
6460
6476
  /**
6461
6477
  * Helper function to get all possible combinations of the given set. This includes the combination
@@ -6817,7 +6833,7 @@ export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
6817
6833
  *
6818
6834
  * For example, the coordinates of (0, 0) are equal to `Vector(80, 160)`.
6819
6835
  */
6820
- export declare function gridCoordinatesToWorldPosition(x: int, y: int): Vector;
6836
+ export declare function gridCoordinatesToWorldPosition(x: int, y: int): Readonly<Vector>;
6821
6837
 
6822
6838
  declare class GridEntityCollisionDetection extends Feature {
6823
6839
  v: {
@@ -6909,14 +6925,14 @@ declare class GridEntityUpdateDetection extends Feature {
6909
6925
  * For example, in a 1x1 room, grid index 0 is equal to "Vector(-1, -1) and grid index 16 is equal
6910
6926
  * to "Vector(0, 0)".
6911
6927
  */
6912
- export declare function gridIndexToGridPosition(gridIndex: int, roomShape: RoomShape): Vector;
6928
+ export declare function gridIndexToGridPosition(gridIndex: int, roomShape: RoomShape): Readonly<Vector>;
6913
6929
 
6914
6930
  /**
6915
6931
  * Helper function to convert a grid position `Vector` to a world position `Vector`.
6916
6932
  *
6917
6933
  * For example, the coordinates of (0, 0) are equal to `Vector(80, 160)`.
6918
6934
  */
6919
- export declare function gridPositionToWorldPosition(gridPosition: Vector): Vector;
6935
+ export declare function gridPositionToWorldPosition(gridPosition: Vector): Readonly<Vector>;
6920
6936
 
6921
6937
  /**
6922
6938
  * Helper function to see if a particular entity has armor. In this context, armor refers to the
@@ -6926,6 +6942,14 @@ export declare function gridPositionToWorldPosition(gridPosition: Vector): Vecto
6926
6942
  */
6927
6943
  export declare function hasArmor(entity: Entity): boolean;
6928
6944
 
6945
+ /**
6946
+ * Helper function to check to see if a player has one or more collectibles.
6947
+ *
6948
+ * This function is variadic, meaning that you can supply as many collectible types as you want to
6949
+ * check for. Returns true if the player has any of the supplied collectible types.
6950
+ */
6951
+ export declare function hasCollectible(player: EntityPlayer, ...collectibleTypes: CollectibleType[]): boolean;
6952
+
6929
6953
  export declare function hasCurse(curse: LevelCurse): boolean;
6930
6954
 
6931
6955
  /**
@@ -6950,6 +6974,14 @@ export declare function hasFlag<T extends BitFlag | BitFlag128>(flags: T | BitFl
6950
6974
 
6951
6975
  export declare function hasFlyingTransformation(player: EntityPlayer): boolean;
6952
6976
 
6977
+ /**
6978
+ * Helper function to check to see if a player has one or more transformations.
6979
+ *
6980
+ * This function is variadic, meaning that you can supply as many transformations as you want to
6981
+ * check for. Returns true if the player has any of the supplied transformations.
6982
+ */
6983
+ export declare function hasForm(player: EntityPlayer, ...playerForms: PlayerForm[]): boolean;
6984
+
6953
6985
  /** Helper type to check if an object or class has one or more functions/methods. */
6954
6986
  export declare type HasFunction<T> = Record<string, unknown> extends {
6955
6987
  [K in keyof T as T[K] extends Function ? K : never]-?: 1;
@@ -7015,7 +7047,7 @@ export declare enum HealthType {
7015
7047
  * @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
7016
7048
  * @param alpha Optional. Range is from 0 to 1. Default is 1. (The same as the `Color` constructor.)
7017
7049
  */
7018
- export declare function hexToColor(hexString: string, alpha?: number): Color;
7050
+ export declare function hexToColor(hexString: string, alpha?: number): Readonly<Color>;
7019
7051
 
7020
7052
  /**
7021
7053
  * Converts a hex string like "#33aa33" to a Color object.
@@ -7023,7 +7055,7 @@ export declare function hexToColor(hexString: string, alpha?: number): Color;
7023
7055
  * @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
7024
7056
  * @param alpha Range is from 0 to 1. Default is 1.
7025
7057
  */
7026
- export declare function hexToKColor(hexString: string, alpha?: number): KColor;
7058
+ export declare function hexToKColor(hexString: string, alpha?: number): Readonly<KColor>;
7027
7059
 
7028
7060
  /**
7029
7061
  * Helper type to make the given array/map/set/object recursively read-only.
@@ -7723,7 +7755,7 @@ export declare function isEntityMoving(entity: Entity, threshold?: number): bool
7723
7755
 
7724
7756
  export declare function isEven(num: int): boolean;
7725
7757
 
7726
- /** Helper function to detect if a variable is of type `EntityEffect`. */
7758
+ /** Helper function to detect if a variable is of type `EntityFamiliar`. */
7727
7759
  export declare function isFamiliar(variable: unknown): variable is EntityFamiliar;
7728
7760
 
7729
7761
  /**
@@ -8617,7 +8649,7 @@ export declare function lockDoor(door: GridEntityDoor): void;
8617
8649
  * @param includeParentFunction Optional. Whether to prefix the message with the function name and
8618
8650
  * line number, as shown in the above example. Default is true.
8619
8651
  */
8620
- export declare function log(this: void, msg: string, includeParentFunction?: boolean): void;
8652
+ export declare function log(this: void, msg: string | number, includeParentFunction?: boolean): void;
8621
8653
 
8622
8654
  /** Helper function for printing out every entity (or filtered entity) in the current room. */
8623
8655
  export declare function logAllEntities(this: void, includeBackgroundEffects: boolean, entityTypeFilter?: EntityType): void;
@@ -12255,14 +12287,6 @@ export declare const PILL_NAME_TO_EFFECT_MAP: ReadonlyMap<string, PillEffect>;
12255
12287
  */
12256
12288
  export declare function playChargeSoundEffect(player: EntityPlayer, activeSlot?: ActiveSlot): void;
12257
12289
 
12258
- /**
12259
- * Helper function to add one or more collectibles to a player.
12260
- *
12261
- * This function is variadic, meaning that you can supply as many collectible types as you want to
12262
- * add.
12263
- */
12264
- export declare function playerAddCollectible(player: EntityPlayer, ...collectibleTypes: CollectibleType[]): void;
12265
-
12266
12290
  declare class PlayerCollectibleDetection extends Feature {
12267
12291
  v: {
12268
12292
  run: {
@@ -12314,22 +12338,6 @@ export declare function playerConvertBlackHeartsToSoulHearts(player: EntityPlaye
12314
12338
 
12315
12339
  export declare function playerConvertSoulHeartsToBlackHearts(player: EntityPlayer): void;
12316
12340
 
12317
- /**
12318
- * Helper function to check to see if a player has one or more collectibles.
12319
- *
12320
- * This function is variadic, meaning that you can supply as many collectible types as you want to
12321
- * check for. Returns true if the player has any of the supplied collectible types.
12322
- */
12323
- export declare function playerHasCollectible(player: EntityPlayer, ...collectibleTypes: CollectibleType[]): boolean;
12324
-
12325
- /**
12326
- * Helper function to check to see if a player has one or more transformations.
12327
- *
12328
- * This function is variadic, meaning that you can supply as many transformations as you want to
12329
- * check for. Returns true if the player has any of the supplied transformations.
12330
- */
12331
- export declare function playerHasForm(player: EntityPlayer, ...playerForms: PlayerForm[]): boolean;
12332
-
12333
12341
  /**
12334
12342
  * Helper function to see if the player is out of health.
12335
12343
  *
@@ -13186,6 +13194,14 @@ export declare function removeAllTrinkets(trinketType?: TrinketType, cap?: int):
13186
13194
  */
13187
13195
  export declare function removeCharactersBefore(string: string, substring: string): string;
13188
13196
 
13197
+ /**
13198
+ * Helper function to remove one or more collectibles to a player.
13199
+ *
13200
+ * This function is variadic, meaning that you can supply as many collectible types as you want to
13201
+ * remove.
13202
+ */
13203
+ export declare function removeCollectible(player: EntityPlayer, ...collectibleTypes: CollectibleType[]): void;
13204
+
13189
13205
  /**
13190
13206
  * Helper function to remove a collectible costume from a player. Use this helper function to avoid
13191
13207
  * having to request the collectible from the item config.
@@ -15651,7 +15667,7 @@ export declare function willReviveFromSpiritShackles(player: EntityPlayer): bool
15651
15667
  *
15652
15668
  * In this context, the grid position of the top-left wall is "Vector(-1, -1)".
15653
15669
  */
15654
- export declare function worldPositionToGridPosition(worldPos: Vector): Vector;
15670
+ export declare function worldPositionToGridPosition(worldPos: Vector): Readonly<Vector>;
15655
15671
 
15656
15672
  /**
15657
15673
  * Helper function to convert a world position `Vector` to a grid position `Vector`.
@@ -15660,7 +15676,7 @@ export declare function worldPositionToGridPosition(worldPos: Vector): Vector;
15660
15676
  *
15661
15677
  * This is similar to the `worldPositionToGridPosition` function, but the values are not rounded.
15662
15678
  */
15663
- export declare function worldPositionToGridPositionFast(worldPos: Vector): Vector;
15679
+ export declare function worldPositionToGridPositionFast(worldPos: Vector): Readonly<Vector>;
15664
15680
 
15665
15681
  /**
15666
15682
  * Helper function to see if a certain damage amount would deal "permanent" damage to Tainted