isaacscript-common 51.2.3 → 51.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.
@@ -75,7 +75,7 @@ import { RoomTransitionAnim } from 'isaac-typescript-definitions';
75
75
  import { RoomType } from 'isaac-typescript-definitions';
76
76
  import type { SackSubType } from 'isaac-typescript-definitions';
77
77
  import { SeedEffect } from 'isaac-typescript-definitions';
78
- import type { SlotVariant } from 'isaac-typescript-definitions';
78
+ import { SlotVariant } from 'isaac-typescript-definitions';
79
79
  import type { StageID } from 'isaac-typescript-definitions';
80
80
  import { StageType } from 'isaac-typescript-definitions';
81
81
  import { TearFlag } from 'isaac-typescript-definitions';
@@ -5628,6 +5628,9 @@ export declare function getFloorDisplayFlags(minimapAPI?: boolean): Map<int, Bit
5628
5628
  /**
5629
5629
  * Helper function to get the corresponding golden trinket type from a normal trinket type.
5630
5630
  *
5631
+ * If the provided trinket type is already a golden trinket type, then the trinket type will be
5632
+ * returned unmodified.
5633
+ *
5631
5634
  * For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
5632
5635
  * corresponds to the golden trinket sub-type for Swallowed Penny.
5633
5636
  */
@@ -6145,6 +6148,14 @@ export declare function getNormalPillColorFromHorse(pillColor: PillColor): PillC
6145
6148
  /** Helper function to get an array with every non-gold and non-horse pill color. */
6146
6149
  export declare function getNormalPillColors(): PillColor[];
6147
6150
 
6151
+ /**
6152
+ * Helper function to get the corresponding normal trinket type from a golden trinket type.
6153
+ *
6154
+ * If the provided trinket type is already a normal trinket type, then the trinket type will be
6155
+ * returned unmodified.
6156
+ */
6157
+ export declare function getNormalTrinketType(trinketType: TrinketType): TrinketType;
6158
+
6148
6159
  /**
6149
6160
  * Helper function to get all of the NPCs in the room.
6150
6161
  *
@@ -7427,6 +7438,17 @@ export declare function getShootActions(controllerIndex: ControllerIndex): Butto
7427
7438
  */
7428
7439
  export declare function getSirenHelper(familiar: EntityFamiliar): Entity | undefined;
7429
7440
 
7441
+ /**
7442
+ * Helper function to get the name of a slot, as listed in the "entities2.xml" file. Returns
7443
+ * "Unknown" if the provided slot variant is not valid.
7444
+ *
7445
+ * This function only works for vanilla slot variants.
7446
+ *
7447
+ * For example, `getSlotName(SlotVariant.BLOOD_DONATION_MACHINE)` would return "Blood Donation
7448
+ * Machine".
7449
+ */
7450
+ export declare function getSlotName(slotVariant: SlotVariant): string;
7451
+
7430
7452
  /**
7431
7453
  * Helper function to get all of the slots in the room.
7432
7454
  *
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 51.2.3
3
+ isaacscript-common 51.4.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -29740,6 +29740,7 @@ return ____exports
29740
29740
  end,
29741
29741
  ["src.functions.trinkets"] = function(...)
29742
29742
  local ____exports = {}
29743
+ local GOLDEN_TRINKET_ADJUSTMENT
29743
29744
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
29744
29745
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
29745
29746
  local ____cachedClasses = require("src.core.cachedClasses")
@@ -29768,15 +29769,18 @@ local ____sprites = require("src.functions.sprites")
29768
29769
  local clearSprite = ____sprites.clearSprite
29769
29770
  local ____types = require("src.functions.types")
29770
29771
  local asNumber = ____types.asNumber
29772
+ function ____exports.isGoldenTrinketType(self, trinketType)
29773
+ return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
29774
+ end
29771
29775
  function ____exports.isVanillaTrinketType(self, trinketType)
29772
29776
  return trinketType <= LAST_VANILLA_TRINKET_TYPE
29773
29777
  end
29774
- local GOLDEN_TRINKET_ADJUSTMENT = 32768
29778
+ GOLDEN_TRINKET_ADJUSTMENT = 32768
29775
29779
  local NUM_MYSTERIOUS_PAPER_EFFECTS = getEnumLength(nil, MysteriousPaperEffect)
29776
29780
  local TRINKET_ANM2_PATH = "gfx/005.350_trinket.anm2"
29777
29781
  local TRINKET_SPRITE_LAYER = 0
29778
29782
  function ____exports.getGoldenTrinketType(self, trinketType)
29779
- return asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
29783
+ return ____exports.isGoldenTrinketType(nil, trinketType) and trinketType or asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
29780
29784
  end
29781
29785
  function ____exports.getMysteriousPaperEffectForFrame(self, player, frameCount)
29782
29786
  if frameCount == nil then
@@ -29787,6 +29791,9 @@ function ____exports.getMysteriousPaperEffectForFrame(self, player, frameCount)
29787
29791
  end
29788
29792
  return frameCount % NUM_MYSTERIOUS_PAPER_EFFECTS
29789
29793
  end
29794
+ function ____exports.getNormalTrinketType(self, trinketType)
29795
+ return ____exports.isGoldenTrinketType(nil, trinketType) and asNumber(nil, trinketType) - GOLDEN_TRINKET_ADJUSTMENT or trinketType
29796
+ end
29790
29797
  function ____exports.getTrinketDescription(self, trinketType)
29791
29798
  local trinketDescription = TRINKET_DESCRIPTION_MAP:get(trinketType)
29792
29799
  if trinketDescription ~= nil then
@@ -29816,9 +29823,6 @@ function ____exports.getTrinketName(self, trinketType)
29816
29823
  end
29817
29824
  return DEFAULT_TRINKET_NAME
29818
29825
  end
29819
- function ____exports.isGoldenTrinketType(self, trinketType)
29820
- return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
29821
- end
29822
29826
  function ____exports.isModdedTrinketType(self, trinketType)
29823
29827
  return not ____exports.isVanillaTrinketType(nil, trinketType)
29824
29828
  end
@@ -39681,6 +39685,33 @@ function PlayerReorderedCallbacks.prototype.____constructor(self, postPEffectUpd
39681
39685
  self.postPlayerRenderReordered = postPlayerRenderReordered
39682
39686
  self.postPlayerUpdateReordered = postPlayerUpdateReordered
39683
39687
  end
39688
+ return ____exports
39689
+ end,
39690
+ ["src.objects.slotNames"] = function(...)
39691
+ local ____exports = {}
39692
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
39693
+ local SlotVariant = ____isaac_2Dtypescript_2Ddefinitions.SlotVariant
39694
+ ____exports.DEFAULT_SLOT_NAME = "Unknown"
39695
+ ____exports.SLOT_NAMES = {
39696
+ [SlotVariant.SLOT_MACHINE] = "Slot Machine",
39697
+ [SlotVariant.BLOOD_DONATION_MACHINE] = "Blood Donation Machine",
39698
+ [SlotVariant.FORTUNE_TELLING_MACHINE] = "Fortune Telling Machine",
39699
+ [SlotVariant.BEGGAR] = "Beggar",
39700
+ [SlotVariant.DEVIL_BEGGAR] = "Devil Beggar",
39701
+ [SlotVariant.SHELL_GAME] = "Shell Game",
39702
+ [SlotVariant.KEY_MASTER] = "Key Master",
39703
+ [SlotVariant.DONATION_MACHINE] = "Donation Machine",
39704
+ [SlotVariant.BOMB_BUM] = "Bomb Bum",
39705
+ [SlotVariant.SHOP_RESTOCK_MACHINE] = "Shop Restock Machine",
39706
+ [SlotVariant.GREED_DONATION_MACHINE] = "Greed Donation Machine",
39707
+ [SlotVariant.MOMS_DRESSING_TABLE] = "Mom's Dressing Table",
39708
+ [SlotVariant.BATTERY_BUM] = "Battery Bum",
39709
+ [SlotVariant.ISAAC_SECRET] = "Isaac (secret)",
39710
+ [SlotVariant.HELL_GAME] = "Hell Game",
39711
+ [SlotVariant.CRANE_GAME] = "Crane Game",
39712
+ [SlotVariant.CONFESSIONAL] = "Confessional",
39713
+ [SlotVariant.ROTTEN_BEGGAR] = "Rotten Beggar"
39714
+ }
39684
39715
  return ____exports
39685
39716
  end,
39686
39717
  ["src.functions.slots"] = function(...)
@@ -39689,6 +39720,9 @@ local __TS__New = ____lualib.__TS__New
39689
39720
  local ____exports = {}
39690
39721
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
39691
39722
  local SlotVariant = ____isaac_2Dtypescript_2Ddefinitions.SlotVariant
39723
+ local ____slotNames = require("src.objects.slotNames")
39724
+ local DEFAULT_SLOT_NAME = ____slotNames.DEFAULT_SLOT_NAME
39725
+ local SLOT_NAMES = ____slotNames.SLOT_NAMES
39692
39726
  local ____ReadonlySet = require("src.types.ReadonlySet")
39693
39727
  local ReadonlySet = ____ReadonlySet.ReadonlySet
39694
39728
  local ____entityTypes = require("src.functions.entityTypes")
@@ -39704,6 +39738,9 @@ local SLOT_MACHINE_VARIANTS = __TS__New(ReadonlySet, {
39704
39738
  SlotVariant.CRANE_GAME,
39705
39739
  SlotVariant.CONFESSIONAL
39706
39740
  })
39741
+ function ____exports.getSlotName(self, slotVariant)
39742
+ return SLOT_NAMES[slotVariant] or DEFAULT_SLOT_NAME
39743
+ end
39707
39744
  function ____exports.isSlotMachine(self, entity)
39708
39745
  if not isSlot(nil, entity) then
39709
39746
  return false
@@ -39921,6 +39958,7 @@ return ____exports
39921
39958
  local ____exports = {}
39922
39959
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
39923
39960
  local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
39961
+ ____exports.DEFAULT_CHEST_NAME = "Unknown"
39924
39962
  ____exports.CHEST_NAMES = {
39925
39963
  [PickupVariant.CHEST] = "Chest",
39926
39964
  [PickupVariant.BOMB_CHEST] = "Bomb Chest",
@@ -40394,6 +40432,7 @@ local BOMB_NAMES = ____bombNames.BOMB_NAMES
40394
40432
  local DEFAULT_BOMB_NAME = ____bombNames.DEFAULT_BOMB_NAME
40395
40433
  local ____chestNames = require("src.objects.chestNames")
40396
40434
  local CHEST_NAMES = ____chestNames.CHEST_NAMES
40435
+ local DEFAULT_CHEST_NAME = ____chestNames.DEFAULT_CHEST_NAME
40397
40436
  local ____coinNames = require("src.objects.coinNames")
40398
40437
  local COIN_NAMES = ____coinNames.COIN_NAMES
40399
40438
  local DEFAULT_COIN_NAME = ____coinNames.DEFAULT_COIN_NAME
@@ -40428,7 +40467,7 @@ function ____exports.getBombName(self, bombSubType)
40428
40467
  end
40429
40468
  function ____exports.getChestName(self, pickupVariant)
40430
40469
  local chestNames = CHEST_NAMES
40431
- return chestNames[pickupVariant] or "Unknown"
40470
+ return chestNames[pickupVariant] or DEFAULT_CHEST_NAME
40432
40471
  end
40433
40472
  function ____exports.getCoinName(self, coinSubType)
40434
40473
  return COIN_NAMES[coinSubType] or DEFAULT_COIN_NAME
@@ -11,6 +11,7 @@ local BOMB_NAMES = ____bombNames.BOMB_NAMES
11
11
  local DEFAULT_BOMB_NAME = ____bombNames.DEFAULT_BOMB_NAME
12
12
  local ____chestNames = require("src.objects.chestNames")
13
13
  local CHEST_NAMES = ____chestNames.CHEST_NAMES
14
+ local DEFAULT_CHEST_NAME = ____chestNames.DEFAULT_CHEST_NAME
14
15
  local ____coinNames = require("src.objects.coinNames")
15
16
  local COIN_NAMES = ____coinNames.COIN_NAMES
16
17
  local DEFAULT_COIN_NAME = ____coinNames.DEFAULT_COIN_NAME
@@ -64,7 +65,7 @@ end
64
65
  -- For example, `getChestName(PickupVariant.SPIKED_CHEST)` would return "Spiked Chest".
65
66
  function ____exports.getChestName(self, pickupVariant)
66
67
  local chestNames = CHEST_NAMES
67
- return chestNames[pickupVariant] or "Unknown"
68
+ return chestNames[pickupVariant] or DEFAULT_CHEST_NAME
68
69
  end
69
70
  --- Helper function to get the name of a coin, as listed in the "entities2.xml" file. Returns
70
71
  -- "Unknown" if the provided coin sub-type is not valid.
@@ -1,4 +1,14 @@
1
- /// <reference types="isaac-typescript-definitions" />
1
+ import { SlotVariant } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to get the name of a slot, as listed in the "entities2.xml" file. Returns
4
+ * "Unknown" if the provided slot variant is not valid.
5
+ *
6
+ * This function only works for vanilla slot variants.
7
+ *
8
+ * For example, `getSlotName(SlotVariant.BLOOD_DONATION_MACHINE)` would return "Blood Donation
9
+ * Machine".
10
+ */
11
+ export declare function getSlotName(slotVariant: SlotVariant): string;
2
12
  /** Returns true for the specific variants of `EntityType.SLOT` that are machines. */
3
13
  export declare function isSlotMachine(entity: Entity): boolean;
4
14
  //# sourceMappingURL=slots.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../../src/functions/slots.ts"],"names":[],"mappings":";AAgBA,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAMrD"}
1
+ {"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../../src/functions/slots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAiB3D;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAI5D;AAED,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAMrD"}
@@ -3,6 +3,9 @@ local __TS__New = ____lualib.__TS__New
3
3
  local ____exports = {}
4
4
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
5
5
  local SlotVariant = ____isaac_2Dtypescript_2Ddefinitions.SlotVariant
6
+ local ____slotNames = require("src.objects.slotNames")
7
+ local DEFAULT_SLOT_NAME = ____slotNames.DEFAULT_SLOT_NAME
8
+ local SLOT_NAMES = ____slotNames.SLOT_NAMES
6
9
  local ____ReadonlySet = require("src.types.ReadonlySet")
7
10
  local ReadonlySet = ____ReadonlySet.ReadonlySet
8
11
  local ____entityTypes = require("src.functions.entityTypes")
@@ -18,6 +21,16 @@ local SLOT_MACHINE_VARIANTS = __TS__New(ReadonlySet, {
18
21
  SlotVariant.CRANE_GAME,
19
22
  SlotVariant.CONFESSIONAL
20
23
  })
24
+ --- Helper function to get the name of a slot, as listed in the "entities2.xml" file. Returns
25
+ -- "Unknown" if the provided slot variant is not valid.
26
+ --
27
+ -- This function only works for vanilla slot variants.
28
+ --
29
+ -- For example, `getSlotName(SlotVariant.BLOOD_DONATION_MACHINE)` would return "Blood Donation
30
+ -- Machine".
31
+ function ____exports.getSlotName(self, slotVariant)
32
+ return SLOT_NAMES[slotVariant] or DEFAULT_SLOT_NAME
33
+ end
21
34
  --- Returns true for the specific variants of `EntityType.SLOT` that are machines.
22
35
  function ____exports.isSlotMachine(self, entity)
23
36
  if not isSlot(nil, entity) then
@@ -4,6 +4,9 @@ import { MysteriousPaperEffect } from "../enums/MysteriousPaperEffect";
4
4
  /**
5
5
  * Helper function to get the corresponding golden trinket type from a normal trinket type.
6
6
  *
7
+ * If the provided trinket type is already a golden trinket type, then the trinket type will be
8
+ * returned unmodified.
9
+ *
7
10
  * For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
8
11
  * corresponds to the golden trinket sub-type for Swallowed Penny.
9
12
  */
@@ -29,6 +32,13 @@ export declare function getGoldenTrinketType(trinketType: TrinketType): TrinketT
29
32
  * Default is the current frame.
30
33
  */
31
34
  export declare function getMysteriousPaperEffectForFrame(player: EntityPlayer, frameCount?: int): MysteriousPaperEffect | undefined;
35
+ /**
36
+ * Helper function to get the corresponding normal trinket type from a golden trinket type.
37
+ *
38
+ * If the provided trinket type is already a normal trinket type, then the trinket type will be
39
+ * returned unmodified.
40
+ */
41
+ export declare function getNormalTrinketType(trinketType: TrinketType): TrinketType;
32
42
  /**
33
43
  * Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
34
44
  * trinket type was not valid.
@@ -1 +1 @@
1
- {"version":3,"file":"trinkets.d.ts","sourceRoot":"","sources":["../../../src/functions/trinkets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AA8BvE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAE1E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,GAAG,GACf,qBAAqB,GAAG,SAAS,CAUnC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CActE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAOtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAc/D;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAYjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAiBN;AAED,6FAA6F;AAC7F,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,OAAO,CAOT"}
1
+ {"version":3,"file":"trinkets.d.ts","sourceRoot":"","sources":["../../../src/functions/trinkets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AA8BvE;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAI1E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,GAAG,GACf,qBAAqB,GAAG,SAAS,CAUnC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAI1E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CActE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAOtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAc/D;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAYjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAiBN;AAED,6FAA6F;AAC7F,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,OAAO,CAOT"}
@@ -1,4 +1,5 @@
1
1
  local ____exports = {}
2
+ local GOLDEN_TRINKET_ADJUSTMENT
2
3
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
4
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
4
5
  local ____cachedClasses = require("src.core.cachedClasses")
@@ -27,24 +28,25 @@ local ____sprites = require("src.functions.sprites")
27
28
  local clearSprite = ____sprites.clearSprite
28
29
  local ____types = require("src.functions.types")
29
30
  local asNumber = ____types.asNumber
31
+ function ____exports.isGoldenTrinketType(self, trinketType)
32
+ return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
33
+ end
30
34
  function ____exports.isVanillaTrinketType(self, trinketType)
31
35
  return trinketType <= LAST_VANILLA_TRINKET_TYPE
32
36
  end
33
- --- Add this to a `TrinketType` to get the corresponding golden trinket type.
34
- --
35
- -- Corresponds to the vanilla `PillColor.TRINKET_GOLDEN_FLAG` value.
36
- --
37
- -- 1 << 15
38
- local GOLDEN_TRINKET_ADJUSTMENT = 32768
37
+ GOLDEN_TRINKET_ADJUSTMENT = 32768
39
38
  local NUM_MYSTERIOUS_PAPER_EFFECTS = getEnumLength(nil, MysteriousPaperEffect)
40
39
  local TRINKET_ANM2_PATH = "gfx/005.350_trinket.anm2"
41
40
  local TRINKET_SPRITE_LAYER = 0
42
41
  --- Helper function to get the corresponding golden trinket type from a normal trinket type.
43
42
  --
43
+ -- If the provided trinket type is already a golden trinket type, then the trinket type will be
44
+ -- returned unmodified.
45
+ --
44
46
  -- For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
45
47
  -- corresponds to the golden trinket sub-type for Swallowed Penny.
46
48
  function ____exports.getGoldenTrinketType(self, trinketType)
47
- return asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
49
+ return ____exports.isGoldenTrinketType(nil, trinketType) and trinketType or asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
48
50
  end
49
51
  --- Helper function to get the current effect that the Mysterious Paper trinket is providing to the
50
52
  -- player. Returns undefined if the player does not have the Mysterious Paper trinket.
@@ -73,6 +75,13 @@ function ____exports.getMysteriousPaperEffectForFrame(self, player, frameCount)
73
75
  end
74
76
  return frameCount % NUM_MYSTERIOUS_PAPER_EFFECTS
75
77
  end
78
+ --- Helper function to get the corresponding normal trinket type from a golden trinket type.
79
+ --
80
+ -- If the provided trinket type is already a normal trinket type, then the trinket type will be
81
+ -- returned unmodified.
82
+ function ____exports.getNormalTrinketType(self, trinketType)
83
+ return ____exports.isGoldenTrinketType(nil, trinketType) and asNumber(nil, trinketType) - GOLDEN_TRINKET_ADJUSTMENT or trinketType
84
+ end
76
85
  --- Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
77
86
  -- trinket type was not valid.
78
87
  --
@@ -118,9 +127,6 @@ function ____exports.getTrinketName(self, trinketType)
118
127
  end
119
128
  return DEFAULT_TRINKET_NAME
120
129
  end
121
- function ____exports.isGoldenTrinketType(self, trinketType)
122
- return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
123
- end
124
130
  function ____exports.isModdedTrinketType(self, trinketType)
125
131
  return not ____exports.isVanillaTrinketType(nil, trinketType)
126
132
  end
@@ -1,3 +1,4 @@
1
+ export declare const DEFAULT_CHEST_NAME = "Unknown";
1
2
  /** Taken from "entities2.xml". */
2
3
  export declare const CHEST_NAMES: {
3
4
  readonly 50: "Chest";
@@ -1 +1 @@
1
- {"version":3,"file":"chestNames.d.ts","sourceRoot":"","sources":["../../../src/objects/chestNames.ts"],"names":[],"mappings":"AAGA,kCAAkC;AAClC,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAamD,CAAC"}
1
+ {"version":3,"file":"chestNames.d.ts","sourceRoot":"","sources":["../../../src/objects/chestNames.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C,kCAAkC;AAClC,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAamD,CAAC"}
@@ -1,6 +1,7 @@
1
1
  local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
4
+ ____exports.DEFAULT_CHEST_NAME = "Unknown"
4
5
  --- Taken from "entities2.xml".
5
6
  ____exports.CHEST_NAMES = {
6
7
  [PickupVariant.CHEST] = "Chest",
@@ -0,0 +1,23 @@
1
+ export declare const DEFAULT_SLOT_NAME = "Unknown";
2
+ /** Taken from "entities2.xml". */
3
+ export declare const SLOT_NAMES: {
4
+ readonly 1: "Slot Machine";
5
+ readonly 2: "Blood Donation Machine";
6
+ readonly 3: "Fortune Telling Machine";
7
+ readonly 4: "Beggar";
8
+ readonly 5: "Devil Beggar";
9
+ readonly 6: "Shell Game";
10
+ readonly 7: "Key Master";
11
+ readonly 8: "Donation Machine";
12
+ readonly 9: "Bomb Bum";
13
+ readonly 10: "Shop Restock Machine";
14
+ readonly 11: "Greed Donation Machine";
15
+ readonly 12: "Mom's Dressing Table";
16
+ readonly 13: "Battery Bum";
17
+ readonly 14: "Isaac (secret)";
18
+ readonly 15: "Hell Game";
19
+ readonly 16: "Crane Game";
20
+ readonly 17: "Confessional";
21
+ readonly 18: "Rotten Beggar";
22
+ };
23
+ //# sourceMappingURL=slotNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slotNames.d.ts","sourceRoot":"","sources":["../../../src/objects/slotNames.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,kCAAkC;AAClC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;CAmByB,CAAC"}
@@ -0,0 +1,26 @@
1
+ local ____exports = {}
2
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
+ local SlotVariant = ____isaac_2Dtypescript_2Ddefinitions.SlotVariant
4
+ ____exports.DEFAULT_SLOT_NAME = "Unknown"
5
+ --- Taken from "entities2.xml".
6
+ ____exports.SLOT_NAMES = {
7
+ [SlotVariant.SLOT_MACHINE] = "Slot Machine",
8
+ [SlotVariant.BLOOD_DONATION_MACHINE] = "Blood Donation Machine",
9
+ [SlotVariant.FORTUNE_TELLING_MACHINE] = "Fortune Telling Machine",
10
+ [SlotVariant.BEGGAR] = "Beggar",
11
+ [SlotVariant.DEVIL_BEGGAR] = "Devil Beggar",
12
+ [SlotVariant.SHELL_GAME] = "Shell Game",
13
+ [SlotVariant.KEY_MASTER] = "Key Master",
14
+ [SlotVariant.DONATION_MACHINE] = "Donation Machine",
15
+ [SlotVariant.BOMB_BUM] = "Bomb Bum",
16
+ [SlotVariant.SHOP_RESTOCK_MACHINE] = "Shop Restock Machine",
17
+ [SlotVariant.GREED_DONATION_MACHINE] = "Greed Donation Machine",
18
+ [SlotVariant.MOMS_DRESSING_TABLE] = "Mom's Dressing Table",
19
+ [SlotVariant.BATTERY_BUM] = "Battery Bum",
20
+ [SlotVariant.ISAAC_SECRET] = "Isaac (secret)",
21
+ [SlotVariant.HELL_GAME] = "Hell Game",
22
+ [SlotVariant.CRANE_GAME] = "Crane Game",
23
+ [SlotVariant.CONFESSIONAL] = "Confessional",
24
+ [SlotVariant.ROTTEN_BEGGAR] = "Rotten Beggar"
25
+ }
26
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "51.2.3",
3
+ "version": "51.4.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -10,7 +10,7 @@ import type {
10
10
  import { CHEST_PICKUP_VARIANTS_SET } from "../core/constants";
11
11
  import { BATTERY_NAMES, DEFAULT_BATTERY_NAME } from "../objects/batteryNames";
12
12
  import { BOMB_NAMES, DEFAULT_BOMB_NAME } from "../objects/bombNames";
13
- import { CHEST_NAMES } from "../objects/chestNames";
13
+ import { CHEST_NAMES, DEFAULT_CHEST_NAME } from "../objects/chestNames";
14
14
  import { COIN_NAMES, DEFAULT_COIN_NAME } from "../objects/coinNames";
15
15
  import {
16
16
  COIN_SUB_TYPE_TO_VALUE,
@@ -62,7 +62,7 @@ export function getBombName(bombSubType: BombSubType): string {
62
62
  */
63
63
  export function getChestName(pickupVariant: PickupVariant): string {
64
64
  const chestNames = CHEST_NAMES as Partial<Record<PickupVariant, string>>;
65
- return chestNames[pickupVariant] ?? "Unknown";
65
+ return chestNames[pickupVariant] ?? DEFAULT_CHEST_NAME;
66
66
  }
67
67
 
68
68
  /**
@@ -1,4 +1,5 @@
1
1
  import { SlotVariant } from "isaac-typescript-definitions";
2
+ import { DEFAULT_SLOT_NAME, SLOT_NAMES } from "../objects/slotNames";
2
3
  import { ReadonlySet } from "../types/ReadonlySet";
3
4
  import { isSlot } from "./entityTypes";
4
5
 
@@ -14,6 +15,21 @@ const SLOT_MACHINE_VARIANTS = new ReadonlySet<SlotVariant>([
14
15
  SlotVariant.CONFESSIONAL, // 17
15
16
  ]);
16
17
 
18
+ /**
19
+ * Helper function to get the name of a slot, as listed in the "entities2.xml" file. Returns
20
+ * "Unknown" if the provided slot variant is not valid.
21
+ *
22
+ * This function only works for vanilla slot variants.
23
+ *
24
+ * For example, `getSlotName(SlotVariant.BLOOD_DONATION_MACHINE)` would return "Blood Donation
25
+ * Machine".
26
+ */
27
+ export function getSlotName(slotVariant: SlotVariant): string {
28
+ // Handle modded slots.
29
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
30
+ return SLOT_NAMES[slotVariant] ?? DEFAULT_SLOT_NAME;
31
+ }
32
+
17
33
  /** Returns true for the specific variants of `EntityType.SLOT` that are machines. */
18
34
  export function isSlotMachine(entity: Entity): boolean {
19
35
  if (!isSlot(entity)) {
@@ -36,11 +36,16 @@ const TRINKET_SPRITE_LAYER = 0;
36
36
  /**
37
37
  * Helper function to get the corresponding golden trinket type from a normal trinket type.
38
38
  *
39
+ * If the provided trinket type is already a golden trinket type, then the trinket type will be
40
+ * returned unmodified.
41
+ *
39
42
  * For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
40
43
  * corresponds to the golden trinket sub-type for Swallowed Penny.
41
44
  */
42
45
  export function getGoldenTrinketType(trinketType: TrinketType): TrinketType {
43
- return asNumber(trinketType) + GOLDEN_TRINKET_ADJUSTMENT;
46
+ return isGoldenTrinketType(trinketType)
47
+ ? trinketType
48
+ : asNumber(trinketType) + GOLDEN_TRINKET_ADJUSTMENT;
44
49
  }
45
50
 
46
51
  /**
@@ -78,6 +83,18 @@ export function getMysteriousPaperEffectForFrame(
78
83
  return frameCount % NUM_MYSTERIOUS_PAPER_EFFECTS;
79
84
  }
80
85
 
86
+ /**
87
+ * Helper function to get the corresponding normal trinket type from a golden trinket type.
88
+ *
89
+ * If the provided trinket type is already a normal trinket type, then the trinket type will be
90
+ * returned unmodified.
91
+ */
92
+ export function getNormalTrinketType(trinketType: TrinketType): TrinketType {
93
+ return isGoldenTrinketType(trinketType)
94
+ ? asNumber(trinketType) - GOLDEN_TRINKET_ADJUSTMENT
95
+ : trinketType;
96
+ }
97
+
81
98
  /**
82
99
  * Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
83
100
  * trinket type was not valid.
@@ -1,6 +1,8 @@
1
1
  import { PickupVariant } from "isaac-typescript-definitions";
2
2
  import type { CHEST_PICKUP_VARIANTS } from "../core/constants";
3
3
 
4
+ export const DEFAULT_CHEST_NAME = "Unknown";
5
+
4
6
  /** Taken from "entities2.xml". */
5
7
  export const CHEST_NAMES = {
6
8
  [PickupVariant.CHEST]: "Chest", // 50
@@ -0,0 +1,25 @@
1
+ import { SlotVariant } from "isaac-typescript-definitions";
2
+
3
+ export const DEFAULT_SLOT_NAME = "Unknown";
4
+
5
+ /** Taken from "entities2.xml". */
6
+ export const SLOT_NAMES = {
7
+ [SlotVariant.SLOT_MACHINE]: "Slot Machine", // 1
8
+ [SlotVariant.BLOOD_DONATION_MACHINE]: "Blood Donation Machine", // 2
9
+ [SlotVariant.FORTUNE_TELLING_MACHINE]: "Fortune Telling Machine", // 3
10
+ [SlotVariant.BEGGAR]: "Beggar", // 4
11
+ [SlotVariant.DEVIL_BEGGAR]: "Devil Beggar", // 5
12
+ [SlotVariant.SHELL_GAME]: "Shell Game", // 6
13
+ [SlotVariant.KEY_MASTER]: "Key Master", // 7
14
+ [SlotVariant.DONATION_MACHINE]: "Donation Machine", // 8
15
+ [SlotVariant.BOMB_BUM]: "Bomb Bum", // 9
16
+ [SlotVariant.SHOP_RESTOCK_MACHINE]: "Shop Restock Machine", // 10
17
+ [SlotVariant.GREED_DONATION_MACHINE]: "Greed Donation Machine", // 11
18
+ [SlotVariant.MOMS_DRESSING_TABLE]: "Mom's Dressing Table", // 12
19
+ [SlotVariant.BATTERY_BUM]: "Battery Bum", // 13
20
+ [SlotVariant.ISAAC_SECRET]: "Isaac (secret)", // 14
21
+ [SlotVariant.HELL_GAME]: "Hell Game", // 15
22
+ [SlotVariant.CRANE_GAME]: "Crane Game", // 16
23
+ [SlotVariant.CONFESSIONAL]: "Confessional", // 17
24
+ [SlotVariant.ROTTEN_BEGGAR]: "Rotten Beggar", // 18
25
+ } as const satisfies Record<SlotVariant, string>;