isaacscript-common 1.2.105 → 1.2.108

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.
@@ -41,13 +41,7 @@ function checkPickupsPurchased(self, pickups, players)
41
41
  v.room.pickupMap:delete(index)
42
42
  local player = getPlayerThatIsNoLongerHoldingAnItem(nil, players)
43
43
  if player ~= nil then
44
- postPurchaseFire(
45
- nil,
46
- player,
47
- pickupDescription.variant,
48
- pickupDescription.subType,
49
- pickupDescription.price
50
- )
44
+ postPurchaseFire(nil, player, pickupDescription)
51
45
  end
52
46
  end
53
47
  ::__continue7::
@@ -70,7 +64,14 @@ function storePickupsInMap(self, pickups)
70
64
  function(____, pickup) return pickup.Price ~= 0 end
71
65
  )
72
66
  for ____, pickup in ipairs(pickupsWithPrice) do
73
- v.room.pickupMap:set(pickup.Index, {variant = pickup.Variant, subType = pickup.SubType, price = pickup.Price})
67
+ v.room.pickupMap:set(pickup.Index, {
68
+ variant = pickup.Variant,
69
+ subType = pickup.SubType,
70
+ position = pickup.Position,
71
+ velocity = pickup.Velocity,
72
+ price = pickup.Price,
73
+ initSeed = pickup.InitSeed
74
+ })
74
75
  end
75
76
  end
76
77
  function storePlayersInMap(self, players)
@@ -1,2 +1,3 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- export declare type PostPurchaseCallbackType = (player: EntityPlayer, pickupVariant: PickupVariant | int, pickupSubType: int, pickupPrice: int) => void;
2
+ import { PickupDescription } from "../../types/PickupDescription";
3
+ export declare type PostPurchaseCallbackType = (player: EntityPlayer, pickupDescription: PickupDescription) => void;
@@ -9,16 +9,10 @@ end
9
9
  function ____exports.postPurchaseRegister(self, callback, pickupVariant, pickupSubType)
10
10
  __TS__ArrayPush(subscriptions, {callback, pickupVariant, pickupSubType})
11
11
  end
12
- function ____exports.postPurchaseFire(self, player, pickupVariant, pickupSubType, pickupPrice)
12
+ function ____exports.postPurchaseFire(self, player, pickupDescription)
13
13
  for ____, ____value in ipairs(subscriptions) do
14
14
  local callback = ____value[1]
15
- callback(
16
- nil,
17
- player,
18
- pickupVariant,
19
- pickupSubType,
20
- pickupPrice
21
- )
15
+ callback(nil, player, pickupDescription)
22
16
  end
23
17
  end
24
18
  return ____exports
@@ -1,5 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  export declare function collectibleHasTag(collectibleType: CollectibleType | int, tag: ItemConfigTag): boolean;
3
+ export declare function clearCollectibleSprite(collectible: EntityPickup): void;
3
4
  export declare function collectibleHasCacheFlag(collectibleType: CollectibleType | int, cacheFlag: CacheFlag): boolean;
4
5
  /**
5
6
  * Helper function to get the in-game description for a collectible. Returns "Unknown" if the
@@ -98,24 +99,24 @@ export declare function setCollectiblesRerolledForItemTracker(): void;
98
99
  export declare function setCollectibleBlind(collectible: EntityPickup): void;
99
100
  /**
100
101
  * Helper function to remove the collectible from a collectible pedestal and make it appear as if a
101
- * player has already taken the item. This is accomplished by setting its sprite to an empty/missing
102
- * PNG file.
102
+ * player has already taken the item. This is accomplished by changing the sub-type to
103
+ * `CollectibleType.COLLECTIBLE_NULL` and then setting the sprite to an empty/missing PNG file.
103
104
  *
104
- * For more information, see the documentation for the "emptySprite" helper function.
105
+ * For more information, see the documentation for the "clearSprite" helper function.
105
106
  */
106
107
  export declare function setCollectibleEmpty(collectible: EntityPickup): void;
107
108
  /**
108
109
  * Helper function to change the sprite of a collectible pedestal entity.
109
110
  *
110
111
  * For more information about removing the collectible sprite, see the documentation for the
111
- * "emptySprite" helper function.
112
+ * "clearSprite" helper function.
112
113
  *
113
114
  * @param collectible The collectible whose sprite you want to modify.
114
- * @param pngPath Optional. Equal to the spritesheet path to load (e.g.
115
- * "gfx/items/collectibles/collectibles_001_thesadonion.png"). If not specified, will remove the
116
- * sprite, making it appear like the collectible has already been taken by the player.
115
+ * @param pngPath Equal to either the spritesheet path to load (e.g.
116
+ * "gfx/items/collectibles/collectibles_001_thesadonion.png") or undefined. If undefined, the sprite
117
+ * will be removed, making it appear like the collectible has already been taken by the player.
117
118
  */
118
- export declare function setCollectibleSprite(collectible: EntityPickup, pngPath?: string): void;
119
+ export declare function setCollectibleSprite(collectible: EntityPickup, pngPath: string | undefined): void;
119
120
  /**
120
121
  * Helper function to change the collectible on a pedestal. Simply updating the SubType property is
121
122
  * not sufficient because the sprite will not change.
@@ -38,6 +38,9 @@ function ____exports.collectibleHasTag(self, collectibleType, tag)
38
38
  end
39
39
  return itemConfigItem:HasTags(tag)
40
40
  end
41
+ function ____exports.clearCollectibleSprite(self, collectible)
42
+ ____exports.setCollectibleSprite(nil, collectible, nil)
43
+ end
41
44
  function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
42
45
  local itemConfig = Isaac.GetItemConfig()
43
46
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
@@ -185,7 +188,7 @@ function ____exports.setCollectibleEmpty(self, collectible)
185
188
  error("You cannot set a collectible to be empty for pickups of variant: " .. tostring(collectible.Variant))
186
189
  end
187
190
  collectible.SubType = CollectibleType.COLLECTIBLE_NULL
188
- ____exports.setCollectibleSprite(nil, collectible)
191
+ ____exports.clearCollectibleSprite(nil, collectible)
189
192
  end
190
193
  function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
191
194
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
@@ -17,7 +17,6 @@ local CHARACTERS_WITH_FREE_DEVIL_DEALS = ____constants.CHARACTERS_WITH_FREE_DEVI
17
17
  local CHARACTERS_WITH_NO_RED_HEARTS = ____constants.CHARACTERS_WITH_NO_RED_HEARTS
18
18
  local CHARACTERS_WITH_NO_SOUL_HEARTS = ____constants.CHARACTERS_WITH_NO_SOUL_HEARTS
19
19
  local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
20
- local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
21
20
  local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
22
21
  local ____HealthType = require("types.HealthType")
23
22
  local HealthType = ____HealthType.HealthType
@@ -56,6 +55,12 @@ function ____exports.getCharacterMaxHeartContainers(self, character)
56
55
  if character == PlayerType.PLAYER_KEEPER then
57
56
  return 3
58
57
  end
58
+ if character == PlayerType.PLAYER_THEFORGOTTEN then
59
+ return 6
60
+ end
61
+ if character == PlayerType.PLAYER_THESOUL then
62
+ return 6
63
+ end
59
64
  if character == PlayerType.PLAYER_KEEPER_B then
60
65
  return 2
61
66
  end
@@ -91,15 +96,15 @@ end
91
96
  function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
92
97
  local character = player:GetPlayerType()
93
98
  repeat
94
- local ____switch66 = character
95
- local ____cond66 = ____switch66 == PlayerType.PLAYER_THESOUL
96
- if ____cond66 then
99
+ local ____switch68 = character
100
+ local ____cond68 = ____switch68 == PlayerType.PLAYER_THESOUL
101
+ if ____cond68 then
97
102
  do
98
103
  return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
99
104
  end
100
105
  end
101
- ____cond66 = ____cond66 or ____switch66 == PlayerType.PLAYER_LAZARUS2_B
102
- if ____cond66 then
106
+ ____cond68 = ____cond68 or ____switch68 == PlayerType.PLAYER_LAZARUS2_B
107
+ if ____cond68 then
103
108
  do
104
109
  return CollectibleType.COLLECTIBLE_INNER_EYE
105
110
  end
@@ -113,53 +118,56 @@ function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSo
113
118
  end
114
119
  function ____exports.getPlayerMaxHeartContainers(self, player)
115
120
  local character = player:GetPlayerType()
116
- local maxHeartContainers = ____exports.getCharacterMaxHeartContainers(nil, character)
121
+ local characterMaxHeartContainers = ____exports.getCharacterMaxHeartContainers(nil, character)
117
122
  if character == PlayerType.PLAYER_MAGDALENE and player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT) then
118
- maxHeartContainers = maxHeartContainers + 6
123
+ local extraMaxHeartContainersFromBirthright = 6
124
+ return characterMaxHeartContainers + extraMaxHeartContainersFromBirthright
119
125
  end
120
- local numMothersKisses = player:GetTrinketMultiplier(TrinketType.TRINKET_MOTHERS_KISS)
121
- maxHeartContainers = maxHeartContainers + numMothersKisses
122
- if maxHeartContainers > MAX_PLAYER_HEART_CONTAINERS then
123
- maxHeartContainers = MAX_PLAYER_HEART_CONTAINERS
126
+ if ____exports.isKeeper(nil, player) then
127
+ local numMothersKisses = player:GetTrinketMultiplier(TrinketType.TRINKET_MOTHERS_KISS)
128
+ local hasGreedsGullet = player:HasCollectible(CollectibleType.COLLECTIBLE_GREEDS_GULLET)
129
+ local coins = player:GetNumCoins()
130
+ local greedsGulletCoinContainers = hasGreedsGullet and math.floor(coins / 25) or 0
131
+ return characterMaxHeartContainers + numMothersKisses + greedsGulletCoinContainers
124
132
  end
125
- return maxHeartContainers
133
+ return characterMaxHeartContainers
126
134
  end
127
135
  function getAdjustedPlayerName(self, player)
128
136
  local character = player:GetPlayerType()
129
137
  repeat
130
- local ____switch79 = character
131
- local ____cond79 = ____switch79 == PlayerType.PLAYER_BLUEBABY or ____switch79 == PlayerType.PLAYER_BLUEBABY_B
132
- if ____cond79 then
138
+ local ____switch81 = character
139
+ local ____cond81 = ____switch81 == PlayerType.PLAYER_BLUEBABY or ____switch81 == PlayerType.PLAYER_BLUEBABY_B
140
+ if ____cond81 then
133
141
  do
134
142
  return "Blue Baby"
135
143
  end
136
144
  end
137
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_LAZARUS2
138
- if ____cond79 then
145
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_LAZARUS2
146
+ if ____cond81 then
139
147
  do
140
148
  return "Lazarus II"
141
149
  end
142
150
  end
143
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_BLACKJUDAS
144
- if ____cond79 then
151
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_BLACKJUDAS
152
+ if ____cond81 then
145
153
  do
146
154
  return "Dark Judas"
147
155
  end
148
156
  end
149
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_JACOB
150
- if ____cond79 then
157
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_JACOB
158
+ if ____cond81 then
151
159
  do
152
160
  return "Jacob & Esau"
153
161
  end
154
162
  end
155
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_LAZARUS2_B
156
- if ____cond79 then
163
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_LAZARUS2_B
164
+ if ____cond81 then
157
165
  do
158
166
  return "Dead Tainted Lazarus"
159
167
  end
160
168
  end
161
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_JACOB2_B
162
- if ____cond79 then
169
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_JACOB2_B
170
+ if ____cond81 then
163
171
  do
164
172
  return "Dead Tainted Jacob"
165
173
  end
@@ -207,6 +215,10 @@ end
207
215
  function ____exports.isChildPlayer(self, player)
208
216
  return player.Parent ~= nil
209
217
  end
218
+ function ____exports.isKeeper(self, player)
219
+ local character = player:GetPlayerType()
220
+ return character == PlayerType.PLAYER_KEEPER or character == PlayerType.PLAYER_KEEPER_B
221
+ end
210
222
  function ____exports.isTainted(self, player)
211
223
  local character = player:GetPlayerType()
212
224
  local ____isVanillaCharacter_result_1
@@ -532,10 +544,6 @@ function ____exports.isJacobOrEsau(self, player)
532
544
  local character = player:GetPlayerType()
533
545
  return character == PlayerType.PLAYER_JACOB or character == PlayerType.PLAYER_ESAU
534
546
  end
535
- function ____exports.isKeeper(self, player)
536
- local character = player:GetPlayerType()
537
- return character == PlayerType.PLAYER_KEEPER or character == PlayerType.PLAYER_KEEPER_B
538
- end
539
547
  function ____exports.isLost(self, player)
540
548
  local character = player:GetPlayerType()
541
549
  return character == PlayerType.PLAYER_THELOST or character == PlayerType.PLAYER_THELOST_B
@@ -589,9 +597,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
589
597
  itemPool:RemoveCollectible(collectibleType)
590
598
  end
591
599
  repeat
592
- local ____switch125 = activeSlot
593
- local ____cond125 = ____switch125 == ActiveSlot.SLOT_PRIMARY
594
- if ____cond125 then
600
+ local ____switch127 = activeSlot
601
+ local ____cond127 = ____switch127 == ActiveSlot.SLOT_PRIMARY
602
+ if ____cond127 then
595
603
  do
596
604
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
597
605
  player:RemoveCollectible(primaryCollectibleType)
@@ -600,8 +608,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
600
608
  break
601
609
  end
602
610
  end
603
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_SECONDARY
604
- if ____cond125 then
611
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_SECONDARY
612
+ if ____cond127 then
605
613
  do
606
614
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
607
615
  player:RemoveCollectible(primaryCollectibleType)
@@ -616,16 +624,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
616
624
  break
617
625
  end
618
626
  end
619
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_POCKET
620
- if ____cond125 then
627
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_POCKET
628
+ if ____cond127 then
621
629
  do
622
630
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
623
631
  player:SetActiveCharge(charge, activeSlot)
624
632
  break
625
633
  end
626
634
  end
627
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_POCKET2
628
- if ____cond125 then
635
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_POCKET2
636
+ if ____cond127 then
629
637
  do
630
638
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
631
639
  break
@@ -178,9 +178,9 @@ export declare function inMegaSatanRoom(): boolean;
178
178
  */
179
179
  export declare function inMinibossRoomOf(minibossID: MinibossID): boolean;
180
180
  /**
181
- * Helper function for checking if the room room is a secret shop from the Member Card collectible.
181
+ * Helper function for checking if the room is a secret shop (from the Member Card collectible).
182
182
  *
183
- * Secret shops are simply copies of normal shops but with the backdrop of a secret room. In other
183
+ * Secret shops are simply copies of normal shops, but with the backdrop of a secret room. In other
184
184
  * words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus,
185
185
  * the only way to detect them is by using the grid index.
186
186
  */
@@ -13,3 +13,12 @@
13
13
  * Tainted Keeper. False by default.
14
14
  */
15
15
  export declare function spawnCollectible(collectibleType: CollectibleType | int, position: Vector, seed?: number, options?: boolean, forceFreeItem?: boolean): EntityPickup;
16
+ /**
17
+ * Helper function to spawn an empty collectible. Doing this is tricky since spawning a collectible
18
+ * with `CollectibleType.COLLECTIBLE_NULL` will result in spawning a collectible with a random type
19
+ * from the current room's item pool.
20
+ *
21
+ * Instead, this function arbitrarily spawns a collectible with
22
+ * `CollectibleType.COLLECTIBLE_SAD_ONION`, and then converts it to an empty pedestal afterward.
23
+ */
24
+ export declare function spawnEmptyCollectible(position: Vector, seed?: number): void;
@@ -6,6 +6,7 @@ local ____featuresInitialized = require("featuresInitialized")
6
6
  local areFeaturesInitialized = ____featuresInitialized.areFeaturesInitialized
7
7
  local ____collectibles = require("functions.collectibles")
8
8
  local isQuestCollectible = ____collectibles.isQuestCollectible
9
+ local setCollectibleEmpty = ____collectibles.setCollectibleEmpty
9
10
  local ____player = require("functions.player")
10
11
  local anyPlayerIs = ____player.anyPlayerIs
11
12
  function ____exports.spawnCollectible(self, collectibleType, position, seed, options, forceFreeItem)
@@ -46,4 +47,18 @@ function ____exports.spawnCollectible(self, collectibleType, position, seed, opt
46
47
  end
47
48
  return collectible
48
49
  end
50
+ function ____exports.spawnEmptyCollectible(self, position, seed)
51
+ if seed == nil then
52
+ seed = Random()
53
+ end
54
+ local collectible = ____exports.spawnCollectible(
55
+ nil,
56
+ CollectibleType.COLLECTIBLE_SAD_ONION,
57
+ position,
58
+ seed,
59
+ false,
60
+ true
61
+ )
62
+ setCollectibleEmpty(nil, collectible)
63
+ end
49
64
  return ____exports
package/dist/index.d.ts CHANGED
@@ -90,6 +90,7 @@ export * from "./types/JSONSpawn";
90
90
  export * from "./types/ModCallbacksCustom";
91
91
  export * from "./types/ModUpgraded";
92
92
  export * from "./types/PickingUpItem";
93
+ export * from "./types/PickupDescription";
93
94
  export * from "./types/PillEffectClass";
94
95
  export * from "./types/PillEffectType";
95
96
  export * from "./types/PlayerHealth";
@@ -0,0 +1,9 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export interface PickupDescription {
3
+ variant: PickupVariant | int;
4
+ subType: int;
5
+ position: Vector;
6
+ velocity: Vector;
7
+ price: int;
8
+ initSeed: int;
9
+ }
@@ -0,0 +1,3 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.105",
3
+ "version": "1.2.108",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",