isaacscript-common 20.3.2 → 20.4.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 (58) hide show
  1. package/dist/index.d.ts +103 -50
  2. package/dist/isaacscript-common.lua +414 -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 +36 -0
  7. package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.d.ts.map +1 -0
  8. package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.lua +91 -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/SlotDestructionType.d.ts +13 -0
  21. package/dist/src/enums/SlotDestructionType.d.ts.map +1 -1
  22. package/dist/src/features.d.ts +46 -43
  23. package/dist/src/features.d.ts.map +1 -1
  24. package/dist/src/features.lua +3 -0
  25. package/dist/src/functions/deepCopyTests.d.ts.map +1 -1
  26. package/dist/src/functions/deepCopyTests.lua +1 -3
  27. package/dist/src/functions/logMisc.d.ts.map +1 -1
  28. package/dist/src/functions/logMisc.lua +1 -3
  29. package/dist/src/functions/mergeTests.d.ts.map +1 -1
  30. package/dist/src/functions/mergeTests.lua +2 -5
  31. package/dist/src/functions/slots.d.ts +4 -0
  32. package/dist/src/functions/slots.d.ts.map +1 -0
  33. package/dist/src/functions/slots.lua +27 -0
  34. package/dist/src/functions/utils.d.ts +3 -4
  35. package/dist/src/functions/utils.d.ts.map +1 -1
  36. package/dist/src/functions/utils.lua +8 -6
  37. package/dist/src/index.d.ts +1 -0
  38. package/dist/src/index.d.ts.map +1 -1
  39. package/dist/src/index.lua +8 -0
  40. package/dist/src/interfaces/RoomDescription.d.ts +1 -0
  41. package/dist/src/interfaces/RoomDescription.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/classes/callbacks/PostSlotDestroyed.ts +2 -72
  44. package/src/classes/features/callbackLogic/SlotDestroyedDetection.ts +163 -0
  45. package/src/classes/features/other/ExtraConsoleCommands.ts +3 -6
  46. package/src/classes/features/other/RoomHistory.ts +6 -0
  47. package/src/classes/features/other/extraConsoleCommands/commands.ts +70 -78
  48. package/src/classes/features/other/extraConsoleCommands/subroutines.ts +11 -12
  49. package/src/enums/ISCFeature.ts +1 -0
  50. package/src/enums/SlotDestructionType.ts +14 -0
  51. package/src/features.ts +6 -0
  52. package/src/functions/deepCopyTests.ts +1 -2
  53. package/src/functions/logMisc.ts +1 -2
  54. package/src/functions/mergeTests.ts +2 -4
  55. package/src/functions/slots.ts +23 -0
  56. package/src/functions/utils.ts +7 -6
  57. package/src/index.ts +1 -0
  58. package/src/interfaces/RoomDescription.ts +1 -0
@@ -10,6 +10,7 @@ export enum ISCFeature {
10
10
  ITEM_PICKUP_DETECTION,
11
11
  PLAYER_COLLECTIBLE_DETECTION,
12
12
  PLAYER_REORDERED_CALLBACKS,
13
+ SLOT_DESTROYED_DETECTION,
13
14
  SLOT_RENDER_DETECTION,
14
15
  SLOT_UPDATE_DETECTION,
15
16
 
@@ -1,5 +1,19 @@
1
1
  /** This is used in the `POST_SLOT_DESTROYED` custom callback. */
2
2
  export enum SlotDestructionType {
3
+ /**
4
+ * When a machine or a beggar is blown up by a bomb or is otherwise removed without spawning a
5
+ * collectible.
6
+ *
7
+ * Note that the destruction type for a Crane Game will be `SlotDestructionType.NORMAL`, even if
8
+ * it destroyed via spawning three separate collectibles.
9
+ */
3
10
  NORMAL,
11
+
12
+ /**
13
+ * When a machine or a beggar is removed while spawning a collectible reward.
14
+ *
15
+ * Note that the destruction type for a Crane Game will be `SlotDestructionType.NORMAL`, even if
16
+ * it destroyed via spawning three separate collectibles.
17
+ */
4
18
  COLLECTIBLE_PAYOUT,
5
19
  }
package/src/features.ts CHANGED
@@ -10,6 +10,7 @@ import { GridEntityUpdateDetection } from "./classes/features/callbackLogic/Grid
10
10
  import { ItemPickupDetection } from "./classes/features/callbackLogic/ItemPickupDetection";
11
11
  import { PlayerCollectibleDetection } from "./classes/features/callbackLogic/PlayerCollectibleDetection";
12
12
  import { PlayerReorderedCallbacks } from "./classes/features/callbackLogic/PlayerReorderedCallbacks";
13
+ import { SlotDestroyedDetection } from "./classes/features/callbackLogic/SlotDestroyedDetection";
13
14
  import { SlotRenderDetection } from "./classes/features/callbackLogic/SlotRenderDetection";
14
15
  import { SlotUpdateDetection } from "./classes/features/callbackLogic/SlotUpdateDetection";
15
16
  import { CharacterHealthConversion } from "./classes/features/other/CharacterHealthConversion";
@@ -71,6 +72,7 @@ export interface ISCFeatureToClass {
71
72
  [ISCFeature.ITEM_PICKUP_DETECTION]: ItemPickupDetection;
72
73
  [ISCFeature.PLAYER_COLLECTIBLE_DETECTION]: PlayerCollectibleDetection;
73
74
  [ISCFeature.PLAYER_REORDERED_CALLBACKS]: PlayerReorderedCallbacks;
75
+ [ISCFeature.SLOT_DESTROYED_DETECTION]: SlotDestroyedDetection;
74
76
  [ISCFeature.SLOT_RENDER_DETECTION]: SlotRenderDetection;
75
77
  [ISCFeature.SLOT_UPDATE_DETECTION]: SlotUpdateDetection;
76
78
 
@@ -222,6 +224,10 @@ export function getFeatures(
222
224
  callbacks[ModCallbackCustom.POST_PLAYER_RENDER_REORDERED],
223
225
  callbacks[ModCallbackCustom.POST_PLAYER_UPDATE_REORDERED],
224
226
  ),
227
+ [ISCFeature.SLOT_DESTROYED_DETECTION]: new SlotDestroyedDetection(
228
+ callbacks[ModCallbackCustom.POST_SLOT_DESTROYED],
229
+ roomHistory,
230
+ ),
225
231
  [ISCFeature.SLOT_RENDER_DETECTION]: new SlotRenderDetection(
226
232
  callbacks[ModCallbackCustom.POST_SLOT_RENDER],
227
233
  callbacks[ModCallbackCustom.POST_SLOT_ANIMATION_CHANGED],
@@ -6,7 +6,6 @@ import { deepCopy } from "./deepCopy";
6
6
  import { log } from "./log";
7
7
  import { isDefaultMap, isTSTLMap, isTSTLSet } from "./tstlClass";
8
8
  import { isNumber, isString, isTable } from "./types";
9
- import { printConsole } from "./utils";
10
9
 
11
10
  /**
12
11
  * Run the suite of tests that prove that the "deepCopy" helper function works properly.
@@ -41,7 +40,7 @@ export function runDeepCopyTests(): void {
41
40
 
42
41
  const successText = "All deep copy tests passed!";
43
42
  log(successText);
44
- printConsole(successText);
43
+ print(successText);
45
44
  }
46
45
 
47
46
  function copiedObjectIsTable() {
@@ -28,7 +28,6 @@ import { iterateTableInOrder } from "./table";
28
28
  import { getTrinketName } from "./trinkets";
29
29
  import { isDefaultMap, isTSTLMap, isTSTLSet } from "./tstlClass";
30
30
  import { isTable, isUserdata } from "./types";
31
- import { printConsole } from "./utils";
32
31
  import { vectorToString } from "./vector";
33
32
 
34
33
  /** Helper function to enumerate all of the values in an array. */
@@ -85,7 +84,7 @@ export function logEntityID(entity: Entity): void {
85
84
  export function logError(msg: string): void {
86
85
  const errorMsg = `Error: ${msg}`;
87
86
  log(errorMsg);
88
- printConsole(errorMsg);
87
+ print(errorMsg);
89
88
  }
90
89
 
91
90
  /** Helper function for printing out every flag that is turned on. Useful when debugging. */
@@ -1,11 +1,10 @@
1
1
  import { DefaultMap } from "../classes/DefaultMap";
2
2
  import { SerializationType } from "../enums/SerializationType";
3
3
  import { deepCopy } from "./deepCopy";
4
- import { log } from "./log";
5
4
  import { merge } from "./merge";
6
5
  import { isRNG, newRNG } from "./rng";
7
6
  import { isSerializedIsaacAPIClass } from "./serialization";
8
- import { printConsole } from "./utils";
7
+ import { logAndPrint } from "./utils";
9
8
  import { isVector, serializeVector } from "./vector";
10
9
 
11
10
  /**
@@ -29,8 +28,7 @@ export function runMergeTests(): void {
29
28
  oldTableHasRNGSerialized();
30
29
 
31
30
  const successText = "All merge tests passed!";
32
- log(successText);
33
- printConsole(successText);
31
+ logAndPrint(successText);
34
32
  }
35
33
 
36
34
  function oldTableHasUpdatedValue() {
@@ -0,0 +1,23 @@
1
+ import { SlotVariant } from "isaac-typescript-definitions";
2
+ import { isSlot } from "./entityTypes";
3
+
4
+ const SLOT_MACHINE_VARIANTS: ReadonlySet<SlotVariant> = new Set([
5
+ SlotVariant.SLOT_MACHINE, // 1
6
+ SlotVariant.BLOOD_DONATION_MACHINE, // 2,
7
+ SlotVariant.FORTUNE_TELLING_MACHINE, // 3
8
+ SlotVariant.DONATION_MACHINE, // 8
9
+ SlotVariant.SHOP_RESTOCK_MACHINE, // 10
10
+ SlotVariant.GREED_DONATION_MACHINE, // 11
11
+ SlotVariant.MOMS_DRESSING_TABLE, // 12
12
+ SlotVariant.CRANE_GAME, // 16
13
+ SlotVariant.CONFESSIONAL, // 17
14
+ ]);
15
+
16
+ /** Returns true for the specific variants of `EntityType.SLOT` that are machines. */
17
+ export function isSlotMachine(entity: Entity): boolean {
18
+ if (!isSlot(entity)) {
19
+ return false;
20
+ }
21
+
22
+ return SLOT_MACHINE_VARIANTS.has(entity.Variant);
23
+ }
@@ -1,6 +1,7 @@
1
1
  import { RenderMode } from "isaac-typescript-definitions";
2
2
  import { game } from "../core/cachedClasses";
3
3
  import { CONSOLE_COMMANDS_SET } from "../sets/consoleCommandsSet";
4
+ import { log } from "./log";
4
5
 
5
6
  /**
6
7
  * Helper function to return an array of integers with the specified range, inclusive on the lower
@@ -103,18 +104,18 @@ export function isVanillaConsoleCommand(commandName: string): boolean {
103
104
  }
104
105
 
105
106
  /**
106
- * Helper function to print something to the in-game console. Use this instead of invoking the
107
- * `Isaac.ConsoleOutput` method directly because it will automatically insert a newline at the end
108
- * of the message (which `Isaac.ConsoleOutput` does not do by default).
107
+ * Helper function to log a message to the "log.txt" file and to print it to the screen at the same
108
+ * time.
109
109
  */
110
- export function printConsole(msg: string): void {
111
- Isaac.ConsoleOutput(`${msg}\n`);
110
+ export function logAndPrint(msg: string): void {
111
+ log(msg);
112
+ print(msg);
112
113
  }
113
114
 
114
115
  /** Helper function to print whether something was enabled or disabled to the in-game console. */
115
116
  export function printEnabled(enabled: boolean, description: string): void {
116
117
  const enabledText = enabled ? "Enabled" : "Disabled";
117
- printConsole(`${enabledText} ${description}.`);
118
+ print(`${enabledText} ${description}.`);
118
119
  }
119
120
 
120
121
  /**
package/src/index.ts CHANGED
@@ -103,6 +103,7 @@ export * from "./functions/run";
103
103
  export * from "./functions/seeds";
104
104
  export * from "./functions/serialization";
105
105
  export * from "./functions/set";
106
+ export * from "./functions/slots";
106
107
  export * from "./functions/sound";
107
108
  export * from "./functions/spawnCollectible";
108
109
  export * from "./functions/sprites";
@@ -8,6 +8,7 @@ import {
8
8
 
9
9
  /** This is used by the room history feature of the standard library. */
10
10
  export interface RoomDescription {
11
+ startSeedString: string;
11
12
  stage: LevelStage;
12
13
  stageType: StageType;
13
14
  stageID: StageID;