isaacscript-common 20.3.2 → 20.4.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 (61) hide show
  1. package/dist/index.d.ts +123 -52
  2. package/dist/isaacscript-common.lua +389 -389
  3. package/dist/src/classes/callbacks/PostSlotDestroyed.d.ts +0 -8
  4. package/dist/src/classes/callbacks/PostSlotDestroyed.d.ts.map +1 -1
  5. package/dist/src/classes/callbacks/PostSlotDestroyed.lua +3 -51
  6. package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.d.ts +25 -0
  7. package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.d.ts.map +1 -0
  8. package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.lua +66 -0
  9. package/dist/src/classes/features/other/ExtraConsoleCommands.d.ts.map +1 -1
  10. package/dist/src/classes/features/other/ExtraConsoleCommands.lua +2 -3
  11. package/dist/src/classes/features/other/RoomHistory.d.ts.map +1 -1
  12. package/dist/src/classes/features/other/RoomHistory.lua +6 -1
  13. package/dist/src/classes/features/other/extraConsoleCommands/commands.d.ts.map +1 -1
  14. package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +69 -127
  15. package/dist/src/classes/features/other/extraConsoleCommands/subroutines.d.ts.map +1 -1
  16. package/dist/src/classes/features/other/extraConsoleCommands/subroutines.lua +11 -22
  17. package/dist/src/enums/ISCFeature.d.ts +44 -43
  18. package/dist/src/enums/ISCFeature.d.ts.map +1 -1
  19. package/dist/src/enums/ISCFeature.lua +45 -43
  20. package/dist/src/enums/ModCallbackCustom.d.ts +28 -2
  21. package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
  22. package/dist/src/enums/SlotDestructionType.d.ts +13 -0
  23. package/dist/src/enums/SlotDestructionType.d.ts.map +1 -1
  24. package/dist/src/features.d.ts +46 -43
  25. package/dist/src/features.d.ts.map +1 -1
  26. package/dist/src/features.lua +3 -0
  27. package/dist/src/functions/deepCopyTests.d.ts.map +1 -1
  28. package/dist/src/functions/deepCopyTests.lua +1 -3
  29. package/dist/src/functions/logMisc.d.ts.map +1 -1
  30. package/dist/src/functions/logMisc.lua +1 -3
  31. package/dist/src/functions/mergeTests.d.ts.map +1 -1
  32. package/dist/src/functions/mergeTests.lua +2 -5
  33. package/dist/src/functions/slots.d.ts +4 -0
  34. package/dist/src/functions/slots.d.ts.map +1 -0
  35. package/dist/src/functions/slots.lua +27 -0
  36. package/dist/src/functions/utils.d.ts +3 -4
  37. package/dist/src/functions/utils.d.ts.map +1 -1
  38. package/dist/src/functions/utils.lua +8 -6
  39. package/dist/src/index.d.ts +1 -0
  40. package/dist/src/index.d.ts.map +1 -1
  41. package/dist/src/index.lua +8 -0
  42. package/dist/src/interfaces/RoomDescription.d.ts +1 -0
  43. package/dist/src/interfaces/RoomDescription.d.ts.map +1 -1
  44. package/package.json +1 -1
  45. package/src/classes/callbacks/PostSlotDestroyed.ts +2 -72
  46. package/src/classes/features/callbackLogic/SlotDestroyedDetection.ts +113 -0
  47. package/src/classes/features/other/ExtraConsoleCommands.ts +3 -6
  48. package/src/classes/features/other/RoomHistory.ts +6 -0
  49. package/src/classes/features/other/extraConsoleCommands/commands.ts +70 -78
  50. package/src/classes/features/other/extraConsoleCommands/subroutines.ts +11 -12
  51. package/src/enums/ISCFeature.ts +1 -0
  52. package/src/enums/ModCallbackCustom.ts +28 -2
  53. package/src/enums/SlotDestructionType.ts +14 -0
  54. package/src/features.ts +6 -0
  55. package/src/functions/deepCopyTests.ts +1 -2
  56. package/src/functions/logMisc.ts +1 -2
  57. package/src/functions/mergeTests.ts +2 -4
  58. package/src/functions/slots.ts +23 -0
  59. package/src/functions/utils.ts +7 -6
  60. package/src/index.ts +1 -0
  61. package/src/interfaces/RoomDescription.ts +1 -0
package/dist/index.d.ts CHANGED
@@ -7204,49 +7204,50 @@ export declare enum ISCFeature {
7204
7204
  ITEM_PICKUP_DETECTION = 7,
7205
7205
  PLAYER_COLLECTIBLE_DETECTION = 8,
7206
7206
  PLAYER_REORDERED_CALLBACKS = 9,
7207
- SLOT_RENDER_DETECTION = 10,
7208
- SLOT_UPDATE_DETECTION = 11,
7209
- CHARACTER_HEALTH_CONVERSION = 12,
7210
- CHARACTER_STATS = 13,
7211
- COLLECTIBLE_ITEM_POOL_TYPE = 14,
7212
- CUSTOM_GRID_ENTITIES = 15,
7213
- CUSTOM_ITEM_POOLS = 16,
7214
- CUSTOM_HOTKEYS = 17,
7215
- CUSTOM_PICKUPS = 18,
7216
- CUSTOM_STAGES = 19,
7217
- CUSTOM_TRAPDOORS = 20,
7218
- DEBUG_DISPLAY = 21,
7219
- DEPLOY_JSON_ROOM = 22,
7220
- DISABLE_ALL_SOUND = 23,
7221
- DISABLE_INPUTS = 24,
7222
- FADE_IN_REMOVER = 25,
7223
- FAST_RESET = 26,
7224
- FLYING_DETECTION = 27,
7225
- FORGOTTEN_SWITCH = 28,
7226
- EXTRA_CONSOLE_COMMANDS = 29,
7227
- ITEM_POOL_DETECTION = 30,
7228
- MODDED_ELEMENT_DETECTION = 31,
7229
- MODDED_ELEMENT_SETS = 32,
7230
- NO_SIREN_STEAL = 33,
7231
- PAUSE = 34,
7232
- PERSISTENT_ENTITIES = 35,
7233
- PICKUP_INDEX_CREATION = 36,
7234
- PLAYER_INVENTORY = 37,
7235
- PONY_DETECTION = 38,
7236
- PRESS_INPUT = 39,
7237
- PREVENT_CHILD_ENTITIES = 40,
7238
- PREVENT_COLLECTIBLE_ROTATION = 41,
7239
- PREVENT_GRID_ENTITY_RESPAWN = 42,
7240
- ROOM_CLEAR_FRAME = 43,
7241
- ROOM_HISTORY = 44,
7242
- RUN_IN_N_FRAMES = 45,
7243
- RUN_NEXT_ROOM = 46,
7244
- SAVE_DATA_MANAGER = 47,
7245
- SPAWN_ALT_ROCK_REWARDS = 48,
7246
- SPAWN_COLLECTIBLE = 49,
7247
- STAGE_HISTORY = 50,
7248
- START_AMBUSH = 51,
7249
- TAINTED_LAZARUS_PLAYERS = 52
7207
+ SLOT_DESTROYED_DETECTION = 10,
7208
+ SLOT_RENDER_DETECTION = 11,
7209
+ SLOT_UPDATE_DETECTION = 12,
7210
+ CHARACTER_HEALTH_CONVERSION = 13,
7211
+ CHARACTER_STATS = 14,
7212
+ COLLECTIBLE_ITEM_POOL_TYPE = 15,
7213
+ CUSTOM_GRID_ENTITIES = 16,
7214
+ CUSTOM_ITEM_POOLS = 17,
7215
+ CUSTOM_HOTKEYS = 18,
7216
+ CUSTOM_PICKUPS = 19,
7217
+ CUSTOM_STAGES = 20,
7218
+ CUSTOM_TRAPDOORS = 21,
7219
+ DEBUG_DISPLAY = 22,
7220
+ DEPLOY_JSON_ROOM = 23,
7221
+ DISABLE_ALL_SOUND = 24,
7222
+ DISABLE_INPUTS = 25,
7223
+ FADE_IN_REMOVER = 26,
7224
+ FAST_RESET = 27,
7225
+ FLYING_DETECTION = 28,
7226
+ FORGOTTEN_SWITCH = 29,
7227
+ EXTRA_CONSOLE_COMMANDS = 30,
7228
+ ITEM_POOL_DETECTION = 31,
7229
+ MODDED_ELEMENT_DETECTION = 32,
7230
+ MODDED_ELEMENT_SETS = 33,
7231
+ NO_SIREN_STEAL = 34,
7232
+ PAUSE = 35,
7233
+ PERSISTENT_ENTITIES = 36,
7234
+ PICKUP_INDEX_CREATION = 37,
7235
+ PLAYER_INVENTORY = 38,
7236
+ PONY_DETECTION = 39,
7237
+ PRESS_INPUT = 40,
7238
+ PREVENT_CHILD_ENTITIES = 41,
7239
+ PREVENT_COLLECTIBLE_ROTATION = 42,
7240
+ PREVENT_GRID_ENTITY_RESPAWN = 43,
7241
+ ROOM_CLEAR_FRAME = 44,
7242
+ ROOM_HISTORY = 45,
7243
+ RUN_IN_N_FRAMES = 46,
7244
+ RUN_NEXT_ROOM = 47,
7245
+ SAVE_DATA_MANAGER = 48,
7246
+ SPAWN_ALT_ROCK_REWARDS = 49,
7247
+ SPAWN_COLLECTIBLE = 50,
7248
+ STAGE_HISTORY = 51,
7249
+ START_AMBUSH = 52,
7250
+ TAINTED_LAZARUS_PLAYERS = 53
7250
7251
  }
7251
7252
 
7252
7253
  /**
@@ -7266,6 +7267,7 @@ declare interface ISCFeatureToClass {
7266
7267
  [ISCFeature.ITEM_PICKUP_DETECTION]: ItemPickupDetection;
7267
7268
  [ISCFeature.PLAYER_COLLECTIBLE_DETECTION]: PlayerCollectibleDetection;
7268
7269
  [ISCFeature.PLAYER_REORDERED_CALLBACKS]: PlayerReorderedCallbacks;
7270
+ [ISCFeature.SLOT_DESTROYED_DETECTION]: SlotDestroyedDetection;
7269
7271
  [ISCFeature.SLOT_RENDER_DETECTION]: SlotRenderDetection;
7270
7272
  [ISCFeature.SLOT_UPDATE_DETECTION]: SlotUpdateDetection;
7271
7273
  [ISCFeature.CHARACTER_HEALTH_CONVERSION]: CharacterHealthConversion;
@@ -7883,6 +7885,9 @@ export declare function isSingleUseCollectible(collectibleType: CollectibleType)
7883
7885
  /** For `EntityType.SLOT` (6). */
7884
7886
  export declare function isSlot(entity: Entity): entity is EntitySlot;
7885
7887
 
7888
+ /** Returns true for the specific variants of `EntityType.SLOT` that are machines. */
7889
+ export declare function isSlotMachine(entity: Entity): boolean;
7890
+
7886
7891
  /** Returns true for cards that have `CardType.SPECIAL`. */
7887
7892
  export declare function isSpecialCard(cardType: CardType): boolean;
7888
7893
 
@@ -8374,6 +8379,12 @@ export declare function logAllEntities(includeBackgroundEffects: boolean, entity
8374
8379
  */
8375
8380
  export declare function logAllGridEntities(includeWalls?: boolean, gridEntityTypeFilter?: GridEntityType): void;
8376
8381
 
8382
+ /**
8383
+ * Helper function to log a message to the "log.txt" file and to print it to the screen at the same
8384
+ * time.
8385
+ */
8386
+ export declare function logAndPrint(msg: string): void;
8387
+
8377
8388
  /** Helper function to enumerate all of the values in an array. */
8378
8389
  export declare function logArray<T>(array: T[] | readonly T[]): void;
8379
8390
 
@@ -10194,8 +10205,34 @@ export declare enum ModCallbackCustom {
10194
10205
  */
10195
10206
  POST_SLOT_COLLISION = 87,
10196
10207
  /**
10197
- * Fires from the `POST_RENDER` callback when a slot plays the animation that indicates that it
10198
- * has broken.
10208
+ * Fires from the `POST_SLOT_UPDATE` or the `POST_ENTITY_REMOVE` callback when a slot machine is
10209
+ * destroyed or a beggar is removed.
10210
+ *
10211
+ * This callback will fire in four different kinds of situations:
10212
+ *
10213
+ * 1. When slot machine entities (e.g. `SlotVariant.SLOT_MACHINE` and
10214
+ * `SlotVariant.BLOOD_DONATION_MACHINE`) are destroyed with an explosion. When this happens,
10215
+ * they typically stay in the room and can be pushed around. This state is detected via a
10216
+ * change in the `GridCollisionClass`.
10217
+ * 2. When slot machine entities pay out with a collectible item. When this happens, they
10218
+ * immediately despawn without playing any special animation.
10219
+ * 3. When beggars are destroyed with an explosion. When this happens, they immediately despawn
10220
+ * without playing any special animation.
10221
+ * 4. When beggars pay out with a collectible item. When this happens, they despawn after playing
10222
+ * the "Teleport" animation. (This is not technically a "destruction" event, but the callback
10223
+ * will fire for this to remain consistent with the other types of slot entities.)
10224
+ *
10225
+ * Depending on the specific types of slot removal that you need to detect, you can filter using:
10226
+ *
10227
+ * 1. The `isSlotMachine` helper function to differentiate between slot machines and beggars.
10228
+ * 2. The passed callback argument of `SlotDestructionType` to differentiate between bombed slots
10229
+ * and slots that paid out with a collectible item.
10230
+ *
10231
+ * Note that when a Crane Game explodes after paying out three collectibles, the
10232
+ * `SlotDestructionType` will be equal to `SlotDestructionType.NORMAL` instead of
10233
+ * `SlotDestructionType.COLLECTIBLE_PAYOUT` like you might expect. (This is because it only
10234
+ * explodes after a short delay, and when doing so, it produces rewards in the same way that would
10235
+ * happen if you bombed it.)
10199
10236
  *
10200
10237
  * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
10201
10238
  * - You can provide an optional third argument that will make the callback only fire if it
@@ -12257,6 +12294,11 @@ declare class PostSlotAnimationChanged extends CustomCallback<ModCallbackCustom.
12257
12294
  protected shouldFire: typeof shouldFireSlot;
12258
12295
  }
12259
12296
 
12297
+ declare class PostSlotDestroyed extends CustomCallback<ModCallbackCustom.POST_SLOT_DESTROYED> {
12298
+ constructor();
12299
+ protected shouldFire: typeof shouldFireSlot;
12300
+ }
12301
+
12260
12302
  declare class PostSlotInit extends CustomCallback<ModCallbackCustom.POST_SLOT_INIT> {
12261
12303
  constructor();
12262
12304
  protected shouldFire: typeof shouldFireSlot;
@@ -12364,13 +12406,6 @@ declare class PreventGridEntityRespawn extends Feature {
12364
12406
  preventGridEntityRespawn(): void;
12365
12407
  }
12366
12408
 
12367
- /**
12368
- * Helper function to print something to the in-game console. Use this instead of invoking the
12369
- * `Isaac.ConsoleOutput` method directly because it will automatically insert a newline at the end
12370
- * of the message (which `Isaac.ConsoleOutput` does not do by default).
12371
- */
12372
- export declare function printConsole(msg: string): void;
12373
-
12374
12409
  /** Helper function to print whether something was enabled or disabled to the in-game console. */
12375
12410
  export declare function printEnabled(enabled: boolean, description: string): void;
12376
12411
 
@@ -13073,6 +13108,7 @@ declare class RoomClearFrame extends Feature {
13073
13108
 
13074
13109
  /** This is used by the room history feature of the standard library. */
13075
13110
  export declare interface RoomDescription {
13111
+ startSeedString: string;
13076
13112
  stage: LevelStage;
13077
13113
  stageType: StageType;
13078
13114
  stageID: StageID;
@@ -14101,9 +14137,44 @@ export declare function shuffleArrayInPlace<T>(array: T[], seedOrRNG?: Seed | RN
14101
14137
  */
14102
14138
  export declare function sign(n: number): int;
14103
14139
 
14140
+ declare class SlotDestroyedDetection extends Feature {
14141
+ v: {
14142
+ room: {
14143
+ destroyedSlotSet: Set<PtrHash>;
14144
+ };
14145
+ };
14146
+ private postSlotDestroyed;
14147
+ private roomHistory;
14148
+ constructor(postSlotDestroyed: PostSlotDestroyed, roomHistory: RoomHistory);
14149
+ private postEntityRemoveSlot;
14150
+ private postEntityRemoveSlotMachine;
14151
+ private postEntityRemoveBeggar;
14152
+ private postSlotUpdate;
14153
+ /**
14154
+ * Slots normally have an entity collision class of `EntityCollisionClass.ALL` (4) and a grid
14155
+ * collision class of `EntityGridCollisionClass.NONE` (0). When they are destroyed with a bomb,
14156
+ * the entity collision class stays the same, but the grid collision class switches to
14157
+ * `EntityGridCollisionClass.GROUND` (5).
14158
+ */
14159
+ private checkDestroyedFromCollisionClass;
14160
+ }
14161
+
14104
14162
  /** This is used in the `POST_SLOT_DESTROYED` custom callback. */
14105
14163
  export declare enum SlotDestructionType {
14164
+ /**
14165
+ * When a machine or a beggar is blown up by a bomb or is otherwise removed without spawning a
14166
+ * collectible.
14167
+ *
14168
+ * Note that the destruction type for a Crane Game will be `SlotDestructionType.NORMAL`, even if
14169
+ * it destroyed via spawning three separate collectibles.
14170
+ */
14106
14171
  NORMAL = 0,
14172
+ /**
14173
+ * When a machine or a beggar is removed while spawning a collectible reward.
14174
+ *
14175
+ * Note that the destruction type for a Crane Game will be `SlotDestructionType.NORMAL`, even if
14176
+ * it destroyed via spawning three separate collectibles.
14177
+ */
14107
14178
  COLLECTIBLE_PAYOUT = 1
14108
14179
  }
14109
14180