isaacscript-common 1.2.72 → 1.2.75

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.
@@ -1,10 +1,12 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local __TS__ArrayFind = ____lualib.__TS__ArrayFind
2
4
  local ____exports = {}
3
5
  local hasSubscriptions, useItemFlip, getNewLazarus, v
4
6
  local ____exports = require("features.saveDataManager.exports")
5
7
  local saveDataManager = ____exports.saveDataManager
6
8
  local ____player = require("functions.player")
7
- local getPlayers = ____player.getPlayers
9
+ local getPlayersOfType = ____player.getPlayersOfType
8
10
  local isTaintedLazarus = ____player.isTaintedLazarus
9
11
  local ____postFirstFlip = require("callbacks.subscriptions.postFirstFlip")
10
12
  local postFirstFlipFire = ____postFirstFlip.postFirstFlipFire
@@ -23,6 +25,9 @@ function useItemFlip(self, _collectibleType, _rng, player, _useFlags, _activeSlo
23
25
  return
24
26
  end
25
27
  local newLazarus = getNewLazarus(nil, player)
28
+ if newLazarus == nil then
29
+ return
30
+ end
26
31
  if not v.run.usedFlipAtLeastOnce then
27
32
  v.run.usedFlipAtLeastOnce = true
28
33
  postFirstFlipFire(nil, newLazarus)
@@ -39,13 +44,11 @@ function getNewLazarus(self, oldLazarus)
39
44
  else
40
45
  error("Failed to determine the character in the postFlip callback.")
41
46
  end
42
- for ____, player in ipairs(getPlayers(nil)) do
43
- local character = player:GetPlayerType()
44
- if character == newCharacter and player.FrameCount == oldLazarus.FrameCount then
45
- return player
46
- end
47
- end
48
- return error("Failed to find the player entity for the new Lazarus.")
47
+ local playersOfType = getPlayersOfType(nil, newCharacter)
48
+ return __TS__ArrayFind(
49
+ playersOfType,
50
+ function(____, player) return player.FrameCount == oldLazarus.FrameCount end
51
+ )
49
52
  end
50
53
  v = {run = {usedFlipAtLeastOnce = false}}
51
54
  function ____exports.postFlipCallbacksInit(self, mod)
@@ -2,6 +2,7 @@
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
5
6
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
6
7
  local __TS__Iterator = ____lualib.__TS__Iterator
7
8
  local ____exports = {}
@@ -23,33 +24,32 @@ function postUpdate(self)
23
24
  if not hasSubscriptions(nil) then
24
25
  return
25
26
  end
26
- for ____, gridEntity in ipairs(getGridEntities(nil)) do
27
- do
28
- if gridEntity.CollisionClass == GridCollisionClass.COLLISION_NONE then
29
- goto __continue7
27
+ local gridEntities = getGridEntities(nil)
28
+ local gridEntitiesWithCollision = __TS__ArrayFilter(
29
+ gridEntities,
30
+ function(____, gridEntity) return gridEntity.CollisionClass ~= GridCollisionClass.COLLISION_NONE end
31
+ )
32
+ for ____, gridEntity in ipairs(gridEntitiesWithCollision) do
33
+ local gridEntityPtrHash = GetPtrHash(gridEntity)
34
+ local oldCollidingEntities = v.room.collidingEntitiesMap:getAndSetDefault(gridEntityPtrHash)
35
+ local collidingEntities = getCollidingEntitiesWithGridEntity(nil, gridEntity)
36
+ for ____, entity in ipairs(collidingEntities) do
37
+ local entityPtrHash = GetPtrHash(entity)
38
+ if not oldCollidingEntities:has(entityPtrHash) then
39
+ oldCollidingEntities:add(entityPtrHash)
40
+ postGridEntityCollisionFire(nil, gridEntity, entity)
30
41
  end
31
- local gridEntityPtrHash = GetPtrHash(gridEntity)
32
- local oldCollidingEntities = v.room.collidingEntitiesMap:getAndSetDefault(gridEntityPtrHash)
33
- local collidingEntities = getCollidingEntitiesWithGridEntity(nil, gridEntity)
34
- for ____, entity in ipairs(collidingEntities) do
35
- local entityPtrHash = GetPtrHash(entity)
36
- if not oldCollidingEntities:has(entityPtrHash) then
37
- oldCollidingEntities:add(entityPtrHash)
38
- postGridEntityCollisionFire(nil, gridEntity, entity)
39
- end
40
- end
41
- local collidingEntitiesPtrHashes = __TS__ArrayMap(
42
- collidingEntities,
43
- function(____, entity) return GetPtrHash(entity) end
44
- )
45
- local collidingEntitiesPtrHashSet = __TS__New(Set, collidingEntitiesPtrHashes)
46
- for ____, oldCollidingEntityPtrHash in __TS__Iterator(oldCollidingEntities:values()) do
47
- if not collidingEntitiesPtrHashSet:has(oldCollidingEntityPtrHash) then
48
- oldCollidingEntities:delete(oldCollidingEntityPtrHash)
49
- end
42
+ end
43
+ local collidingEntitiesPtrHashes = __TS__ArrayMap(
44
+ collidingEntities,
45
+ function(____, entity) return GetPtrHash(entity) end
46
+ )
47
+ local collidingEntitiesPtrHashSet = __TS__New(Set, collidingEntitiesPtrHashes)
48
+ for ____, oldCollidingEntityPtrHash in __TS__Iterator(oldCollidingEntities:values()) do
49
+ if not collidingEntitiesPtrHashSet:has(oldCollidingEntityPtrHash) then
50
+ oldCollidingEntities:delete(oldCollidingEntityPtrHash)
50
51
  end
51
52
  end
52
- ::__continue7::
53
53
  end
54
54
  end
55
55
  v = {room = {collidingEntitiesMap = __TS__New(
@@ -1,6 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
+ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
4
5
  local __TS__ArraySplice = ____lualib.__TS__ArraySplice
5
6
  local ____exports = {}
6
7
  local postUpdate, postRender, checkExecuteQueuedFunctions, v
@@ -20,18 +21,16 @@ end
20
21
  function checkExecuteQueuedFunctions(self, frameCount, functionTuples)
21
22
  local functionsToFire = {}
22
23
  local indexesToRemove = {}
23
- do
24
- local i = 0
25
- while i < #functionTuples do
26
- local functionTuple = functionTuples[i + 1]
24
+ __TS__ArrayForEach(
25
+ functionTuples,
26
+ function(____, functionTuple, i)
27
27
  local frame, func = table.unpack(functionTuple)
28
28
  if frameCount >= frame then
29
29
  __TS__ArrayPush(functionsToFire, func)
30
30
  __TS__ArrayPush(indexesToRemove, i)
31
31
  end
32
- i = i + 1
33
32
  end
34
- end
33
+ )
35
34
  for ____, indexToRemove in ipairs(indexesToRemove) do
36
35
  __TS__ArraySplice(functionTuples, indexToRemove, 1)
37
36
  end
@@ -6,8 +6,14 @@
6
6
  * combine N arrays. Note that this will only perform a shallow copy of the array elements.
7
7
  */
8
8
  export declare function combineArray<T>(...arrays: Array<T[] | readonly T[]>): T[];
9
- /** Helper function to perform a shallow copy. */
10
- export declare function copyArray<T>(array: T[] | readonly T[]): T[];
9
+ /**
10
+ * Helper function to perform a shallow copy.
11
+ *
12
+ * @param oldArray The array to copy.
13
+ * @param numElements Optional. If specified, will only copy the first N elements. By default, the
14
+ * entire array will be copied.
15
+ */
16
+ export declare function copyArray<T>(oldArray: T[] | readonly T[], numElements?: int): T[];
11
17
  export declare function emptyArray<T>(array: T[]): void;
12
18
  /**
13
19
  * Helper function for determining if two arrays contain the exact same elements. Note that this
@@ -48,8 +48,20 @@ function ____exports.combineArray(self, ...)
48
48
  end
49
49
  return elements
50
50
  end
51
- function ____exports.copyArray(self, array)
52
- return {table.unpack(array)}
51
+ function ____exports.copyArray(self, oldArray, numElements)
52
+ if numElements == nil then
53
+ numElements = #oldArray
54
+ end
55
+ local newArray = {}
56
+ do
57
+ local i = 0
58
+ while i < numElements do
59
+ local oldElement = oldArray[i + 1]
60
+ __TS__ArrayPush(newArray, oldElement)
61
+ i = i + 1
62
+ end
63
+ end
64
+ return newArray
53
65
  end
54
66
  function ____exports.emptyArray(self, array)
55
67
  __TS__ArraySplice(array, 0, #array)
@@ -5,6 +5,8 @@ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
5
5
  local ____exports = {}
6
6
  local ____constants = require("constants")
7
7
  local FAMILIARS_THAT_SHOOT_PLAYER_TEARS = ____constants.FAMILIARS_THAT_SHOOT_PLAYER_TEARS
8
+ local ____array = require("functions.array")
9
+ local copyArray = ____array.copyArray
8
10
  local ____entity = require("functions.entity")
9
11
  local getEntities = ____entity.getEntities
10
12
  local removeEntities = ____entity.removeEntities
@@ -41,14 +43,8 @@ function ____exports.checkFamiliar(self, player, collectibleType, numTargetFamil
41
43
  end
42
44
  if #familiarsForThisPlayer > numTargetFamiliars then
43
45
  local numFamiliarsToRemove = #familiarsForThisPlayer - numTargetFamiliars
44
- do
45
- local i = 0
46
- while i < numFamiliarsToRemove do
47
- local familiar = familiarsForThisPlayer[i + 1]
48
- familiar:Remove()
49
- i = i + 1
50
- end
51
- end
46
+ local familiarsToRemove = copyArray(nil, familiarsForThisPlayer, numFamiliarsToRemove)
47
+ removeEntities(nil, familiarsToRemove)
52
48
  return numFamiliarsToRemove * -1
53
49
  end
54
50
  local numFamiliarsToSpawn = numTargetFamiliars - #familiarsForThisPlayer
@@ -10,5 +10,5 @@ export declare function getDefaultGlobals(): Set<string>;
10
10
  * Helper function to get an array of any added global variables in the Isaac Lua environment.
11
11
  * Returns an array of key/value tuples.
12
12
  */
13
- export declare function getNewGlobals(): [AnyNotNil, unknown][];
13
+ export declare function getNewGlobals(): Array<[AnyNotNil, unknown]>;
14
14
  export declare function logNewGlobals(): void;
@@ -4,6 +4,7 @@ local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
6
  local __TS__ArraySort = ____lualib.__TS__ArraySort
7
+ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
7
8
  local ____exports = {}
8
9
  local twoDimensionalSort
9
10
  local ____log = require("functions.log")
@@ -214,13 +215,15 @@ function ____exports.logNewGlobals(self)
214
215
  if #newGlobals == 0 then
215
216
  log("- n/a (no extra global variables found)")
216
217
  end
217
- do
218
- local i = 0
219
- while i < #newGlobals do
220
- local key, value = table.unpack(newGlobals[i + 1])
218
+ __TS__ArrayForEach(
219
+ newGlobals,
220
+ function(____, ____bindingPattern0, i)
221
+ local value
222
+ local key
223
+ key = ____bindingPattern0[1]
224
+ value = ____bindingPattern0[2]
221
225
  log((((tostring(i + 1) .. ") ") .. tostring(key)) .. " - ") .. tostring(value))
222
- i = i + 1
223
226
  end
224
- end
227
+ )
225
228
  end
226
229
  return ____exports
@@ -39,6 +39,15 @@ export declare function getSurroundingGridEntities(gridEntity: GridEntity): Grid
39
39
  * Returns true if there are no pressure plates in the room.
40
40
  */
41
41
  export declare function isAllPressurePlatesPushed(): boolean;
42
+ export declare function isGridEntityBreakableByExplosion(gridEntity: GridEntity): boolean;
43
+ /**
44
+ * Helper function to see if the provided gridEntity is in its respective broken state. See the
45
+ * `GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP` constant for more details.
46
+ *
47
+ * Note that in the case of `GridEntityType.GRID_LOCK` (11), the state will turn to being broken
48
+ * before the actual collision for the entity is removed.
49
+ */
50
+ export declare function isGridEntityBroken(gridEntity: GridEntity): boolean;
42
51
  /**
43
52
  * Helper function to detect whether a given Void Portal is one that randomly spawns after a boss is
44
53
  * defeated or is one that naturally spawns in the room after Hush. (This is determined by looking
@@ -1,13 +1,15 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
- local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
4
3
  local Set = ____lualib.Set
5
4
  local __TS__New = ____lualib.__TS__New
5
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
6
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
7
7
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
8
8
  local ____exports = {}
9
9
  local ____constants = require("constants")
10
10
  local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
11
+ local ____gridEntityTypeToBrokenStateMap = require("maps.gridEntityTypeToBrokenStateMap")
12
+ local GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP = ____gridEntityTypeToBrokenStateMap.GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP
11
13
  local ____gridEntityXMLMap = require("maps.gridEntityXMLMap")
12
14
  local GRID_ENTITY_XML_MAP = ____gridEntityXMLMap.GRID_ENTITY_XML_MAP
13
15
  local ____roomShapeToTopLeftWallGridIndexMap = require("maps.roomShapeToTopLeftWallGridIndexMap")
@@ -61,6 +63,23 @@ function ____exports.spawnGridEntityWithVariant(self, gridEntityType, variant, g
61
63
  end
62
64
  return gridEntity
63
65
  end
66
+ local BREAKABLE_GRID_ENTITY_TYPES_BY_EXPLOSIONS = __TS__New(Set, {
67
+ GridEntityType.GRID_ROCK,
68
+ GridEntityType.GRID_ROCKT,
69
+ GridEntityType.GRID_ROCK_BOMB,
70
+ GridEntityType.GRID_ROCK_ALT,
71
+ GridEntityType.GRID_SPIDERWEB,
72
+ GridEntityType.GRID_TNT,
73
+ GridEntityType.GRID_POOP,
74
+ GridEntityType.GRID_ROCK_SS,
75
+ GridEntityType.GRID_ROCK_SPIKED,
76
+ GridEntityType.GRID_ROCK_ALT2,
77
+ GridEntityType.GRID_ROCK_GOLD
78
+ })
79
+ local BREAKABLE_GRID_ENTITY_TYPES_VARIANTS_BY_EXPLOSIONS = __TS__New(
80
+ Set,
81
+ {(tostring(GridEntityType.GRID_STATUE) .. ".") .. 1}
82
+ )
64
83
  function ____exports.convertXMLGridEntityType(self, gridEntityXMLType, gridEntityXMLVariant)
65
84
  if gridEntityXMLType == EntityType.ENTITY_TRIGGER_OUTPUT then
66
85
  return nil
@@ -167,6 +186,17 @@ function ____exports.isAllPressurePlatesPushed(self)
167
186
  end
168
187
  )
169
188
  end
189
+ function ____exports.isGridEntityBreakableByExplosion(self, gridEntity)
190
+ local gridEntityType = gridEntity:GetType()
191
+ local gridEntityVariant = gridEntity:GetVariant()
192
+ local gridEntityTypeVariant = (tostring(gridEntityType) .. ".") .. tostring(gridEntityVariant)
193
+ return BREAKABLE_GRID_ENTITY_TYPES_BY_EXPLOSIONS:has(gridEntityType) or BREAKABLE_GRID_ENTITY_TYPES_VARIANTS_BY_EXPLOSIONS:has(gridEntityTypeVariant)
194
+ end
195
+ function ____exports.isGridEntityBroken(self, gridEntity)
196
+ local gridEntityType = gridEntity:GetType()
197
+ local brokenState = GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP:get(gridEntityType)
198
+ return gridEntity.State == brokenState
199
+ end
170
200
  function ____exports.isPostBossVoidPortal(self, gridEntity)
171
201
  local saveState = gridEntity:GetSaveState()
172
202
  return saveState.VarData == 1
@@ -2,6 +2,7 @@
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local Map = ____lualib.Map
4
4
  local __TS__Iterator = ____lualib.__TS__Iterator
5
+ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
5
6
  local Set = ____lualib.Set
6
7
  local ____exports = {}
7
8
  local ____array = require("functions.array")
@@ -154,10 +155,9 @@ function ____exports.logTemporaryEffects(player)
154
155
  ____exports.log(" n/a (no temporary effects)")
155
156
  return
156
157
  end
157
- do
158
- local i = 0
159
- while i < #effects do
160
- local effect = effects[i + 1]
158
+ __TS__ArrayForEach(
159
+ effects,
160
+ function(____, effect, i)
161
161
  if effect.Item:IsCollectible() then
162
162
  local collectibleName = getCollectibleName(nil, effect.Item.ID)
163
163
  ____exports.log(((" " .. tostring(i + 1)) .. ") ") .. collectibleName)
@@ -169,9 +169,8 @@ function ____exports.logTemporaryEffects(player)
169
169
  else
170
170
  ____exports.log(((" " .. tostring(i + 1)) .. ") Unknown type of temporary effect: ") .. tostring(effect.Item.ID))
171
171
  end
172
- i = i + 1
173
172
  end
174
- end
173
+ )
175
174
  end
176
175
  function ____exports.logSet(set)
177
176
  ____exports.log("Printing out a TSTL Set:")
@@ -45,6 +45,14 @@ export declare function characterCanHaveSoulHearts(character: PlayerType | int):
45
45
  * Otherwise, returns false.
46
46
  */
47
47
  export declare function characterGetsBlackHeartFromEternalHeart(character: PlayerType | int): boolean;
48
+ /**
49
+ * Helper function to get every player with no restrictions, by using `Game.GetNumPlayers` and
50
+ * `Isaac.GetPlayer`.
51
+ *
52
+ * This function is almost never what you want to use. For most intents and purposes, use the
53
+ * `getPlayers()` helper function instead to get a more filtered list of players.
54
+ */
55
+ export declare function getAllPlayers(): EntityPlayer[];
48
56
  /**
49
57
  * Helper function to get how long Azazel's Brimstone laser should be. You can pass either an
50
58
  * `EntityPlayer` object or a tear height stat.
@@ -167,10 +175,12 @@ export declare function getPlayerNumHitsRemaining(player: EntityPlayer): int;
167
175
  * This function always excludes players with a non-undefined parent, since they are not real
168
176
  * players. (e.g. the Strawman Keeper)
169
177
  *
170
- * @param performExclusions Whether or not to exclude characters that are not directly controlled by
171
- * the player (i.e. Esau & Tainted Soul). False by default.
178
+ * If this is not desired, use the `getAllPlayers` helper function instead.
179
+ *
180
+ * @param performCharacterExclusions Whether or not to exclude characters that are not directly
181
+ * controlled by the player (i.e. Esau & Tainted Soul). False by default.
172
182
  */
173
- export declare function getPlayers(performExclusions?: boolean): EntityPlayer[];
183
+ export declare function getPlayers(performCharacterExclusions?: boolean): EntityPlayer[];
174
184
  /**
175
185
  * Helper function to get all of the players that are a certain character.
176
186
  *
@@ -3,8 +3,8 @@ local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArraySome = ____lualib.__TS__ArraySome
6
- local __TS__ArrayMap = ____lualib.__TS__ArrayMap
7
6
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
7
+ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
8
8
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
9
9
  local Map = ____lualib.Map
10
10
  local __TS__Iterator = ____lualib.__TS__Iterator
@@ -35,6 +35,21 @@ local stringContains = ____string.stringContains
35
35
  local trimPrefix = ____string.trimPrefix
36
36
  local ____utils = require("functions.utils")
37
37
  local ensureAllCases = ____utils.ensureAllCases
38
+ local ____repeat = ____utils["repeat"]
39
+ function ____exports.getAllPlayers(self)
40
+ local game = Game()
41
+ local numPlayers = game:GetNumPlayers()
42
+ local players = {}
43
+ do
44
+ local i = 0
45
+ while i < numPlayers do
46
+ local player = Isaac.GetPlayer(i)
47
+ __TS__ArrayPush(players, player)
48
+ i = i + 1
49
+ end
50
+ end
51
+ return players
52
+ end
38
53
  function ____exports.getCharacterMaxHeartContainers(self, character)
39
54
  if character == PlayerType.PLAYER_KEEPER then
40
55
  return 3
@@ -74,15 +89,15 @@ end
74
89
  function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
75
90
  local character = player:GetPlayerType()
76
91
  repeat
77
- local ____switch62 = character
78
- local ____cond62 = ____switch62 == PlayerType.PLAYER_THESOUL
79
- if ____cond62 then
92
+ local ____switch64 = character
93
+ local ____cond64 = ____switch64 == PlayerType.PLAYER_THESOUL
94
+ if ____cond64 then
80
95
  do
81
96
  return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
82
97
  end
83
98
  end
84
- ____cond62 = ____cond62 or ____switch62 == PlayerType.PLAYER_LAZARUS2_B
85
- if ____cond62 then
99
+ ____cond64 = ____cond64 or ____switch64 == PlayerType.PLAYER_LAZARUS2_B
100
+ if ____cond64 then
86
101
  do
87
102
  return CollectibleType.COLLECTIBLE_INNER_EYE
88
103
  end
@@ -110,39 +125,39 @@ end
110
125
  function getAdjustedPlayerName(self, player)
111
126
  local character = player:GetPlayerType()
112
127
  repeat
113
- local ____switch75 = character
114
- local ____cond75 = ____switch75 == PlayerType.PLAYER_BLUEBABY or ____switch75 == PlayerType.PLAYER_BLUEBABY_B
115
- if ____cond75 then
128
+ local ____switch77 = character
129
+ local ____cond77 = ____switch77 == PlayerType.PLAYER_BLUEBABY or ____switch77 == PlayerType.PLAYER_BLUEBABY_B
130
+ if ____cond77 then
116
131
  do
117
132
  return "Blue Baby"
118
133
  end
119
134
  end
120
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2
121
- if ____cond75 then
135
+ ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_LAZARUS2
136
+ if ____cond77 then
122
137
  do
123
138
  return "Lazarus II"
124
139
  end
125
140
  end
126
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_BLACKJUDAS
127
- if ____cond75 then
141
+ ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_BLACKJUDAS
142
+ if ____cond77 then
128
143
  do
129
144
  return "Dark Judas"
130
145
  end
131
146
  end
132
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB
133
- if ____cond75 then
147
+ ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_JACOB
148
+ if ____cond77 then
134
149
  do
135
150
  return "Jacob & Esau"
136
151
  end
137
152
  end
138
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2_B
139
- if ____cond75 then
153
+ ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_LAZARUS2_B
154
+ if ____cond77 then
140
155
  do
141
156
  return "Dead Tainted Lazarus"
142
157
  end
143
158
  end
144
- ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB2_B
145
- if ____cond75 then
159
+ ____cond77 = ____cond77 or ____switch77 == PlayerType.PLAYER_JACOB2_B
160
+ if ____cond77 then
146
161
  do
147
162
  return "Dead Tainted Jacob"
148
163
  end
@@ -154,32 +169,23 @@ function getAdjustedPlayerName(self, player)
154
169
  end
155
170
  until true
156
171
  end
157
- function ____exports.getPlayers(self, performExclusions)
158
- if performExclusions == nil then
159
- performExclusions = false
172
+ function ____exports.getPlayers(self, performCharacterExclusions)
173
+ if performCharacterExclusions == nil then
174
+ performCharacterExclusions = false
160
175
  end
161
- local game = Game()
162
- local numPlayers = game:GetNumPlayers()
163
- local players = {}
164
- do
165
- local i = 0
166
- while i < numPlayers do
167
- do
168
- local player = Isaac.GetPlayer(i)
169
- if ____exports.isChildPlayer(nil, player) then
170
- goto __continue85
171
- end
172
- local character = player:GetPlayerType()
173
- if performExclusions and EXCLUDED_CHARACTERS:has(character) then
174
- goto __continue85
175
- end
176
- __TS__ArrayPush(players, player)
177
- end
178
- ::__continue85::
179
- i = i + 1
176
+ local players = ____exports.getAllPlayers(nil)
177
+ local nonChildPlayers = __TS__ArrayFilter(
178
+ players,
179
+ function(____, player) return not ____exports.isChildPlayer(nil, player) end
180
+ )
181
+ local nonChildPlayersFiltered = __TS__ArrayFilter(
182
+ nonChildPlayers,
183
+ function(____, player)
184
+ local character = player:GetPlayerType()
185
+ return not EXCLUDED_CHARACTERS:has(character)
180
186
  end
181
- end
182
- return players
187
+ )
188
+ return performCharacterExclusions and nonChildPlayersFiltered or nonChildPlayers
183
189
  end
184
190
  function ____exports.getSubPlayerParent(self, subPlayer)
185
191
  local subPlayerPtrHash = GetPtrHash(subPlayer)
@@ -534,13 +540,13 @@ function ____exports.removeCollectibleCostume(self, player, collectibleType)
534
540
  player:RemoveCostume(itemConfigItem)
535
541
  end
536
542
  function ____exports.removeDeadEyeMultiplier(self, player)
537
- do
538
- local i = 0
539
- while i < 100 do
543
+ ____repeat(
544
+ nil,
545
+ 100,
546
+ function()
540
547
  player:ClearDeadEyeCharge()
541
- i = i + 1
542
548
  end
543
- end
549
+ )
544
550
  end
545
551
  function ____exports.removeTrinketCostume(self, player, trinketType)
546
552
  local itemConfig = Isaac.GetItemConfig()
@@ -566,9 +572,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
566
572
  itemPool:RemoveCollectible(collectibleType)
567
573
  end
568
574
  repeat
569
- local ____switch121 = activeSlot
570
- local ____cond121 = ____switch121 == ActiveSlot.SLOT_PRIMARY
571
- if ____cond121 then
575
+ local ____switch122 = activeSlot
576
+ local ____cond122 = ____switch122 == ActiveSlot.SLOT_PRIMARY
577
+ if ____cond122 then
572
578
  do
573
579
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
574
580
  player:RemoveCollectible(primaryCollectibleType)
@@ -577,8 +583,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
577
583
  break
578
584
  end
579
585
  end
580
- ____cond121 = ____cond121 or ____switch121 == ActiveSlot.SLOT_SECONDARY
581
- if ____cond121 then
586
+ ____cond122 = ____cond122 or ____switch122 == ActiveSlot.SLOT_SECONDARY
587
+ if ____cond122 then
582
588
  do
583
589
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
584
590
  player:RemoveCollectible(primaryCollectibleType)
@@ -593,16 +599,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
593
599
  break
594
600
  end
595
601
  end
596
- ____cond121 = ____cond121 or ____switch121 == ActiveSlot.SLOT_POCKET
597
- if ____cond121 then
602
+ ____cond122 = ____cond122 or ____switch122 == ActiveSlot.SLOT_POCKET
603
+ if ____cond122 then
598
604
  do
599
605
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
600
606
  player:SetActiveCharge(charge, activeSlot)
601
607
  break
602
608
  end
603
609
  end
604
- ____cond121 = ____cond121 or ____switch121 == ActiveSlot.SLOT_POCKET2
605
- if ____cond121 then
610
+ ____cond122 = ____cond122 or ____switch122 == ActiveSlot.SLOT_POCKET2
611
+ if ____cond122 then
606
612
  do
607
613
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
608
614
  break
@@ -1,6 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
+ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
4
5
  local ____exports = {}
5
6
  local ____constants = require("constants")
6
7
  local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
@@ -90,10 +91,9 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
90
91
  end
91
92
  player:AddEternalHearts(playerHealth.eternalHearts)
92
93
  local soulHeartsRemaining = playerHealth.soulHearts
93
- do
94
- local i = 0
95
- while i < #playerHealth.soulHeartTypes do
96
- local heartType = playerHealth.soulHeartTypes[i + 1]
94
+ __TS__ArrayForEach(
95
+ playerHealth.soulHeartTypes,
96
+ function(____, heartType, i)
97
97
  local isHalf = playerHealth.soulHearts + playerHealth.boneHearts * 2 < (i + 1) * 2
98
98
  local addAmount = 2
99
99
  if isHalf or heartType == HeartSubType.HEART_BONE or soulHeartsRemaining < 2 then
@@ -108,9 +108,8 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
108
108
  elseif heartType == HeartSubType.HEART_BONE then
109
109
  player:AddBoneHearts(addAmount)
110
110
  end
111
- i = i + 1
112
111
  end
113
- end
112
+ )
114
113
  player:AddRottenHearts(playerHealth.rottenHearts)
115
114
  player:AddHearts(playerHealth.hearts)
116
115
  player:AddGoldenHearts(playerHealth.goldenHearts)
@@ -1,21 +1,14 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
- local ____lualib = require("lualib_bundle")
3
- local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
2
  local ____exports = {}
5
3
  local ____constants = require("constants")
6
4
  local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
5
+ local ____math = require("functions.math")
6
+ local range = ____math.range
7
7
  function ____exports.clearSprite(self, sprite, ...)
8
8
  local layerIDs = {...}
9
- local numLayers = sprite:GetLayerCount()
10
9
  if #layerIDs == 0 then
11
- layerIDs = {}
12
- do
13
- local i = 0
14
- while i < numLayers do
15
- __TS__ArrayPush(layerIDs, i)
16
- i = i + 1
17
- end
18
- end
10
+ local numLayers = sprite:GetLayerCount()
11
+ layerIDs = range(nil, 0, numLayers - 1)
19
12
  end
20
13
  for ____, layerID in ipairs(layerIDs) do
21
14
  sprite:ReplaceSpritesheet(layerID, EMPTY_PNG_PATH)
package/dist/index.d.ts CHANGED
@@ -61,14 +61,19 @@ export * from "./functions/trinketSet";
61
61
  export * from "./functions/ui";
62
62
  export * from "./functions/utils";
63
63
  export * from "./functions/vector";
64
+ export * from "./maps/cardDescriptionMap";
64
65
  export * from "./maps/cardNameMap";
66
+ export * from "./maps/challengeNameMap";
67
+ export * from "./maps/collectibleDescriptionMap";
65
68
  export * from "./maps/collectibleNameMap";
69
+ export * from "./maps/gridEntityTypeToBrokenStateMap";
66
70
  export * from "./maps/gridEntityXMLMap";
67
71
  export * from "./maps/pillEffectClassMap";
68
72
  export * from "./maps/pillEffectNameMap";
69
73
  export * from "./maps/pillEffectTypeMap";
70
74
  export * from "./maps/roomShapeToTopLeftWallGridIndexMap";
71
75
  export * from "./maps/transformationNameMap";
76
+ export * from "./maps/trinketDescriptionMap";
72
77
  export * from "./maps/trinketNameMap";
73
78
  export * from "./sets/cards";
74
79
  export * from "./types/AnyEntity";
package/dist/index.lua CHANGED
@@ -498,6 +498,14 @@ do
498
498
  end
499
499
  end
500
500
  end
501
+ do
502
+ local ____export = require("maps.cardDescriptionMap")
503
+ for ____exportKey, ____exportValue in pairs(____export) do
504
+ if ____exportKey ~= "default" then
505
+ ____exports[____exportKey] = ____exportValue
506
+ end
507
+ end
508
+ end
501
509
  do
502
510
  local ____export = require("maps.cardNameMap")
503
511
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -506,6 +514,22 @@ do
506
514
  end
507
515
  end
508
516
  end
517
+ do
518
+ local ____export = require("maps.challengeNameMap")
519
+ for ____exportKey, ____exportValue in pairs(____export) do
520
+ if ____exportKey ~= "default" then
521
+ ____exports[____exportKey] = ____exportValue
522
+ end
523
+ end
524
+ end
525
+ do
526
+ local ____export = require("maps.collectibleDescriptionMap")
527
+ for ____exportKey, ____exportValue in pairs(____export) do
528
+ if ____exportKey ~= "default" then
529
+ ____exports[____exportKey] = ____exportValue
530
+ end
531
+ end
532
+ end
509
533
  do
510
534
  local ____export = require("maps.collectibleNameMap")
511
535
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -514,6 +538,14 @@ do
514
538
  end
515
539
  end
516
540
  end
541
+ do
542
+ local ____export = require("maps.gridEntityTypeToBrokenStateMap")
543
+ for ____exportKey, ____exportValue in pairs(____export) do
544
+ if ____exportKey ~= "default" then
545
+ ____exports[____exportKey] = ____exportValue
546
+ end
547
+ end
548
+ end
517
549
  do
518
550
  local ____export = require("maps.gridEntityXMLMap")
519
551
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -562,6 +594,14 @@ do
562
594
  end
563
595
  end
564
596
  end
597
+ do
598
+ local ____export = require("maps.trinketDescriptionMap")
599
+ for ____exportKey, ____exportValue in pairs(____export) do
600
+ if ____exportKey ~= "default" then
601
+ ____exports[____exportKey] = ____exportValue
602
+ end
603
+ end
604
+ end
565
605
  do
566
606
  local ____export = require("maps.trinketNameMap")
567
607
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -0,0 +1,2 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare const GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP: ReadonlyMap<GridEntityType, int>;
@@ -0,0 +1,20 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Map = ____lualib.Map
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ ____exports.GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP = __TS__New(Map, {
7
+ {GridEntityType.GRID_ROCK, 2},
8
+ {GridEntityType.GRID_ROCKT, 2},
9
+ {GridEntityType.GRID_ROCK_BOMB, 2},
10
+ {GridEntityType.GRID_ROCK_ALT, 2},
11
+ {GridEntityType.GRID_SPIDERWEB, 1},
12
+ {GridEntityType.GRID_LOCK, 1},
13
+ {GridEntityType.GRID_TNT, 4},
14
+ {GridEntityType.GRID_POOP, 1000},
15
+ {GridEntityType.GRID_ROCK_SS, 2},
16
+ {GridEntityType.GRID_ROCK_SPIKED, 2},
17
+ {GridEntityType.GRID_ROCK_ALT2, 2},
18
+ {GridEntityType.GRID_ROCK_GOLD, 2}
19
+ })
20
+ return ____exports
@@ -2,9 +2,9 @@
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local __TS__StringSplit = ____lualib.__TS__StringSplit
4
4
  local __TS__StringIncludes = ____lualib.__TS__StringIncludes
5
- local __TS__ArraySplice = ____lualib.__TS__ArraySplice
5
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
6
  local ____exports = {}
7
- local errorWithTraceback, slimTracebackOutput, removeAnyLineThatContains, LINE_SEPARATOR, USELESS_TRACEBACK_MESSAGES, vanillaError
7
+ local errorWithTraceback, slimTracebackOutput, removeLinesContaining, LINE_SEPARATOR, USELESS_TRACEBACK_MESSAGES, vanillaError
8
8
  local ____debug = require("functions.debug")
9
9
  local getTraceback = ____debug.getTraceback
10
10
  local ____utils = require("functions.utils")
@@ -24,23 +24,17 @@ function errorWithTraceback(message, level)
24
24
  end
25
25
  function slimTracebackOutput(self, tracebackOutput)
26
26
  for ____, msg in ipairs(USELESS_TRACEBACK_MESSAGES) do
27
- tracebackOutput = removeAnyLineThatContains(nil, tracebackOutput, msg)
27
+ tracebackOutput = removeLinesContaining(nil, tracebackOutput, msg)
28
28
  end
29
29
  return tracebackOutput
30
30
  end
31
- function removeAnyLineThatContains(self, msg, containsMsg)
31
+ function removeLinesContaining(self, msg, containsMsg)
32
32
  local lines = __TS__StringSplit(msg, LINE_SEPARATOR)
33
- do
34
- local i = 0
35
- while i < #lines do
36
- local line = lines[i + 1]
37
- if __TS__StringIncludes(line, containsMsg) then
38
- __TS__ArraySplice(lines, i, 1)
39
- end
40
- i = i + 1
41
- end
42
- end
43
- return table.concat(lines, LINE_SEPARATOR or ",")
33
+ local linesThatDontContain = __TS__ArrayFilter(
34
+ lines,
35
+ function(____, line) return not __TS__StringIncludes(line, containsMsg) end
36
+ )
37
+ return table.concat(linesThatDontContain, LINE_SEPARATOR or ",")
44
38
  end
45
39
  LINE_SEPARATOR = "\n"
46
40
  USELESS_TRACEBACK_MESSAGES = {"in upvalue 'getTraceback'", "in function 'sandbox.GetTraceback'", "in function 'error'"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.72",
3
+ "version": "1.2.75",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.0",
29
- "isaac-typescript-definitions": "^1.0.349",
29
+ "isaac-typescript-definitions": "^1.0.353",
30
30
  "isaacscript-lint": "^1.0.81",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.12",