isaacscript-common 10.1.0 → 10.2.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.
package/dist/index.d.ts CHANGED
@@ -6438,6 +6438,32 @@ export declare function isTarotCard(cardType: CardType): boolean;
6438
6438
  /** Helper function to detect if a variable is of type `EntityTear`. */
6439
6439
  export declare function isTear(variable: unknown): variable is EntityTear;
6440
6440
 
6441
+ /**
6442
+ * Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
6443
+ * is determined by looking at the parent.
6444
+ *
6445
+ * For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
6446
+ * player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
6447
+ * and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
6448
+ * callback or on frame 2+.
6449
+ *
6450
+ * If this function is called on frame 0 or frame 1, it will throw a run-time error.
6451
+ */
6452
+ export declare function isTearFromFamiliar(tear: EntityTear): boolean;
6453
+
6454
+ /**
6455
+ * Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
6456
+ * is determined by looking at the parent.
6457
+ *
6458
+ * For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
6459
+ * player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
6460
+ * and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
6461
+ * callback or on frame 2+.
6462
+ *
6463
+ * If this function is called on frame 0 or frame 1, it will throw a run-time error.
6464
+ */
6465
+ export declare function isTearFromPlayer(tear: EntityTear): boolean;
6466
+
6441
6467
  /** Helper function to detect if a variable is of type `GridEntityTNT`. */
6442
6468
  export declare function isTNT(variable: unknown): variable is GridEntityTNT;
6443
6469
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 10.1.0
3
+ isaacscript-common 10.2.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -22575,7 +22575,7 @@ function ____exports.getUnusedDoorSlots(self)
22575
22575
  local doorSlots = getEnumValues(nil, DoorSlot)
22576
22576
  return __TS__ArrayFilter(
22577
22577
  doorSlots,
22578
- function(____, doorSlot) return room:IsDoorSlotAllowed(doorSlot) and room:GetDoor(doorSlot) == nil end
22578
+ function(____, doorSlot) return doorSlot ~= DoorSlot.NO_DOOR_SLOT and room:IsDoorSlotAllowed(doorSlot) and room:GetDoor(doorSlot) == nil end
22579
22579
  )
22580
22580
  end
22581
22581
  --- Helper function to check if the current room has one or more open door slots that can be used to
@@ -39247,6 +39247,44 @@ function ____exports.addTearsStat(self, player, tearsStat)
39247
39247
  local newMaxFireDelay = ____exports.getFireDelay(nil, newTearsStat)
39248
39248
  player.MaxFireDelay = newMaxFireDelay
39249
39249
  end
39250
+ --- Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
39251
+ -- is determined by looking at the parent.
39252
+ --
39253
+ -- For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
39254
+ -- player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
39255
+ -- and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
39256
+ -- callback or on frame 2+.
39257
+ --
39258
+ -- If this function is called on frame 0 or frame 1, it will throw a run-time error.
39259
+ function ____exports.isTearFromFamiliar(self, tear)
39260
+ if tear.FrameCount == 0 or tear.FrameCount == 1 then
39261
+ error(("Failed to check if the given tear was from a player since the tear's frame count was equal to " .. tostring(tear.FrameCount)) .. ". (The \"isTearFromFamiliar\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 2 and onwards.)")
39262
+ end
39263
+ if tear.Parent == nil then
39264
+ return false
39265
+ end
39266
+ local familiar = tear.Parent:ToFamiliar()
39267
+ return familiar ~= nil
39268
+ end
39269
+ --- Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
39270
+ -- is determined by looking at the parent.
39271
+ --
39272
+ -- For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
39273
+ -- player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
39274
+ -- and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
39275
+ -- callback or on frame 2+.
39276
+ --
39277
+ -- If this function is called on frame 0 or frame 1, it will throw a run-time error.
39278
+ function ____exports.isTearFromPlayer(self, tear)
39279
+ if tear.FrameCount == 0 or tear.FrameCount == 1 then
39280
+ error(("Failed to check if the given tear was from a player since the tear's frame count was equal to " .. tostring(tear.FrameCount)) .. ". (The \"isTearFromPlayer\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 2 and onwards.)")
39281
+ end
39282
+ if tear.Parent == nil then
39283
+ return false
39284
+ end
39285
+ local player = tear.Parent:ToPlayer()
39286
+ return player ~= nil
39287
+ end
39250
39288
  return ____exports
39251
39289
  end,
39252
39290
  ["src.maps.defaultPlayerStatMap"] = function(...)
@@ -46910,7 +46948,7 @@ return ____exports
46910
46948
  ["package"] = function(...)
46911
46949
  return {
46912
46950
  name = "isaacscript-common",
46913
- version = "10.1.0",
46951
+ version = "10.2.0",
46914
46952
  description = "Helper functions and features for IsaacScript mods.",
46915
46953
  keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
46916
46954
  homepage = "https://isaacscript.github.io/",
package/dist/package.lua CHANGED
@@ -1,6 +1,6 @@
1
1
  return {
2
2
  name = "isaacscript-common",
3
- version = "10.1.0",
3
+ version = "10.2.0",
4
4
  description = "Helper functions and features for IsaacScript mods.",
5
5
  keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
6
6
  homepage = "https://isaacscript.github.io/",
@@ -1 +1 @@
1
- {"version":3,"file":"doors.d.ts","sourceRoot":"","sources":["../../../src/functions/doors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,YAAY,EAIZ,SAAS,EACT,QAAQ,EACT,MAAM,8BAA8B,CAAC;AAmBtC,wBAAgB,aAAa,IAAI,IAAI,CAIpC;AAED;;;GAG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CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAU/D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAKpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAM9D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAUnD;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAMnC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAKvD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,GAAG,CAK5D;AAED,+CAA+C;AAC/C,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAGrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,CAI5D"}
@@ -270,7 +270,7 @@ function ____exports.getUnusedDoorSlots(self)
270
270
  local doorSlots = getEnumValues(nil, DoorSlot)
271
271
  return __TS__ArrayFilter(
272
272
  doorSlots,
273
- function(____, doorSlot) return room:IsDoorSlotAllowed(doorSlot) and room:GetDoor(doorSlot) == nil end
273
+ function(____, doorSlot) return doorSlot ~= DoorSlot.NO_DOOR_SLOT and room:IsDoorSlotAllowed(doorSlot) and room:GetDoor(doorSlot) == nil end
274
274
  )
275
275
  end
276
276
  --- Helper function to check if the current room has one or more open door slots that can be used to
@@ -1,5 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
3
4
  /**
4
5
  * - Converts the specified amount of tears stat into the format of `EntityPlayer.MaxFireDelay` and
5
6
  * adds it to the player.
@@ -22,4 +23,28 @@ export declare function getFireDelay(tearsStat: float): float;
22
23
  * this function.
23
24
  */
24
25
  export declare function getTearsStat(fireDelay: float): float;
26
+ /**
27
+ * Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
28
+ * is determined by looking at the parent.
29
+ *
30
+ * For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
31
+ * player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
32
+ * and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
33
+ * callback or on frame 2+.
34
+ *
35
+ * If this function is called on frame 0 or frame 1, it will throw a run-time error.
36
+ */
37
+ export declare function isTearFromFamiliar(tear: EntityTear): boolean;
38
+ /**
39
+ * Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
40
+ * is determined by looking at the parent.
41
+ *
42
+ * For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
43
+ * player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
44
+ * and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
45
+ * callback or on frame 2+.
46
+ *
47
+ * If this function is called on frame 0 or frame 1, it will throw a run-time error.
48
+ */
49
+ export declare function isTearFromPlayer(tear: EntityTear): boolean;
25
50
  //# sourceMappingURL=tears.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tears.d.ts","sourceRoot":"","sources":["../../../src/functions/tears.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAKzE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD"}
1
+ {"version":3,"file":"tears.d.ts","sourceRoot":"","sources":["../../../src/functions/tears.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAKzE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAc5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAc1D"}
@@ -24,4 +24,42 @@ function ____exports.addTearsStat(self, player, tearsStat)
24
24
  local newMaxFireDelay = ____exports.getFireDelay(nil, newTearsStat)
25
25
  player.MaxFireDelay = newMaxFireDelay
26
26
  end
27
+ --- Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
28
+ -- is determined by looking at the parent.
29
+ --
30
+ -- For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
31
+ -- player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
32
+ -- and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
33
+ -- callback or on frame 2+.
34
+ --
35
+ -- If this function is called on frame 0 or frame 1, it will throw a run-time error.
36
+ function ____exports.isTearFromFamiliar(self, tear)
37
+ if tear.FrameCount == 0 or tear.FrameCount == 1 then
38
+ error(("Failed to check if the given tear was from a player since the tear's frame count was equal to " .. tostring(tear.FrameCount)) .. ". (The \"isTearFromFamiliar\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 2 and onwards.)")
39
+ end
40
+ if tear.Parent == nil then
41
+ return false
42
+ end
43
+ local familiar = tear.Parent:ToFamiliar()
44
+ return familiar ~= nil
45
+ end
46
+ --- Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
47
+ -- is determined by looking at the parent.
48
+ --
49
+ -- For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
50
+ -- player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
51
+ -- and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
52
+ -- callback or on frame 2+.
53
+ --
54
+ -- If this function is called on frame 0 or frame 1, it will throw a run-time error.
55
+ function ____exports.isTearFromPlayer(self, tear)
56
+ if tear.FrameCount == 0 or tear.FrameCount == 1 then
57
+ error(("Failed to check if the given tear was from a player since the tear's frame count was equal to " .. tostring(tear.FrameCount)) .. ". (The \"isTearFromPlayer\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 2 and onwards.)")
58
+ end
59
+ if tear.Parent == nil then
60
+ return false
61
+ end
62
+ local player = tear.Parent:ToPlayer()
63
+ return player ~= nil
64
+ end
27
65
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -268,7 +268,10 @@ export function getUnusedDoorSlots(): DoorSlot[] {
268
268
  const doorSlots = getEnumValues(DoorSlot);
269
269
  return doorSlots.filter(
270
270
  (doorSlot) =>
271
- room.IsDoorSlotAllowed(doorSlot) && room.GetDoor(doorSlot) === undefined,
271
+ // We need to filter out the -1 value to prevent crashes.
272
+ doorSlot !== DoorSlot.NO_DOOR_SLOT &&
273
+ room.IsDoorSlotAllowed(doorSlot) &&
274
+ room.GetDoor(doorSlot) === undefined,
272
275
  );
273
276
  }
274
277
 
@@ -31,3 +31,57 @@ export function getFireDelay(tearsStat: float): float {
31
31
  export function getTearsStat(fireDelay: float): float {
32
32
  return 30 / (fireDelay + 1);
33
33
  }
34
+
35
+ /**
36
+ * Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
37
+ * is determined by looking at the parent.
38
+ *
39
+ * For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
40
+ * player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
41
+ * and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
42
+ * callback or on frame 2+.
43
+ *
44
+ * If this function is called on frame 0 or frame 1, it will throw a run-time error.
45
+ */
46
+ export function isTearFromFamiliar(tear: EntityTear): boolean {
47
+ if (tear.FrameCount === 0 || tear.FrameCount === 1) {
48
+ error(
49
+ `Failed to check if the given tear was from a player since the tear's frame count was equal to ${tear.FrameCount}. (The "isTearFromFamiliar" function must only be used in the "POST_TEAR_INIT_VERY_LATE" callback or on frame 2 and onwards.)`,
50
+ );
51
+ }
52
+
53
+ // Normally, all tears have a parent, which is either the player or the familiar.
54
+ if (tear.Parent === undefined) {
55
+ return false;
56
+ }
57
+
58
+ const familiar = tear.Parent.ToFamiliar();
59
+ return familiar !== undefined;
60
+ }
61
+
62
+ /**
63
+ * Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
64
+ * is determined by looking at the parent.
65
+ *
66
+ * For the special case of Incubus and Blood Babies, the spawner entity of the tear is always the
67
+ * player. The parent of the tear is the player on frames 0 and 1 and it is the familiar on frames 2
68
+ * and onwards. For this reason, you can only use this function in the `POST_TEAR_INIT_VERY_LATE`
69
+ * callback or on frame 2+.
70
+ *
71
+ * If this function is called on frame 0 or frame 1, it will throw a run-time error.
72
+ */
73
+ export function isTearFromPlayer(tear: EntityTear): boolean {
74
+ if (tear.FrameCount === 0 || tear.FrameCount === 1) {
75
+ error(
76
+ `Failed to check if the given tear was from a player since the tear's frame count was equal to ${tear.FrameCount}. (The "isTearFromPlayer" function must only be used in the "POST_TEAR_INIT_VERY_LATE" callback or on frame 2 and onwards.)`,
77
+ );
78
+ }
79
+
80
+ // Normally, all tears have a parent, which is either the player or the familiar.
81
+ if (tear.Parent === undefined) {
82
+ return false;
83
+ }
84
+
85
+ const player = tear.Parent.ToPlayer();
86
+ return player !== undefined;
87
+ }