isaacscript-common 1.0.485 → 1.0.489

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 (139) hide show
  1. package/README.md +2 -0
  2. package/dist/callbacks/itemPickup.lua +2 -6
  3. package/dist/callbacks/postBombInitLate.lua +6 -8
  4. package/dist/callbacks/postCursedTeleport.lua +8 -10
  5. package/dist/callbacks/postEffectInitLate.lua +6 -8
  6. package/dist/callbacks/postEsauJr.lua +2 -4
  7. package/dist/callbacks/postFamiliarInitLate.lua +6 -8
  8. package/dist/callbacks/postFlip.lua +2 -4
  9. package/dist/callbacks/postGridEntity.lua +8 -18
  10. package/dist/callbacks/postKnifeInitLate.lua +6 -8
  11. package/dist/callbacks/postLaserInitLate.lua +6 -8
  12. package/dist/callbacks/postNPCInitLate.lua +6 -8
  13. package/dist/callbacks/postPickupCollect.lua +1 -5
  14. package/dist/callbacks/postPickupInitLate.lua +6 -8
  15. package/dist/callbacks/postPlayerChangeHealth.lua +9 -13
  16. package/dist/callbacks/postPlayerChangeType.lua +1 -5
  17. package/dist/callbacks/postPlayerFatalDamage.lua +2 -2
  18. package/dist/callbacks/postPlayerInitLate.lua +1 -5
  19. package/dist/callbacks/postPlayerReordered.lua +1 -1
  20. package/dist/callbacks/postProjectileInitLate.lua +6 -8
  21. package/dist/callbacks/postPurchase.lua +10 -14
  22. package/dist/callbacks/postSacrifice.lua +3 -3
  23. package/dist/callbacks/postSlotInitUpdate.lua +3 -11
  24. package/dist/callbacks/postSlotRenderBroken.lua +2 -8
  25. package/dist/callbacks/postTearInitLate.lua +6 -8
  26. package/dist/callbacks/postTransformation.lua +1 -5
  27. package/dist/callbacks/reorderedCallbacks.lua +4 -4
  28. package/dist/callbacks/subscriptions/postBombInitLate.lua +3 -3
  29. package/dist/callbacks/subscriptions/postCursedTeleport.lua +1 -1
  30. package/dist/callbacks/subscriptions/postCustomRevive.lua +3 -3
  31. package/dist/callbacks/subscriptions/postEffectInitLate.lua +3 -3
  32. package/dist/callbacks/subscriptions/postEsauJr.lua +1 -1
  33. package/dist/callbacks/subscriptions/postFamiliarInitLate.lua +3 -3
  34. package/dist/callbacks/subscriptions/postFirstEsauJr.lua +1 -1
  35. package/dist/callbacks/subscriptions/postFirstFlip.lua +1 -1
  36. package/dist/callbacks/subscriptions/postFlip.lua +1 -1
  37. package/dist/callbacks/subscriptions/postGameStartedReordered.lua +1 -1
  38. package/dist/callbacks/subscriptions/postGridEntityInit.lua +3 -3
  39. package/dist/callbacks/subscriptions/postGridEntityRemove.lua +3 -3
  40. package/dist/callbacks/subscriptions/postGridEntityUpdate.lua +3 -3
  41. package/dist/callbacks/subscriptions/postItemPickup.lua +5 -5
  42. package/dist/callbacks/subscriptions/postKnifeInitLate.lua +3 -3
  43. package/dist/callbacks/subscriptions/postLaserInitLate.lua +3 -3
  44. package/dist/callbacks/subscriptions/postNPCInitLate.lua +3 -3
  45. package/dist/callbacks/subscriptions/postNewLevelReordered.lua +1 -1
  46. package/dist/callbacks/subscriptions/postNewRoomReordered.lua +1 -1
  47. package/dist/callbacks/subscriptions/postPickupCollect.lua +3 -3
  48. package/dist/callbacks/subscriptions/postPickupInitLate.lua +3 -3
  49. package/dist/callbacks/subscriptions/postPlayerChangeHealth.lua +3 -3
  50. package/dist/callbacks/subscriptions/postPlayerChangeType.lua +1 -1
  51. package/dist/callbacks/subscriptions/postPlayerFatalDamage.lua +3 -3
  52. package/dist/callbacks/subscriptions/postPlayerInitLate.lua +3 -3
  53. package/dist/callbacks/subscriptions/postPlayerInitReordered.lua +3 -3
  54. package/dist/callbacks/subscriptions/postPlayerRenderReordered.lua +3 -3
  55. package/dist/callbacks/subscriptions/postPlayerUpdateReordered.lua +3 -3
  56. package/dist/callbacks/subscriptions/postProjectileInitLate.lua +3 -3
  57. package/dist/callbacks/subscriptions/postPurchase.lua +8 -2
  58. package/dist/callbacks/subscriptions/postSacrifice.lua +1 -1
  59. package/dist/callbacks/subscriptions/postSlotDestroyed.lua +3 -3
  60. package/dist/callbacks/subscriptions/postSlotInit.lua +3 -3
  61. package/dist/callbacks/subscriptions/postSlotRender.lua +3 -3
  62. package/dist/callbacks/subscriptions/postSlotUpdate.lua +3 -3
  63. package/dist/callbacks/subscriptions/postTearInitLate.lua +3 -3
  64. package/dist/callbacks/subscriptions/postTransformation.lua +3 -3
  65. package/dist/callbacks/subscriptions/preCustomRevive.lua +1 -1
  66. package/dist/callbacks/subscriptions/preItemPickup.lua +5 -5
  67. package/dist/constants.d.ts +0 -6
  68. package/dist/constants.lua +38 -6
  69. package/dist/features/deployJSONRoom.lua +90 -61
  70. package/dist/features/disableInputs.lua +9 -3
  71. package/dist/features/forgottenSwitch.lua +1 -1
  72. package/dist/features/getCollectibleItemPoolType.lua +10 -14
  73. package/dist/features/preventCollectibleRotate.lua +3 -9
  74. package/dist/features/saveDataManager/load.lua +2 -6
  75. package/dist/features/saveDataManager/main.lua +1 -1
  76. package/dist/features/saveDataManager/merge.lua +2 -4
  77. package/dist/features/sirenHelpers.lua +5 -5
  78. package/dist/functions/array.d.ts +19 -7
  79. package/dist/functions/array.lua +32 -19
  80. package/dist/functions/bitwise.lua +1 -1
  81. package/dist/functions/cards.d.ts +15 -9
  82. package/dist/functions/cards.lua +40 -30
  83. package/dist/functions/charge.lua +10 -12
  84. package/dist/functions/collectibles.d.ts +1 -0
  85. package/dist/functions/collectibles.lua +26 -21
  86. package/dist/functions/color.lua +9 -1
  87. package/dist/functions/deepCopy.lua +42 -22
  88. package/dist/functions/deepCopyTests.lua +12 -20
  89. package/dist/functions/doors.lua +7 -19
  90. package/dist/functions/entity.lua +7 -1
  91. package/dist/functions/flag.lua +1 -1
  92. package/dist/functions/gridEntity.lua +15 -10
  93. package/dist/functions/input.lua +14 -18
  94. package/dist/functions/jsonRoom.lua +3 -9
  95. package/dist/functions/language.lua +9 -1
  96. package/dist/functions/log.lua +18 -46
  97. package/dist/functions/math.lua +15 -17
  98. package/dist/functions/npc.lua +15 -17
  99. package/dist/functions/pickups.d.ts +7 -2
  100. package/dist/functions/pickups.lua +19 -3
  101. package/dist/functions/player.d.ts +0 -43
  102. package/dist/functions/player.lua +37 -137
  103. package/dist/functions/playerHealth.lua +19 -9
  104. package/dist/functions/pocketItems.d.ts +16 -14
  105. package/dist/functions/pocketItems.lua +56 -30
  106. package/dist/functions/random.lua +2 -2
  107. package/dist/functions/revive.lua +4 -4
  108. package/dist/functions/rooms.lua +15 -18
  109. package/dist/functions/spawnCollectible.lua +10 -2
  110. package/dist/functions/sprite.lua +2 -2
  111. package/dist/functions/stage.lua +6 -6
  112. package/dist/functions/tears.lua +1 -1
  113. package/dist/functions/transformations.lua +4 -10
  114. package/dist/functions/trinketGive.lua +2 -2
  115. package/dist/functions/trinkets.d.ts +23 -1
  116. package/dist/functions/trinkets.lua +24 -0
  117. package/dist/functions/ui.lua +3 -3
  118. package/dist/functions/util.lua +4 -8
  119. package/dist/functions/vector.lua +8 -8
  120. package/dist/index.d.ts +4 -0
  121. package/dist/index.lua +32 -0
  122. package/dist/lualib_bundle.lua +603 -555
  123. package/dist/maps/cardDescriptionMap.lua +99 -1
  124. package/dist/maps/cardNameMap.lua +99 -1
  125. package/dist/maps/collectibleDescriptionMap.lua +722 -1
  126. package/dist/maps/collectibleNameMap.lua +722 -1
  127. package/dist/maps/gridEntityXMLMap.d.ts +6 -0
  128. package/dist/maps/gridEntityXMLMap.lua +40 -0
  129. package/dist/maps/pillEffectNameMap.lua +52 -1
  130. package/dist/maps/roomTypeToItemPoolMap.d.ts +2 -0
  131. package/dist/maps/roomTypeToItemPoolMap.lua +19 -0
  132. package/dist/maps/transformationMap.lua +19 -12
  133. package/dist/maps/trinketDescriptionMap.lua +190 -1
  134. package/dist/maps/trinketNameMap.lua +190 -1
  135. package/dist/sets/cards.d.ts +25 -0
  136. package/dist/sets/cards.lua +106 -0
  137. package/dist/types/ModUpgraded.lua +82 -166
  138. package/dist/types/PocketItemDescription.d.ts +1 -0
  139. package/package.json +5 -5
@@ -1,6 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { HealthType } from "../types/HealthType";
3
- import { PocketItemDescription } from "../types/PocketItemDescription";
4
3
  /**
5
4
  * PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
6
5
  * function. Mods can signify that data structures handle EntityPlayers by using this type:
@@ -47,20 +46,6 @@ export declare function getLastHeart(player: EntityPlayer): HealthType;
47
46
  */
48
47
  export declare function getNewestPlayer(): EntityPlayer;
49
48
  export declare function getFinalPlayer(): EntityPlayer;
50
- /**
51
- * Returns the slot number corresponding to where a trinket can be safely inserted.
52
- *
53
- * Example:
54
- * ```
55
- * const player = Isaac.GetPlayer();
56
- * const trinketSlot = getOpenTrinketSlotNum(player);
57
- * if (trinketSlot !== undefined) {
58
- * // They have one or more open trinket slots
59
- * player.AddTrinket(TrinketType.TRINKET_SWALLOWED_PENNY);
60
- * }
61
- * ```
62
- */
63
- export declare function getOpenTrinketSlot(player: EntityPlayer): int | undefined;
64
49
  /**
65
50
  * Iterates over all players and checks if any are close enough to the specified position.
66
51
  *
@@ -115,17 +100,6 @@ export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int |
115
100
  * This is equivalent to the number of hits that the player can currently take.
116
101
  */
117
102
  export declare function getPlayerNumAllHearts(player: EntityPlayer): int;
118
- /**
119
- * Use this helper function as a workaround for `EntityPlayer.GetPocketItem()` not working
120
- * correctly.
121
- *
122
- * Note that due to API limitations, there is no way to determine the location of a Dice Bag trinket
123
- * dice. Furthermore, when the player has a Dice Bag trinket dice and a pocket active at the same
124
- * time, there is no way to determine the location of the pocket active item. If this function
125
- * cannot determine the identity of a particular slot, it will mark the type of the slot as
126
- * `PocketItemType.UNDETERMINABLE`.
127
- */
128
- export declare function getPocketItems(player: EntityPlayer): PocketItemDescription[];
129
103
  /**
130
104
  * Helper function to return the active charge and the battery charge combined. This is useful
131
105
  * because you are not able to set the battery charge directly.
@@ -146,23 +120,6 @@ export declare function hasLostCurse(player: EntityPlayer): boolean;
146
120
  * items. (Only Tainted Forgotten can pick up items.)
147
121
  */
148
122
  export declare function hasOpenActiveItemSlot(player: EntityPlayer): boolean;
149
- /**
150
- * Returns whether or not the player can hold an additional pocket item, beyond what they are
151
- * currently carrying. This takes into account items that modify the max number of pocket items,
152
- * like Starter Deck.
153
- *
154
- * If the player is the Tainted Soul, this always returns false, since that character cannot pick up
155
- * items. (Only Tainted Forgotten can pick up items.)
156
- */
157
- export declare function hasOpenPocketItemSlot(player: EntityPlayer): boolean;
158
- /**
159
- * Returns whether or not the player can hold an additional trinket, beyond what they are currently
160
- * carrying. This takes into account items that modify the max number of trinkets, like Mom's Purse.
161
- *
162
- * If the player is the Tainted Soul, this always returns false, since that character cannot pick up
163
- * items. (Only Tainted Forgotten can pick up items.)
164
- */
165
- export declare function hasOpenTrinketSlot(player: EntityPlayer): boolean;
166
123
  /**
167
124
  * Helper function for detecting when a player is Bethany or Tainted Bethany. This is useful if you
168
125
  * need to adjust UI elements to account for Bethany's soul charges or Tainted Bethany's blood
@@ -6,8 +6,6 @@ local ____constants = require("constants")
6
6
  local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
7
7
  local ____HealthType = require("types.HealthType")
8
8
  local HealthType = ____HealthType.HealthType
9
- local ____PocketItemType = require("types.PocketItemType")
10
- local PocketItemType = ____PocketItemType.PocketItemType
11
9
  local ____bitwise = require("functions.bitwise")
12
10
  local getKBitOfN = ____bitwise.getKBitOfN
13
11
  local getNumBitsOfN = ____bitwise.getNumBitsOfN
@@ -29,18 +27,18 @@ function ____exports.getPlayers(self, performExclusions)
29
27
  do
30
28
  local player = Isaac.GetPlayer(i)
31
29
  if player == nil then
32
- goto __continue55
30
+ goto __continue51
33
31
  end
34
32
  if ____exports.isChildPlayer(nil, player) then
35
- goto __continue55
33
+ goto __continue51
36
34
  end
37
35
  local character = player:GetPlayerType()
38
36
  if performExclusions and EXCLUDED_CHARACTERS:has(character) then
39
- goto __continue55
37
+ goto __continue51
40
38
  end
41
39
  __TS__ArrayPush(players, player)
42
40
  end
43
- ::__continue55::
41
+ ::__continue51::
44
42
  i = i + 1
45
43
  end
46
44
  end
@@ -48,7 +46,7 @@ function ____exports.getPlayers(self, performExclusions)
48
46
  end
49
47
  function ____exports.getPlayerIndex(self, player)
50
48
  local character = player:GetPlayerType()
51
- local collectibleToUse = ((character == PlayerType.PLAYER_LAZARUS2_B) and CollectibleType.COLLECTIBLE_INNER_EYE) or CollectibleType.COLLECTIBLE_SAD_ONION
49
+ local collectibleToUse = character == PlayerType.PLAYER_LAZARUS2_B and CollectibleType.COLLECTIBLE_INNER_EYE or CollectibleType.COLLECTIBLE_SAD_ONION
52
50
  local collectibleRNG = player:GetCollectibleRNG(collectibleToUse)
53
51
  local seed = collectibleRNG:GetSeed()
54
52
  return seed
@@ -74,9 +72,7 @@ function ____exports.addTrinketCostume(self, player, trinketType)
74
72
  player:AddCostume(itemConfigTrinket, false)
75
73
  end
76
74
  function ____exports.anyPlayerCloserThan(self, position, distance)
77
- for ____, player in ipairs(
78
- ____exports.getPlayers(nil)
79
- ) do
75
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
80
76
  if player.Position:Distance(position) <= distance then
81
77
  return true
82
78
  end
@@ -84,9 +80,7 @@ function ____exports.anyPlayerCloserThan(self, position, distance)
84
80
  return false
85
81
  end
86
82
  function ____exports.anyPlayerHasCollectible(self, collectibleType)
87
- for ____, player in ipairs(
88
- ____exports.getPlayers(nil)
89
- ) do
83
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
90
84
  if player:HasCollectible(collectibleType) then
91
85
  return true
92
86
  end
@@ -94,9 +88,7 @@ function ____exports.anyPlayerHasCollectible(self, collectibleType)
94
88
  return false
95
89
  end
96
90
  function ____exports.anyPlayerHasTrinket(self, trinketType)
97
- for ____, player in ipairs(
98
- ____exports.getPlayers(nil)
99
- ) do
91
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
100
92
  if player:HasTrinket(trinketType) then
101
93
  return true
102
94
  end
@@ -104,9 +96,7 @@ function ____exports.anyPlayerHasTrinket(self, trinketType)
104
96
  return false
105
97
  end
106
98
  function ____exports.anyPlayerIs(self, matchingCharacter)
107
- for ____, player in ipairs(
108
- ____exports.getPlayers(nil)
109
- ) do
99
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
110
100
  local character = player:GetPlayerType()
111
101
  if character == matchingCharacter then
112
102
  return true
@@ -120,14 +110,12 @@ function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
120
110
  local player = playerOrTearHeight
121
111
  tearHeight = player.TearHeight
122
112
  end
123
- return 32 - (2.5 * tearHeight)
113
+ return 32 - 2.5 * tearHeight
124
114
  end
125
115
  function ____exports.getClosestPlayer(self, position)
126
116
  local closestPlayer = nil
127
117
  local closestDistance = math.huge
128
- for ____, player in ipairs(
129
- ____exports.getPlayers(nil)
130
- ) do
118
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
131
119
  local distance = position:Distance(player.Position)
132
120
  if distance < closestDistance then
133
121
  closestPlayer = player
@@ -158,10 +146,10 @@ function ____exports.getLastHeart(self, player)
158
146
  local boneHearts = player:GetBoneHearts()
159
147
  local rottenHearts = player:GetRottenHearts()
160
148
  local soulHeartSlots = soulHearts / 2
161
- local lastHeartIndex = (boneHearts + soulHeartSlots) - 1
149
+ local lastHeartIndex = boneHearts + soulHeartSlots - 1
162
150
  local isLastHeartBone = player:IsBoneHeart(lastHeartIndex)
163
151
  if isLastHeartBone then
164
- local isLastContainerEmpty = hearts <= (effectiveMaxHearts - 2)
152
+ local isLastContainerEmpty = hearts <= effectiveMaxHearts - 2
165
153
  if isLastContainerEmpty then
166
154
  return HealthType.BONE
167
155
  end
@@ -193,9 +181,7 @@ end
193
181
  function ____exports.getNewestPlayer(self)
194
182
  local newestPlayer = nil
195
183
  local lowestFrame = math.huge
196
- for ____, player in ipairs(
197
- ____exports.getPlayers(nil)
198
- ) do
184
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
199
185
  if player.FrameCount < lowestFrame then
200
186
  newestPlayer = player
201
187
  lowestFrame = player.FrameCount
@@ -210,28 +196,8 @@ function ____exports.getFinalPlayer(self)
210
196
  local players = ____exports.getPlayers(nil)
211
197
  return players[#players]
212
198
  end
213
- function ____exports.getOpenTrinketSlot(self, player)
214
- local maxTrinkets = player:GetMaxTrinkets()
215
- local trinket0 = player:GetTrinket(0)
216
- local trinket1 = player:GetTrinket(1)
217
- if maxTrinkets == 1 then
218
- return ((trinket0 == TrinketType.TRINKET_NULL) and 0) or nil
219
- end
220
- if maxTrinkets == 2 then
221
- if trinket0 == TrinketType.TRINKET_NULL then
222
- return 0
223
- end
224
- return ((trinket1 == TrinketType.TRINKET_NULL) and 1) or nil
225
- end
226
- error(
227
- "The player has an unknown number of trinket slots: " .. tostring(maxTrinkets)
228
- )
229
- return nil
230
- end
231
199
  function ____exports.getPlayerCloserThan(self, position, distance)
232
- for ____, player in ipairs(
233
- ____exports.getPlayers(nil)
234
- ) do
200
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
235
201
  if player.Position:Distance(position) <= distance then
236
202
  return player
237
203
  end
@@ -241,9 +207,7 @@ end
241
207
  function ____exports.getPlayerCollectibleMap(self, player)
242
208
  local collectibleSet = getCollectibleSet(nil)
243
209
  local collectibleMap = __TS__New(Map)
244
- for ____, collectibleType in __TS__Iterator(
245
- collectibleSet:values()
246
- ) do
210
+ for ____, collectibleType in __TS__Iterator(collectibleSet:values()) do
247
211
  local collectibleNum = player:GetCollectibleNum(collectibleType, true)
248
212
  if collectibleNum > 0 then
249
213
  collectibleMap:set(collectibleType, collectibleNum)
@@ -252,9 +216,7 @@ function ____exports.getPlayerCollectibleMap(self, player)
252
216
  return collectibleMap
253
217
  end
254
218
  function ____exports.getPlayerFromIndex(self, playerIndex)
255
- for ____, player in ipairs(
256
- ____exports.getPlayers(nil)
257
- ) do
219
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
258
220
  local existingPlayerIndex = ____exports.getPlayerIndex(nil, player)
259
221
  if existingPlayerIndex == playerIndex then
260
222
  return player
@@ -264,9 +226,7 @@ function ____exports.getPlayerFromIndex(self, playerIndex)
264
226
  end
265
227
  function ____exports.getPlayersOfType(self, playerType)
266
228
  local players = {}
267
- for ____, player in ipairs(
268
- ____exports.getPlayers(nil)
269
- ) do
229
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
270
230
  local character = player:GetPlayerType()
271
231
  if character == playerType then
272
232
  __TS__ArrayPush(players, player)
@@ -283,14 +243,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
283
243
  do
284
244
  local player = Isaac.GetPlayer(i)
285
245
  if player == nil then
286
- goto __continue64
246
+ goto __continue60
287
247
  end
288
248
  local playerHash = GetPtrHash(player)
289
249
  if playerHash == playerToFindHash then
290
250
  return i
291
251
  end
292
252
  end
293
- ::__continue64::
253
+ ::__continue60::
294
254
  i = i + 1
295
255
  end
296
256
  end
@@ -301,44 +261,7 @@ function ____exports.getPlayerNumAllHearts(self, player)
301
261
  local soulHearts = player:GetSoulHearts()
302
262
  local boneHearts = player:GetBoneHearts()
303
263
  local eternalHearts = player:GetEternalHearts()
304
- return ((hearts + soulHearts) + boneHearts) + eternalHearts
305
- end
306
- function ____exports.getPocketItems(self, player)
307
- local pocketItem = player:GetActiveItem(ActiveSlot.SLOT_POCKET)
308
- local hasPocketItem = pocketItem ~= CollectibleType.COLLECTIBLE_NULL
309
- local pocketItem2 = player:GetActiveItem(ActiveSlot.SLOT_POCKET2)
310
- local hasPocketItem2 = pocketItem2 ~= CollectibleType.COLLECTIBLE_NULL
311
- local maxPocketItems = player:GetMaxPocketItems()
312
- local pocketItems = {}
313
- local pocketItemIdentified = false
314
- local pocketItem2Identified = false
315
- do
316
- local slot = 0
317
- while slot < 4 do
318
- local card = player:GetCard(slot)
319
- local pill = player:GetPill(slot)
320
- if card ~= Card.CARD_NULL then
321
- __TS__ArrayPush(pocketItems, {type = PocketItemType.CARD, id = card})
322
- elseif pill ~= PillColor.PILL_NULL then
323
- __TS__ArrayPush(pocketItems, {type = PocketItemType.PILL, id = pill})
324
- elseif (hasPocketItem and (not hasPocketItem2)) and (not pocketItemIdentified) then
325
- pocketItemIdentified = true
326
- __TS__ArrayPush(pocketItems, {type = PocketItemType.ACTIVE_ITEM, id = pocketItem})
327
- elseif ((not hasPocketItem) and hasPocketItem2) and (not pocketItem2Identified) then
328
- pocketItem2Identified = true
329
- __TS__ArrayPush(pocketItems, {type = PocketItemType.DICE_BAG_DICE, id = pocketItem2})
330
- elseif hasPocketItem and hasPocketItem2 then
331
- __TS__ArrayPush(pocketItems, {type = PocketItemType.UNDETERMINABLE, id = 0})
332
- else
333
- __TS__ArrayPush(pocketItems, {type = PocketItemType.EMPTY, id = 0})
334
- end
335
- if (slot + 1) == maxPocketItems then
336
- break
337
- end
338
- slot = slot + 1
339
- end
340
- end
341
- return pocketItems
264
+ return hearts + soulHearts + boneHearts + eternalHearts
342
265
  end
343
266
  function ____exports.getTotalCharge(self, player, activeSlot)
344
267
  local activeCharge = player:GetActiveCharge(activeSlot)
@@ -347,9 +270,7 @@ function ____exports.getTotalCharge(self, player, activeSlot)
347
270
  end
348
271
  function ____exports.getTotalPlayerCollectibles(self, collectibleType)
349
272
  local numCollectibles = 0
350
- for ____, player in ipairs(
351
- ____exports.getPlayers(nil)
352
- ) do
273
+ for ____, player in ipairs(____exports.getPlayers(nil)) do
353
274
  numCollectibles = numCollectibles + player:GetCollectibleNum(collectibleType)
354
275
  end
355
276
  return numCollectibles
@@ -367,53 +288,32 @@ function ____exports.hasOpenActiveItemSlot(self, player)
367
288
  local activeItemSecondary = player:GetActiveItem(ActiveSlot.SLOT_SECONDARY)
368
289
  local hasSchoolbag = player:HasCollectible(CollectibleType.COLLECTIBLE_SCHOOLBAG)
369
290
  if hasSchoolbag then
370
- return (activeItemPrimary == CollectibleType.COLLECTIBLE_NULL) or (activeItemSecondary == CollectibleType.COLLECTIBLE_NULL)
291
+ return activeItemPrimary == CollectibleType.COLLECTIBLE_NULL or activeItemSecondary == CollectibleType.COLLECTIBLE_NULL
371
292
  end
372
293
  return activeItemPrimary == CollectibleType.COLLECTIBLE_NULL
373
294
  end
374
- function ____exports.hasOpenPocketItemSlot(self, player)
375
- local character = player:GetPlayerType()
376
- if character == PlayerType.PLAYER_THESOUL_B then
377
- return false
378
- end
379
- local pocketItems = ____exports.getPocketItems(nil, player)
380
- for ____, pocketItem in ipairs(pocketItems) do
381
- if pocketItem.type == PocketItemType.EMPTY then
382
- return true
383
- end
384
- end
385
- return false
386
- end
387
- function ____exports.hasOpenTrinketSlot(self, player)
388
- local character = player:GetPlayerType()
389
- if character == PlayerType.PLAYER_THESOUL_B then
390
- return false
391
- end
392
- local openTrinketSlot = ____exports.getOpenTrinketSlot(nil, player)
393
- return openTrinketSlot ~= nil
394
- end
395
295
  function ____exports.isBethany(self, player)
396
296
  local character = player:GetPlayerType()
397
- return (character == PlayerType.PLAYER_BETHANY) or (character == PlayerType.PLAYER_BETHANY_B)
297
+ return character == PlayerType.PLAYER_BETHANY or character == PlayerType.PLAYER_BETHANY_B
398
298
  end
399
299
  function ____exports.isFirstPlayer(self, player)
400
300
  return ____exports.getPlayerIndexVanilla(nil, player) == 0
401
301
  end
402
302
  function ____exports.isJacobOrEsau(self, player)
403
303
  local character = player:GetPlayerType()
404
- return (character == PlayerType.PLAYER_JACOB) or (character == PlayerType.PLAYER_ESAU)
304
+ return character == PlayerType.PLAYER_JACOB or character == PlayerType.PLAYER_ESAU
405
305
  end
406
306
  function ____exports.isKeeper(self, player)
407
307
  local character = player:GetPlayerType()
408
- return (character == PlayerType.PLAYER_KEEPER) or (character == PlayerType.PLAYER_KEEPER_B)
308
+ return character == PlayerType.PLAYER_KEEPER or character == PlayerType.PLAYER_KEEPER_B
409
309
  end
410
310
  function ____exports.isLost(self, player)
411
311
  local character = player:GetPlayerType()
412
- return (character == PlayerType.PLAYER_THELOST) or (character == PlayerType.PLAYER_THELOST_B)
312
+ return character == PlayerType.PLAYER_THELOST or character == PlayerType.PLAYER_THELOST_B
413
313
  end
414
314
  function ____exports.isTaintedLazarus(self, player)
415
315
  local character = player:GetPlayerType()
416
- return (character == PlayerType.PLAYER_LAZARUS_B) or (character == PlayerType.PLAYER_LAZARUS2_B)
316
+ return character == PlayerType.PLAYER_LAZARUS_B or character == PlayerType.PLAYER_LAZARUS2_B
417
317
  end
418
318
  function ____exports.removeCollectibleCostume(self, player, collectibleType)
419
319
  local itemConfig = Isaac.GetItemConfig()
@@ -456,9 +356,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
456
356
  itemPool:RemoveCollectible(collectibleType)
457
357
  end
458
358
  repeat
459
- local ____switch106 = activeSlot
460
- local ____cond106 = ____switch106 == ActiveSlot.SLOT_PRIMARY
461
- if ____cond106 then
359
+ local ____switch87 = activeSlot
360
+ local ____cond87 = ____switch87 == ActiveSlot.SLOT_PRIMARY
361
+ if ____cond87 then
462
362
  do
463
363
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
464
364
  player:RemoveCollectible(primaryCollectibleType)
@@ -467,8 +367,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
467
367
  break
468
368
  end
469
369
  end
470
- ____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_SECONDARY)
471
- if ____cond106 then
370
+ ____cond87 = ____cond87 or ____switch87 == ActiveSlot.SLOT_SECONDARY
371
+ if ____cond87 then
472
372
  do
473
373
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
474
374
  player:RemoveCollectible(primaryCollectibleType)
@@ -483,16 +383,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
483
383
  break
484
384
  end
485
385
  end
486
- ____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_POCKET)
487
- if ____cond106 then
386
+ ____cond87 = ____cond87 or ____switch87 == ActiveSlot.SLOT_POCKET
387
+ if ____cond87 then
488
388
  do
489
389
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
490
390
  player:SetActiveCharge(charge, activeSlot)
491
391
  break
492
392
  end
493
393
  end
494
- ____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_POCKET2)
495
- if ____cond106 then
394
+ ____cond87 = ____cond87 or ____switch87 == ActiveSlot.SLOT_POCKET2
395
+ if ____cond87 then
496
396
  do
497
397
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
498
398
  break
@@ -27,29 +27,29 @@ function ____exports.getPlayerHealth(self, player)
27
27
  local rottenHearts = player:GetRottenHearts()
28
28
  local brokenHearts = player:GetBrokenHearts()
29
29
  local subPlayer = player:GetSubPlayer()
30
- if (character == PlayerType.PLAYER_THEFORGOTTEN) and (subPlayer ~= nil) then
30
+ if character == PlayerType.PLAYER_THEFORGOTTEN and subPlayer ~= nil then
31
31
  maxHearts = boneHearts * 2
32
32
  boneHearts = 0
33
33
  soulHearts = subPlayer:GetSoulHearts()
34
- elseif (character == PlayerType.PLAYER_THESOUL) and (subPlayer ~= nil) then
34
+ elseif character == PlayerType.PLAYER_THESOUL and subPlayer ~= nil then
35
35
  maxHearts = subPlayer:GetBoneHearts() * 2
36
36
  hearts = subPlayer:GetHearts()
37
37
  end
38
- hearts = hearts - (rottenHearts * 2)
38
+ hearts = hearts - rottenHearts * 2
39
39
  local extraHearts = math.ceil(soulHearts / 2) + boneHearts
40
40
  local currentSoulHeart = 0
41
41
  do
42
42
  local i = 0
43
43
  while i < extraHearts do
44
44
  local isBoneHeart = player:IsBoneHeart(i)
45
- if (character == PlayerType.PLAYER_THEFORGOTTEN) and (subPlayer ~= nil) then
45
+ if character == PlayerType.PLAYER_THEFORGOTTEN and subPlayer ~= nil then
46
46
  isBoneHeart = subPlayer:IsBoneHeart(i)
47
47
  end
48
48
  if isBoneHeart then
49
49
  __TS__ArrayPush(soulHeartTypes, HeartSubType.HEART_BONE)
50
50
  else
51
51
  local isBlackHeart = player:IsBlackHeart(currentSoulHeart + 1)
52
- if (character == PlayerType.PLAYER_THEFORGOTTEN) and (subPlayer ~= nil) then
52
+ if character == PlayerType.PLAYER_THEFORGOTTEN and subPlayer ~= nil then
53
53
  isBlackHeart = subPlayer:IsBlackHeart(currentSoulHeart + 1)
54
54
  end
55
55
  if isBlackHeart then
@@ -62,13 +62,23 @@ function ____exports.getPlayerHealth(self, player)
62
62
  i = i + 1
63
63
  end
64
64
  end
65
- return {soulHeartTypes = soulHeartTypes, maxHearts = maxHearts, hearts = hearts, eternalHearts = eternalHearts, soulHearts = soulHearts, boneHearts = boneHearts, goldenHearts = goldenHearts, rottenHearts = rottenHearts, brokenHearts = brokenHearts}
65
+ return {
66
+ soulHeartTypes = soulHeartTypes,
67
+ maxHearts = maxHearts,
68
+ hearts = hearts,
69
+ eternalHearts = eternalHearts,
70
+ soulHearts = soulHearts,
71
+ boneHearts = boneHearts,
72
+ goldenHearts = goldenHearts,
73
+ rottenHearts = rottenHearts,
74
+ brokenHearts = brokenHearts
75
+ }
66
76
  end
67
77
  function ____exports.setPlayerHealth(self, player, playerHealth)
68
78
  local character = player:GetPlayerType()
69
79
  local subPlayer = player:GetSubPlayer()
70
80
  ____exports.removeAllPlayerHealth(nil, player)
71
- if (character == PlayerType.PLAYER_THESOUL) and (subPlayer ~= nil) then
81
+ if character == PlayerType.PLAYER_THESOUL and subPlayer ~= nil then
72
82
  subPlayer:AddMaxHearts(playerHealth.maxHearts, false)
73
83
  else
74
84
  player:AddMaxHearts(playerHealth.maxHearts, false)
@@ -79,9 +89,9 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
79
89
  local i = 0
80
90
  while i < #playerHealth.soulHeartTypes do
81
91
  local heartType = playerHealth.soulHeartTypes[i + 1]
82
- local isHalf = (playerHealth.soulHearts + (playerHealth.boneHearts * 2)) < ((i + 1) * 2)
92
+ local isHalf = playerHealth.soulHearts + playerHealth.boneHearts * 2 < (i + 1) * 2
83
93
  local addAmount = 2
84
- if (isHalf or (heartType == HeartSubType.HEART_BONE)) or (soulHeartsRemaining < 2) then
94
+ if isHalf or heartType == HeartSubType.HEART_BONE or soulHeartsRemaining < 2 then
85
95
  addAmount = 1
86
96
  end
87
97
  if heartType == HeartSubType.HEART_SOUL then
@@ -1,21 +1,23 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ import { PocketItemDescription } from "../types/PocketItemDescription";
3
+ export declare function getFirstCardOrPill(player: EntityPlayer): PocketItemDescription | undefined;
2
4
  /**
3
- * This is a helper function to get a card name from a Card.
5
+ * Use this helper function as a workaround for `EntityPlayer.GetPocketItem()` not working
6
+ * correctly.
4
7
  *
5
- * Example:
6
- * ```
7
- * const card = Card.CARD_FOOL;
8
- * const cardName = getCardName(card); // cardName is "0 - The Fool"
9
- * ```
8
+ * Note that due to API limitations, there is no way to determine the location of a Dice Bag trinket
9
+ * dice. Furthermore, when the player has a Dice Bag trinket dice and a pocket active at the same
10
+ * time, there is no way to determine the location of the pocket active item. If this function
11
+ * cannot determine the identity of a particular slot, it will mark the type of the slot as
12
+ * `PocketItemType.UNDETERMINABLE`.
10
13
  */
11
- export declare function getCardName(card: Card | int): string;
14
+ export declare function getPocketItems(player: EntityPlayer): PocketItemDescription[];
12
15
  /**
13
- * This is a helper function to get a pill effect name from a PillEffect.
16
+ * Returns whether or not the player can hold an additional pocket item, beyond what they are
17
+ * currently carrying. This takes into account items that modify the max number of pocket items,
18
+ * like Starter Deck.
14
19
  *
15
- * Example:
16
- * ```
17
- * const pillEffect = PillEffect.PILLEFFECT_BAD_GAS;
18
- * const pillEffectName = getPillEffectName(pillEffect); // trinketName is "Bad Gas"
19
- * ```
20
+ * If the player is the Tainted Soul, this always returns false, since that character cannot pick up
21
+ * items. (Only Tainted Forgotten can pick up items.)
20
22
  */
21
- export declare function getPillEffectName(pillEffect: PillEffect | int): string;
23
+ export declare function hasOpenPocketItemSlot(player: EntityPlayer): boolean;
@@ -1,39 +1,65 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
2
3
  local ____exports = {}
3
- local ____cardNameMap = require("maps.cardNameMap")
4
- local CARD_NAME_MAP = ____cardNameMap.CARD_NAME_MAP
5
- local ____pillEffectNameMap = require("maps.pillEffectNameMap")
6
- local PILL_EFFECT_NAME_MAP = ____pillEffectNameMap.PILL_EFFECT_NAME_MAP
7
- function ____exports.getCardName(self, card)
8
- local itemConfig = Isaac.GetItemConfig()
9
- local defaultName = "Unknown"
10
- if type(card) ~= "number" then
11
- return defaultName
4
+ local ____PocketItemType = require("types.PocketItemType")
5
+ local PocketItemType = ____PocketItemType.PocketItemType
6
+ function ____exports.getPocketItems(self, player)
7
+ local pocketItem = player:GetActiveItem(ActiveSlot.SLOT_POCKET)
8
+ local hasPocketItem = pocketItem ~= CollectibleType.COLLECTIBLE_NULL
9
+ local pocketItem2 = player:GetActiveItem(ActiveSlot.SLOT_POCKET2)
10
+ local hasPocketItem2 = pocketItem2 ~= CollectibleType.COLLECTIBLE_NULL
11
+ local maxPocketItems = player:GetMaxPocketItems()
12
+ local pocketItems = {}
13
+ local pocketItemIdentified = false
14
+ local pocketItem2Identified = false
15
+ do
16
+ local slot = 0
17
+ while slot < 4 do
18
+ local card = player:GetCard(slot)
19
+ local pill = player:GetPill(slot)
20
+ if card ~= Card.CARD_NULL then
21
+ __TS__ArrayPush(pocketItems, {type = PocketItemType.CARD, id = card, slot = slot})
22
+ elseif pill ~= PillColor.PILL_NULL then
23
+ __TS__ArrayPush(pocketItems, {type = PocketItemType.PILL, id = pill, slot = slot})
24
+ elseif hasPocketItem and not hasPocketItem2 and not pocketItemIdentified then
25
+ pocketItemIdentified = true
26
+ __TS__ArrayPush(pocketItems, {type = PocketItemType.ACTIVE_ITEM, id = pocketItem, slot = slot})
27
+ elseif not hasPocketItem and hasPocketItem2 and not pocketItem2Identified then
28
+ pocketItem2Identified = true
29
+ __TS__ArrayPush(pocketItems, {type = PocketItemType.DICE_BAG_DICE, id = pocketItem2, slot = slot})
30
+ elseif hasPocketItem and hasPocketItem2 then
31
+ __TS__ArrayPush(pocketItems, {type = PocketItemType.UNDETERMINABLE, id = 0, slot = slot})
32
+ else
33
+ __TS__ArrayPush(pocketItems, {type = PocketItemType.EMPTY, id = 0, slot = slot})
34
+ end
35
+ if slot + 1 == maxPocketItems then
36
+ break
37
+ end
38
+ slot = slot + 1
39
+ end
12
40
  end
13
- local cardName = CARD_NAME_MAP:get(card)
14
- if cardName ~= nil then
15
- return cardName
16
- end
17
- local itemConfigCard = itemConfig:GetCard(card)
18
- if itemConfigCard == nil then
19
- return defaultName
20
- end
21
- return itemConfigCard.Name
41
+ return pocketItems
22
42
  end
23
- function ____exports.getPillEffectName(self, pillEffect)
24
- local itemConfig = Isaac.GetItemConfig()
25
- local defaultName = "Unknown"
26
- if type(pillEffect) ~= "number" then
27
- return defaultName
43
+ function ____exports.getFirstCardOrPill(self, player)
44
+ local pocketItems = ____exports.getPocketItems(nil, player)
45
+ for ____, pocketItem in ipairs(pocketItems) do
46
+ if pocketItem.type == PocketItemType.CARD or pocketItem.type == PocketItemType.PILL then
47
+ return pocketItem
48
+ end
28
49
  end
29
- local pillEffectName = PILL_EFFECT_NAME_MAP:get(pillEffect)
30
- if pillEffectName ~= nil then
31
- return pillEffectName
50
+ return nil
51
+ end
52
+ function ____exports.hasOpenPocketItemSlot(self, player)
53
+ local character = player:GetPlayerType()
54
+ if character == PlayerType.PLAYER_THESOUL_B then
55
+ return false
32
56
  end
33
- local itemConfigPillEffect = itemConfig:GetPillEffect(pillEffect)
34
- if itemConfigPillEffect == nil then
35
- return defaultName
57
+ local pocketItems = ____exports.getPocketItems(nil, player)
58
+ for ____, pocketItem in ipairs(pocketItems) do
59
+ if pocketItem.type == PocketItemType.EMPTY then
60
+ return true
61
+ end
36
62
  end
37
- return itemConfigPillEffect.Name
63
+ return false
38
64
  end
39
65
  return ____exports
@@ -24,14 +24,14 @@ function ____exports.getRandomFloat(self, min, max, seed)
24
24
  if seed == nil then
25
25
  seed = Random()
26
26
  end
27
- return min + (____exports.getRandom(nil, seed) * (max - min))
27
+ return min + ____exports.getRandom(nil, seed) * (max - min)
28
28
  end
29
29
  function ____exports.getRandomInt(self, min, max, seed)
30
30
  if seed == nil then
31
31
  seed = Random()
32
32
  end
33
33
  local rng = ____exports.initRNG(nil, seed)
34
- return rng:RandomInt((max - min) + 1) + min
34
+ return rng:RandomInt(max - min + 1) + min
35
35
  end
36
36
  function ____exports.nextSeed(self, seed)
37
37
  local rng = ____exports.initRNG(nil, seed)