isaacscript-common 9.0.0 → 9.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 (40) hide show
  1. package/dist/callbacks/postPlayerCollectible.d.ts.map +1 -1
  2. package/dist/callbacks/postPlayerCollectible.lua +101 -27
  3. package/dist/enums/ModCallbackCustom.d.ts +4 -2
  4. package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
  5. package/dist/features/playerInventory.d.ts.map +1 -1
  6. package/dist/features/playerInventory.lua +4 -50
  7. package/dist/functions/cards.d.ts.map +1 -1
  8. package/dist/functions/collectibleCacheFlag.d.ts +4 -1
  9. package/dist/functions/collectibleCacheFlag.d.ts.map +1 -1
  10. package/dist/functions/collectibleCacheFlag.lua +5 -2
  11. package/dist/functions/debug.d.ts +25 -0
  12. package/dist/functions/debug.d.ts.map +1 -1
  13. package/dist/functions/debug.lua +50 -0
  14. package/dist/functions/familiars.d.ts.map +1 -1
  15. package/dist/functions/itemPool.lua +9 -11
  16. package/dist/functions/log.d.ts +2 -7
  17. package/dist/functions/log.d.ts.map +1 -1
  18. package/dist/functions/log.lua +9 -31
  19. package/dist/functions/players.d.ts +6 -0
  20. package/dist/functions/players.d.ts.map +1 -1
  21. package/dist/functions/players.lua +7 -1
  22. package/dist/index.d.ts +16 -3
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.lua +0 -8
  25. package/package.json +1 -1
  26. package/src/callbacks/postPlayerCollectible.ts +174 -38
  27. package/src/enums/ModCallbackCustom.ts +4 -2
  28. package/src/features/playerInventory.ts +5 -65
  29. package/src/functions/cards.ts +4 -2
  30. package/src/functions/collectibleCacheFlag.ts +6 -2
  31. package/src/functions/debug.ts +49 -0
  32. package/src/functions/familiars.ts +1 -0
  33. package/src/functions/itemPool.ts +6 -7
  34. package/src/functions/log.ts +15 -35
  35. package/src/functions/players.ts +14 -1
  36. package/src/index.ts +0 -1
  37. package/dist/functions/dev.d.ts +0 -20
  38. package/dist/functions/dev.d.ts.map +0 -1
  39. package/dist/functions/dev.lua +0 -34
  40. package/src/functions/dev.ts +0 -31
@@ -1,4 +1,36 @@
1
+ import { ModUpgraded } from "../classes/ModUpgraded";
2
+ import { enableExtraConsoleCommands } from "../features/extraConsoleCommands/exports";
3
+ import { removeFadeIn } from "../features/fadeInRemover";
4
+ import { enableFastReset } from "../features/fastReset";
5
+ import { saveDataManagerSetGlobal } from "../features/saveDataManager/exports";
6
+ import * as logExports from "./log";
1
7
  import { log } from "./log";
8
+ import * as logEntitiesExports from "./logEntities";
9
+
10
+ /**
11
+ * Helper function to enable some IsaacScript features that are useful when developing a mod. They
12
+ * should not be enabled when your mod goes to production (i.e. when it is uploaded to the Steam
13
+ * Workshop).
14
+ *
15
+ * The list of development features that are enabled are as follows:
16
+ *
17
+ * - `saveDataManagerSetGlobal` - Sets your local variables registered with the save data manager as
18
+ * global variables so you can access them from the in-game console.
19
+ * - `setLogFunctionsGlobal` - Sets the various log functions global so that you can access them
20
+ * from the in-game console.
21
+ * - `enableExtraConsoleCommands` - Enables many extra in-game console commands that make warping
22
+ * around easier (like e.g. `angel` to warp to the Angel Room).
23
+ * - `enableFastReset` - Makes it so that the r key resets the game instantaneously.
24
+ * - `removeFadeIn` - Removes the slow fade in that occurs at the beginning of the run, so that you
25
+ * can immediately start playing or testing.
26
+ */
27
+ export function enableDevFeatures(mod: ModUpgraded): void {
28
+ saveDataManagerSetGlobal();
29
+ setLogFunctionsGlobal();
30
+ enableExtraConsoleCommands(mod);
31
+ enableFastReset();
32
+ removeFadeIn();
33
+ }
2
34
 
3
35
  /**
4
36
  * Helper function to get a stack trace.
@@ -37,6 +69,23 @@ export function isLuaDebugEnabled(): boolean {
37
69
  return _G.package !== undefined;
38
70
  }
39
71
 
72
+ /**
73
+ * Converts every `isaacscript-common` function that begins with "log" to a global function.
74
+ *
75
+ * This is useful when printing out variables from the in-game debug console.
76
+ */
77
+ export function setLogFunctionsGlobal(): void {
78
+ const globals = _G as Record<string, unknown>;
79
+
80
+ for (const [logFuncName, logFunc] of Object.entries(logExports)) {
81
+ globals[logFuncName] = logFunc;
82
+ }
83
+
84
+ for (const [logFuncName, logFunc] of Object.entries(logEntitiesExports)) {
85
+ globals[logFuncName] = logFunc;
86
+ }
87
+ }
88
+
40
89
  /**
41
90
  * Helper function to print a stack trace to the "log.txt" file, similar to JavaScript's
42
91
  * `console.trace` function.
@@ -82,6 +82,7 @@ export function checkFamiliarFromCollectibles(
82
82
  familiarVariant: FamiliarVariant,
83
83
  familiarSubType?: int,
84
84
  ): void {
85
+ // We need to include non-real collectibles, like Lilith's Incubus.
85
86
  const numCollectibles = player.GetCollectibleNum(collectibleType);
86
87
  const effects = player.GetEffects();
87
88
 
@@ -128,13 +128,12 @@ function removeItemsAndTrinketsThatAffectItemPools(): [
128
128
  for (const player of getPlayers()) {
129
129
  const removedItems: CollectibleType[] = [];
130
130
  for (const itemToRemove of COLLECTIBLES_THAT_AFFECT_ITEM_POOLS) {
131
- if (player.HasCollectible(itemToRemove)) {
132
- const numCollectibles = player.GetCollectibleNum(itemToRemove);
133
- repeat(numCollectibles, () => {
134
- player.RemoveCollectible(itemToRemove);
135
- removedItems.push(itemToRemove);
136
- });
137
- }
131
+ // We need to include non-real collectibles, like Lilith's Incubus.
132
+ const numCollectibles = player.GetCollectibleNum(itemToRemove);
133
+ repeat(numCollectibles, () => {
134
+ player.RemoveCollectible(itemToRemove);
135
+ removedItems.push(itemToRemove);
136
+ });
138
137
  }
139
138
 
140
139
  mapSetPlayer(removedItemsMap, player, removedItems);
@@ -1,4 +1,5 @@
1
1
  import {
2
+ CollectibleType,
2
3
  DamageFlag,
3
4
  EntityFlag,
4
5
  GameStateFlag,
@@ -73,6 +74,20 @@ export function logArray<T>(this: void, array: T[] | readonly T[]): void {
73
74
  log(`Array: ${arrayString}`);
74
75
  }
75
76
 
77
+ export function logCollectibleTypes(
78
+ this: void,
79
+ collectibleTypes: CollectibleType[],
80
+ ): void {
81
+ log("Collectibles:");
82
+
83
+ let i = 1;
84
+ for (const collectibleType of collectibleTypes) {
85
+ const collectibleName = getCollectibleName(collectibleType);
86
+ log(`${i}) ${collectibleName} (${collectibleType})`);
87
+ i++;
88
+ }
89
+ }
90
+
76
91
  export function logColor(this: void, color: Color): void {
77
92
  log(
78
93
  `Color: R${color.R}, G${color.G}, B${color.B}, A${color.A}, RO${color.RO}, BO${color.BO}, GO${color.GO}`,
@@ -482,38 +497,3 @@ export function logVector(this: void, vector: Vector, round = false): void {
482
497
  const vectorString = vectorToString(vector, round);
483
498
  log(`Vector: ${vectorString}`);
484
499
  }
485
-
486
- /**
487
- * Converts every `isaacscript-common` function that begins with "log" to a global function.
488
- *
489
- * This is useful when printing out variables from the in-game debug console.
490
- */
491
- export function setLogFunctionsGlobal(): void {
492
- const globals = _G as Record<string, unknown>;
493
-
494
- globals["log"] = log;
495
- globals["logArray"] = logArray;
496
- globals["logColor"] = logColor;
497
- globals["logDamageFlags"] = logDamageFlags;
498
- globals["logEntityID"] = logEntityID;
499
- globals["logEntityFlags"] = logEntityFlags;
500
- globals["logError"] = logError;
501
- globals["logFlags"] = logFlags;
502
- globals["logGameStateFlags"] = logGameStateFlags;
503
- globals["logKColor"] = logKColor;
504
- globals["logLevelStateFlags"] = logLevelStateFlags;
505
- globals["logMap"] = logMap;
506
- globals["logPlayerEffects"] = logPlayerEffects;
507
- globals["logPlayerHealth"] = logPlayerHealth;
508
- globals["logProjectileFlags"] = logProjectileFlags;
509
- globals["logRoom"] = logRoom;
510
- globals["logSeedEffects"] = logSeedEffects;
511
- globals["logSet"] = logSet;
512
- globals["logSounds"] = logSounds;
513
- globals["logTable"] = logTable;
514
- globals["logTableDifferences"] = logTableDifferences;
515
- globals["logTearFlags"] = logTearFlags;
516
- globals["logUseFlags"] = logUseFlags;
517
- globals["logUserdata"] = logUserdata;
518
- globals["logVector"] = logVector;
519
- }
@@ -223,6 +223,8 @@ export function getPlayerCloserThan(
223
223
  * collectible type(s) provided.
224
224
  *
225
225
  * This function is variadic, meaning that you can specify N collectible types.
226
+ *
227
+ * Note that this will filter out non-real collectibles like Lilith's Incubus.
226
228
  */
227
229
  export function getPlayerCollectibleCount(
228
230
  player: EntityPlayer,
@@ -230,6 +232,8 @@ export function getPlayerCollectibleCount(
230
232
  ): int {
231
233
  let numCollectibles = 0;
232
234
  for (const collectibleType of collectibleTypes) {
235
+ // We need to specify "true" as the second argument here to filter out things like Lilith's
236
+ // Incubus.
233
237
  numCollectibles += player.GetCollectibleNum(collectibleType, true);
234
238
  }
235
239
 
@@ -239,6 +243,8 @@ export function getPlayerCollectibleCount(
239
243
  /**
240
244
  * Iterates over every item in the game and returns a map containing the number of each item that
241
245
  * the player has.
246
+ *
247
+ * Note that this will filter out non-real collectibles like Lilith's Incubus.
242
248
  */
243
249
  export function getPlayerCollectibleMap(
244
250
  player: EntityPlayer,
@@ -247,6 +253,8 @@ export function getPlayerCollectibleMap(
247
253
 
248
254
  const collectibleMap = new Map<CollectibleType, int>();
249
255
  for (const collectibleType of collectibleArray) {
256
+ // We need to specify "true" as the second argument here to filter out things like Lilith's
257
+ // Incubus.
250
258
  const collectibleNum = player.GetCollectibleNum(collectibleType, true);
251
259
  if (collectibleNum > 0) {
252
260
  collectibleMap.set(collectibleType, collectibleNum);
@@ -374,14 +382,19 @@ export function getPlayersWithTrinket(
374
382
  /**
375
383
  * Returns the total number of collectibles amongst all players. For example, if player 1 has 1 Sad
376
384
  * Onion and player 2 has 2 Sad Onions, then this function would return 3.
385
+ *
386
+ * Note that this will filter out non-real collectibles like Lilith's Incubus.
377
387
  */
378
388
  export function getTotalPlayerCollectibles(
379
389
  collectibleType: CollectibleType,
380
390
  ): int {
381
391
  const players = getPlayers();
382
392
  const numCollectiblesArray = players.map((player) =>
383
- player.GetCollectibleNum(collectibleType),
393
+ // We need to specify "true" as the second argument here to filter out things like Lilith's
394
+ // Incubus.
395
+ player.GetCollectibleNum(collectibleType, true),
384
396
  );
397
+
385
398
  return sumArray(numCollectiblesArray);
386
399
  }
387
400
 
package/src/index.ts CHANGED
@@ -67,7 +67,6 @@ export * from "./functions/curses";
67
67
  export * from "./functions/debug";
68
68
  export * from "./functions/deepCopy";
69
69
  export * from "./functions/deepCopyTests";
70
- export * from "./functions/dev";
71
70
  export * from "./functions/dimensions";
72
71
  export * from "./functions/direction";
73
72
  export * from "./functions/doors";
@@ -1,20 +0,0 @@
1
- import { ModUpgraded } from "../classes/ModUpgraded";
2
- /**
3
- * Helper function to enable some IsaacScript features that are useful when developing a mod. They
4
- * should not be enabled when your mod goes to production (i.e. when it is uploaded to the Steam
5
- * Workshop).
6
- *
7
- * The list of development features that are enabled are as follows:
8
- *
9
- * - `saveDataManagerSetGlobal` - Sets your local variables registered with the save data manager as
10
- * global variables so you can access them from the in-game console.
11
- * - `setLogFunctionsGlobal` - Sets the various log functions global so that you can access them
12
- * from the in-game console.
13
- * - `enableExtraConsoleCommands` - Enables many extra in-game console commands that make warping
14
- * around easier (like e.g. `angel` to warp to the Angel Room).
15
- * - `enableFastReset` - Makes it so that the r key resets the game instantaneously.
16
- * - `removeFadeIn` - Removes the slow fade in that occurs at the beginning of the run, so that you
17
- * can immediately start playing or testing.
18
- */
19
- export declare function enableDevFeatures(mod: ModUpgraded): void;
20
- //# sourceMappingURL=dev.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/functions/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAOrD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAMxD"}
@@ -1,34 +0,0 @@
1
- local ____exports = {}
2
- local ____exports = require("features.extraConsoleCommands.exports")
3
- local enableExtraConsoleCommands = ____exports.enableExtraConsoleCommands
4
- local ____fadeInRemover = require("features.fadeInRemover")
5
- local removeFadeIn = ____fadeInRemover.removeFadeIn
6
- local ____fastReset = require("features.fastReset")
7
- local enableFastReset = ____fastReset.enableFastReset
8
- local ____exports = require("features.saveDataManager.exports")
9
- local saveDataManagerSetGlobal = ____exports.saveDataManagerSetGlobal
10
- local ____log = require("functions.log")
11
- local setLogFunctionsGlobal = ____log.setLogFunctionsGlobal
12
- --- Helper function to enable some IsaacScript features that are useful when developing a mod. They
13
- -- should not be enabled when your mod goes to production (i.e. when it is uploaded to the Steam
14
- -- Workshop).
15
- --
16
- -- The list of development features that are enabled are as follows:
17
- --
18
- -- - `saveDataManagerSetGlobal` - Sets your local variables registered with the save data manager as
19
- -- global variables so you can access them from the in-game console.
20
- -- - `setLogFunctionsGlobal` - Sets the various log functions global so that you can access them
21
- -- from the in-game console.
22
- -- - `enableExtraConsoleCommands` - Enables many extra in-game console commands that make warping
23
- -- around easier (like e.g. `angel` to warp to the Angel Room).
24
- -- - `enableFastReset` - Makes it so that the r key resets the game instantaneously.
25
- -- - `removeFadeIn` - Removes the slow fade in that occurs at the beginning of the run, so that you
26
- -- can immediately start playing or testing.
27
- function ____exports.enableDevFeatures(self, mod)
28
- saveDataManagerSetGlobal(nil)
29
- setLogFunctionsGlobal(nil)
30
- enableExtraConsoleCommands(nil, mod)
31
- enableFastReset(nil)
32
- removeFadeIn(nil)
33
- end
34
- return ____exports
@@ -1,31 +0,0 @@
1
- import { ModUpgraded } from "../classes/ModUpgraded";
2
- import { enableExtraConsoleCommands } from "../features/extraConsoleCommands/exports";
3
- import { removeFadeIn } from "../features/fadeInRemover";
4
- import { enableFastReset } from "../features/fastReset";
5
- import { saveDataManagerSetGlobal } from "../features/saveDataManager/exports";
6
- import { setLogFunctionsGlobal } from "./log";
7
-
8
- /**
9
- * Helper function to enable some IsaacScript features that are useful when developing a mod. They
10
- * should not be enabled when your mod goes to production (i.e. when it is uploaded to the Steam
11
- * Workshop).
12
- *
13
- * The list of development features that are enabled are as follows:
14
- *
15
- * - `saveDataManagerSetGlobal` - Sets your local variables registered with the save data manager as
16
- * global variables so you can access them from the in-game console.
17
- * - `setLogFunctionsGlobal` - Sets the various log functions global so that you can access them
18
- * from the in-game console.
19
- * - `enableExtraConsoleCommands` - Enables many extra in-game console commands that make warping
20
- * around easier (like e.g. `angel` to warp to the Angel Room).
21
- * - `enableFastReset` - Makes it so that the r key resets the game instantaneously.
22
- * - `removeFadeIn` - Removes the slow fade in that occurs at the beginning of the run, so that you
23
- * can immediately start playing or testing.
24
- */
25
- export function enableDevFeatures(mod: ModUpgraded): void {
26
- saveDataManagerSetGlobal();
27
- setLogFunctionsGlobal();
28
- enableExtraConsoleCommands(mod);
29
- enableFastReset();
30
- removeFadeIn();
31
- }