isaacscript-common 13.0.0 → 13.1.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.
Files changed (83) hide show
  1. package/dist/index.d.ts +96 -26
  2. package/dist/isaacscript-common.lua +613 -168
  3. package/dist/src/features/customStage/backdrop.lua +4 -4
  4. package/dist/src/features/customStage/versusScreen.lua +2 -2
  5. package/dist/src/features/deployJSONRoom.d.ts +0 -11
  6. package/dist/src/features/deployJSONRoom.d.ts.map +1 -1
  7. package/dist/src/features/deployJSONRoom.lua +10 -74
  8. package/dist/src/features/extraConsoleCommands/listCommands.lua +2 -2
  9. package/dist/src/features/firstLast.lua +8 -8
  10. package/dist/src/features/setHotkey.d.ts +27 -8
  11. package/dist/src/features/setHotkey.d.ts.map +1 -1
  12. package/dist/src/features/setHotkey.lua +41 -30
  13. package/dist/src/functions/array.lua +2 -2
  14. package/dist/src/functions/cards.lua +2 -2
  15. package/dist/src/functions/collectibles.lua +2 -2
  16. package/dist/src/functions/dimensions.lua +2 -2
  17. package/dist/src/functions/emptyRoom.d.ts +8 -0
  18. package/dist/src/functions/emptyRoom.d.ts.map +1 -0
  19. package/dist/src/functions/emptyRoom.lua +79 -0
  20. package/dist/src/functions/enums.d.ts.map +1 -1
  21. package/dist/src/functions/enums.lua +3 -3
  22. package/dist/src/functions/gridEntities.lua +2 -2
  23. package/dist/src/functions/gridIndex.d.ts +10 -0
  24. package/dist/src/functions/gridIndex.d.ts.map +1 -0
  25. package/dist/src/functions/gridIndex.lua +32 -0
  26. package/dist/src/functions/log.d.ts.map +1 -1
  27. package/dist/src/functions/log.lua +9 -8
  28. package/dist/src/functions/logEntities.d.ts.map +1 -1
  29. package/dist/src/functions/logEntities.lua +17 -9
  30. package/dist/src/functions/pills.lua +4 -4
  31. package/dist/src/functions/roomShape.d.ts +6 -1
  32. package/dist/src/functions/roomShape.d.ts.map +1 -1
  33. package/dist/src/functions/roomShape.lua +3 -0
  34. package/dist/src/functions/roomShapeWalls.d.ts +11 -0
  35. package/dist/src/functions/roomShapeWalls.d.ts.map +1 -0
  36. package/dist/src/functions/roomShapeWalls.lua +273 -0
  37. package/dist/src/functions/rooms.d.ts +7 -0
  38. package/dist/src/functions/rooms.d.ts.map +1 -1
  39. package/dist/src/functions/rooms.lua +16 -5
  40. package/dist/src/functions/set.d.ts +7 -0
  41. package/dist/src/functions/set.d.ts.map +1 -1
  42. package/dist/src/functions/set.lua +10 -0
  43. package/dist/src/functions/sprites.lua +2 -2
  44. package/dist/src/functions/trinkets.lua +2 -2
  45. package/dist/src/functions/utils.d.ts +18 -12
  46. package/dist/src/functions/utils.d.ts.map +1 -1
  47. package/dist/src/functions/utils.lua +26 -14
  48. package/dist/src/index.d.ts +3 -0
  49. package/dist/src/index.d.ts.map +1 -1
  50. package/dist/src/index.lua +24 -0
  51. package/dist/src/interfaces/Corner.d.ts +8 -0
  52. package/dist/src/interfaces/Corner.d.ts.map +1 -1
  53. package/dist/src/objects/roomShapeCorners.d.ts +6 -1
  54. package/dist/src/objects/roomShapeCorners.d.ts.map +1 -1
  55. package/dist/src/objects/roomShapeCorners.lua +71 -14
  56. package/package.json +2 -2
  57. package/src/features/customStage/backdrop.ts +3 -3
  58. package/src/features/customStage/versusScreen.ts +2 -2
  59. package/src/features/deployJSONRoom.ts +8 -98
  60. package/src/features/extraConsoleCommands/listCommands.ts +2 -2
  61. package/src/features/firstLast.ts +8 -8
  62. package/src/features/setHotkey.ts +60 -40
  63. package/src/functions/array.ts +2 -2
  64. package/src/functions/cards.ts +2 -2
  65. package/src/functions/collectibles.ts +2 -2
  66. package/src/functions/dimensions.ts +2 -2
  67. package/src/functions/emptyRoom.ts +92 -0
  68. package/src/functions/enums.ts +4 -3
  69. package/src/functions/gridEntities.ts +2 -2
  70. package/src/functions/gridIndex.ts +40 -0
  71. package/src/functions/log.ts +9 -10
  72. package/src/functions/logEntities.ts +25 -9
  73. package/src/functions/pills.ts +4 -4
  74. package/src/functions/roomShape.ts +6 -1
  75. package/src/functions/roomShapeWalls.ts +342 -0
  76. package/src/functions/rooms.ts +22 -3
  77. package/src/functions/set.ts +12 -0
  78. package/src/functions/sprites.ts +2 -2
  79. package/src/functions/trinkets.ts +2 -2
  80. package/src/functions/utils.ts +20 -14
  81. package/src/index.ts +3 -0
  82. package/src/interfaces/Corner.ts +9 -0
  83. package/src/objects/roomShapeCorners.ts +74 -16
package/dist/index.d.ts CHANGED
@@ -967,6 +967,13 @@ export declare function copyVector(vector: Vector): Vector;
967
967
  */
968
968
  export declare interface Corner {
969
969
  readonly type: CornerType;
970
+ /** The grid index of the corresponding wall tile. */
971
+ readonly gridIndex: int;
972
+ /**
973
+ * The position is not the same as the center of the corresponding grid index. Rather, it is the
974
+ * exact position of the corner, which will be offset from the grid index position by half of a
975
+ * grid tile.
976
+ */
970
977
  readonly position: Readonly<Vector>;
971
978
  }
972
979
 
@@ -2051,12 +2058,8 @@ export declare function emptyArray<T>(array: T[]): void;
2051
2058
  * this will not remove players (1), tears (2), familiars (3), lasers (7), knives (8), projectiles
2052
2059
  * (9), blacklisted NPCs such as Dark Esau, charmed NPCs, friendly NPCs, persistent NPCs, most
2053
2060
  * effects (1000), doors, and walls.
2054
- *
2055
- * @param fillWithDecorations Optional. Set to true to fill every grid tile with an invisible
2056
- * decoration, which prevents vanilla entities in the room from
2057
- * respawning the next time that the player enters. Default is false.
2058
2061
  */
2059
- export declare function emptyRoom(fillWithDecorations: boolean): void;
2062
+ export declare function emptyRoom(): void;
2060
2063
 
2061
2064
  /**
2062
2065
  * Helper function to enable all inputs. Use this function to set things back to normal after having
@@ -2126,15 +2129,18 @@ export declare function enableExtraConsoleCommands(mod: ModUpgraded): void;
2126
2129
  export declare function enableFastReset(): void;
2127
2130
 
2128
2131
  /**
2129
- * Helper function to return an array with the elements from start to end. It is inclusive at the
2130
- * start and exclusive at the end. (The "e" stands for exclusive.)
2132
+ * Helper function to return an array of integers with the specified range, inclusive on the lower
2133
+ * end and exclusive on the high end. (The "e" stands for exclusive.)
2131
2134
  *
2132
- * If only one argument is specified, then it will assume that the start is 0.
2135
+ * - For example, `eRange(1, 3)` will return `[1, 2]`.
2136
+ * - For example, `eRange(2)` will return `[0, 1]`.
2133
2137
  *
2134
- * - For example, `erange(1, 3)` will return `[1, 2]`.
2135
- * - For example, `erange(2)` will return `[0, 1]`.
2138
+ * @param start The number to start at.
2139
+ * @param end Optional. The number to end at. If not specified, then the start will be 0 and the
2140
+ * first argument will be the end.
2141
+ * @param increment Optional. The increment to use. Default is 1.
2136
2142
  */
2137
- export declare function erange(start: int, end?: int): int[];
2143
+ export declare function eRange(start: int, end?: int, increment?: number): int[];
2138
2144
 
2139
2145
  declare type ErrorCustomClassNotSerializable = "Error: Custom classes with one or more methods are not serializable when inside of an array, map, or set. For more information, see: https://isaacscript.github.io/main/gotchas#custom-classes-are-not-serializable";
2140
2146
 
@@ -3400,6 +3406,15 @@ export declare function getGridEntityIDFromConstituents(gridEntityType: GridEnti
3400
3406
  */
3401
3407
  export declare function getGridIndexDelta(roomShape: RoomShape, doorSlot: DoorSlot): int | undefined;
3402
3408
 
3409
+ /**
3410
+ * Helper function to get all of the grid indexes between two grid indexes on either a horizontal or
3411
+ * vertical line, inclusive on both ends.
3412
+ *
3413
+ * This function will throw a run-time error if the two provided grid indexes are not on the same
3414
+ * horizontal or vertical line.
3415
+ */
3416
+ export declare function getGridIndexesBetween(gridIndex1: int, gridIndex2: int, roomShape: RoomShape): int[];
3417
+
3403
3418
  /**
3404
3419
  * Returns how many hearts are in the heart UI row. If the player has more than 6 hearts, this
3405
3420
  * function will return 6.
@@ -4883,7 +4898,12 @@ export declare function getRoomShapeBounds(roomShape: RoomShape): readonly [widt
4883
4898
  */
4884
4899
  export declare function getRoomShapeCharges(roomShape: RoomShape): int;
4885
4900
 
4886
- /** Helper function to get the corners that exist in the given room shape. */
4901
+ /**
4902
+ * Helper function to get the corners that exist in the given room shape.
4903
+ *
4904
+ * Note that these corner locations are not accurate for the Mother Boss Room and the Home closet
4905
+ * rooms. (Those rooms have custom shapes.)
4906
+ */
4887
4907
  export declare function getRoomShapeCorners(roomShape: RoomShape): readonly Corner[];
4888
4908
 
4889
4909
  /**
@@ -5640,6 +5660,14 @@ export declare function inDoubleTrouble(): boolean;
5640
5660
 
5641
5661
  export declare function inGenesisRoom(): boolean;
5642
5662
 
5663
+ /**
5664
+ * Helper function to check if the current room is either the left Home closet (behind the red door)
5665
+ * or the right Home closet (with one random pickup).
5666
+ *
5667
+ * Home closets have a unique shape that is different from any other room in the game.
5668
+ */
5669
+ export declare function inHomeCloset(): boolean;
5670
+
5643
5671
  /**
5644
5672
  * Initializes an array with all of the elements containing the specified default value.
5645
5673
  *
@@ -5740,15 +5768,18 @@ export declare function inSecretShop(): boolean;
5740
5768
  export declare function inStartingRoom(): boolean;
5741
5769
 
5742
5770
  /**
5743
- * Helper function to return an array with the elements from start to end, inclusive. (The "i"
5744
- * stands for inclusive.)
5771
+ * Helper function to return an array of integers with the specified range, inclusive on both ends.
5772
+ * (The "i" stands for inclusive.)
5745
5773
  *
5746
- * If only one argument is specified, then it will assume that the start is 0.
5774
+ * - For example, `iRange(1, 3)` will return `[1, 2, 3]`.
5775
+ * - For example, `iRange(2)` will return `[0, 1, 2]`.
5747
5776
  *
5748
- * - For example, `irange(1, 3)` will return `[1, 2, 3]`.
5749
- * - For example, `irange(2)` will return `[0, 1, 2]`.
5777
+ * @param start The number to start at.
5778
+ * @param end Optional. The number to end at. If not specified, then the start will be 0 and the
5779
+ * first argument will be the end.
5780
+ * @param increment Optional. The increment to use. Default is 1.
5750
5781
  */
5751
- export declare function irange(start: int, end?: int): int[];
5782
+ export declare function iRange(start: int, end?: int, increment?: number): int[];
5752
5783
 
5753
5784
  /**
5754
5785
  * Helper function to check if an instantiated Isaac API class is equal to another one of the same
@@ -6597,6 +6628,16 @@ export declare function isVanillaTrinketType(trinketType: TrinketType): boolean;
6597
6628
  */
6598
6629
  export declare function isVanillaTSTLClass(object: unknown): boolean;
6599
6630
 
6631
+ /**
6632
+ * Helper function to determine if a given grid index should have a wall generated by the vanilla
6633
+ * game. This is useful as a mechanism to distinguish between real walls and custom walls spawned by
6634
+ * mods.
6635
+ *
6636
+ * This function properly handles the special cases of the Mother boss room and the Home closet
6637
+ * rooms, which are both non-standard room shapes.
6638
+ */
6639
+ export declare function isVanillaWallGridIndex(gridIndex: int): boolean;
6640
+
6600
6641
  /** Helper function to check if something is an instantiated `Vector` object. */
6601
6642
  export declare function isVector(object: unknown): object is Vector;
6602
6643
 
@@ -10655,6 +10696,14 @@ export declare function serializeVector(vector: Vector): SerializedVector;
10655
10696
  */
10656
10697
  export declare function setActiveItem(player: EntityPlayer, collectibleType: CollectibleType, activeSlot: ActiveSlot, charge?: int, keepInPools?: boolean): void;
10657
10698
 
10699
+ /**
10700
+ * Helper function to add one or more elements to a set at once without having to repeatedly call
10701
+ * the `Set.add` method.
10702
+ *
10703
+ * This function is variadic, meaning that you can pass as many things as you want to add.
10704
+ */
10705
+ export declare function setAdd<T>(set: Set<T>, ...elements: T[]): void;
10706
+
10658
10707
  /**
10659
10708
  * Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
10660
10709
  * `Set.add` method if you have a set of this type.
@@ -10744,6 +10793,22 @@ export declare function setCollectiblesRerolledForItemTracker(): void;
10744
10793
  */
10745
10794
  export declare function setCollectibleSubType(collectible: EntityPickup, newCollectibleType: CollectibleType): void;
10746
10795
 
10796
+ /**
10797
+ * Helper function to run arbitrary code when you press and release a specific keyboard key.
10798
+ *
10799
+ * This can be used to easily set up custom hotkeys to facilitate custom game features or to assist
10800
+ * in debugging.
10801
+ *
10802
+ * This is different from the `setHotkey` function in that the keyboard activation key is not
10803
+ * hardcoded and is instead the return value of a provided function. This is useful for situations
10804
+ * where the key can change (like if end-users can specify a custom hotkey using Mod Config Menu).
10805
+ *
10806
+ * @param getKeyFunc The function that returns the key that will trigger the hotkey.
10807
+ * @param triggerFunc A function containing the arbitrary code that you want to execute when the
10808
+ * hotkey is triggered.
10809
+ */
10810
+ export declare function setConditionalHotkey(getKeyFunc: () => Keyboard | undefined, triggerFunc: () => void): void;
10811
+
10747
10812
  /**
10748
10813
  * Helper function to warp to a custom stage/level.
10749
10814
  *
@@ -10877,15 +10942,11 @@ export declare function setHasPlayer(set: Set<PlayerIndex>, player: EntityPlayer
10877
10942
  * This can be used to easily set up custom hotkeys to facilitate custom game features or to assist
10878
10943
  * in debugging.
10879
10944
  *
10880
- * @param keyboardOrFunc Either the key that you want to trigger the hotkey or a function that
10881
- * returns the key that will trigger the hotkey. Normally, you would just
10882
- * specify the key directly, but you can use a function for situations where
10883
- * the key can change (like if end-users can specify a custom hotkey using Mod
10884
- * Config Menu).
10945
+ * @param keyboard The key that you want to trigger the hotkey.
10885
10946
  * @param triggerFunc A function containing the arbitrary code that you want to execute when the
10886
10947
  * hotkey is triggered.
10887
10948
  */
10888
- export declare function setHotkey(keyboardOrFunc: Keyboard | (() => Keyboard | undefined), triggerFunc: () => void): void;
10949
+ export declare function setHotkey(keyboard: Keyboard, triggerFunc: () => void): void;
10889
10950
 
10890
10951
  /**
10891
10952
  * Supply a function to be repeatedly run on an interval of N game frames in the `POST_UPDATE`
@@ -12122,12 +12183,21 @@ export declare const UI_HEART_WIDTH = 12;
12122
12183
  /** Helper function to put things back to normal after the `pause` function was used. */
12123
12184
  export declare function unpause(): void;
12124
12185
 
12186
+ /**
12187
+ * Helper function to remove a hotkey created with the `setConditionalHotkey` function.
12188
+ *
12189
+ * @param getKeyFunc Equal to the `getKeyFunc` that you passed when initially registering the
12190
+ * hotkey.
12191
+ */
12192
+ export declare function unsetConditionalHotkey(getKeyFunc: () => Keyboard | undefined): void;
12193
+
12125
12194
  /**
12126
12195
  * Helper function to remove a hotkey created with the `setHotkey` function.
12127
12196
  *
12128
- * @param keyboardOrFunc Equal to the value that you passed when initially registering the hotkey.
12197
+ * @param keyboard Equal to the keyboard value that you passed when initially registering the
12198
+ * hotkey.
12129
12199
  */
12130
- export declare function unsetHotkey(keyboardOrFunc: Keyboard | (() => Keyboard | undefined)): void;
12200
+ export declare function unsetHotkey(keyboard: Keyboard): void;
12131
12201
 
12132
12202
  /**
12133
12203
  * Use this function to enable the custom callbacks and other optional features provided by