isaacscript-common 1.0.492 → 1.0.493

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.
@@ -56,7 +56,14 @@ export declare function isGlitchedCollectible(entity: Entity): boolean;
56
56
  */
57
57
  export declare function isPassiveCollectible(collectibleType: CollectibleType | int): boolean;
58
58
  export declare function isQuestCollectible(collectibleType: CollectibleType | int): boolean;
59
- export declare function removeAllCollectibles(): void;
59
+ /**
60
+ * Helper function to remove all of the collectibles in the room.
61
+ *
62
+ * @param collectibleType Optional. If specified, will only remove collectibles that match this
63
+ * collectible type.
64
+ * @param cap Optional. If specified, will only remove the given amount of collectibles.
65
+ */
66
+ export declare function removeAllCollectibles(collectibleType?: CollectibleType | int, cap?: int): void;
60
67
  /**
61
68
  * Helper function to remove all pickup delay on a collectible. By default, collectibles have a 20
62
69
  * frame delay before they can be picked up by a player.
@@ -7,7 +7,7 @@ local COLLECTIBLE_DESCRIPTION_MAP = ____collectibleDescriptionMap.COLLECTIBLE_DE
7
7
  local ____collectibleNameMap = require("maps.collectibleNameMap")
8
8
  local COLLECTIBLE_NAME_MAP = ____collectibleNameMap.COLLECTIBLE_NAME_MAP
9
9
  local ____entity = require("functions.entity")
10
- local removeAllMatchingEntities = ____entity.removeAllMatchingEntities
10
+ local removeAllPickups = ____entity.removeAllPickups
11
11
  function ____exports.setCollectibleSprite(self, collectible, pngPath)
12
12
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
13
13
  error("You cannot set a collectible sprite for pickups of variant: " .. tostring(collectible.Variant))
@@ -136,8 +136,8 @@ end
136
136
  function ____exports.isQuestCollectible(self, collectibleType)
137
137
  return ____exports.collectibleHasTag(nil, collectibleType, 32768)
138
138
  end
139
- function ____exports.removeAllCollectibles(self)
140
- removeAllMatchingEntities(nil, EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE)
139
+ function ____exports.removeAllCollectibles(self, collectibleType, cap)
140
+ removeAllPickups(nil, PickupVariant.PICKUP_COLLECTIBLE, collectibleType, cap)
141
141
  end
142
142
  function ____exports.removeCollectiblePickupDelay(self, collectible)
143
143
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
@@ -152,17 +152,88 @@ export declare function getSlots(matchingVariant?: number, matchingSubType?: num
152
152
  * ```
153
153
  */
154
154
  export declare function getTears(matchingVariant?: number, matchingSubType?: number): EntityTear[];
155
- /** Removes all of the entities in the supplied array. */
156
- export declare function removeEntities(entities: Entity[]): void;
157
- export declare function removeAllBombs(): void;
158
- export declare function removeAllEffects(): void;
159
- export declare function removeAllFamiliars(): void;
160
- export declare function removeAllKnives(): void;
161
- export declare function removeAllLasers(): void;
162
- export declare function removeAllMatchingEntities(entityType: int, entityVariant?: number, entitySubType?: number): void;
163
- export declare function removeAllPickups(): void;
164
- export declare function removeAllProjectiles(): void;
165
- export declare function removeAllTears(): void;
155
+ /**
156
+ * Helper function to remove all of the entities in the supplied array.
157
+ *
158
+ * @param entities The array of entities to remove.
159
+ * @param cap Optional. If specified, will only remove the given amount of entities.
160
+ */
161
+ export declare function removeEntities(entities: Entity[], cap?: int): void;
162
+ /**
163
+ * Helper function to remove all of the bombs in the room.
164
+ *
165
+ * @param variant Optional. If specified, will only remove bombs that match this variant.
166
+ * @param subType Optional. If specified, will only remove bombs that match this sub-type.
167
+ * @param cap Optional. If specified, will only remove the given amount of bombs.
168
+ */
169
+ export declare function removeAllBombs(variant?: BombVariant, subType?: int, cap?: int): void;
170
+ /**
171
+ * Helper function to remove all of the effects in the room.
172
+ *
173
+ * @param variant Optional. If specified, will only remove effects that match this variant.
174
+ * @param subType Optional. If specified, will only remove effects that match this sub-type.
175
+ * @param cap Optional. If specified, will only remove the given amount of effects.
176
+ */
177
+ export declare function removeAllEffects(variant?: EffectVariant, subType?: int, cap?: int): void;
178
+ /**
179
+ * Helper function to remove all of the familiars in the room.
180
+ *
181
+ * @param variant Optional. If specified, will only remove familiars that match this variant.
182
+ * @param subType Optional. If specified, will only remove familiars that match this sub-type.
183
+ * @param cap Optional. If specified, will only remove the given amount of familiars.
184
+ */
185
+ export declare function removeAllFamiliars(variant?: FamiliarVariant, subType?: int, cap?: int): void;
186
+ /**
187
+ * Helper function to remove all of the knives in the room.
188
+ *
189
+ * @param variant Optional. If specified, will only remove knives that match this variant.
190
+ * @param subType Optional. If specified, will only remove knives that match this sub-type.
191
+ * @param cap Optional. If specified, will only remove the given amount of knives.
192
+ */
193
+ export declare function removeAllKnives(variant?: KnifeVariant, subType?: int, cap?: int): void;
194
+ /**
195
+ * Helper function to remove all of the lasers in the room.
196
+ *
197
+ * @param variant Optional. If specified, will only remove lasers that match this variant.
198
+ * @param subType Optional. If specified, will only remove lasers that match this sub-type.
199
+ * @param cap Optional. If specified, will only remove the given amount of lasers.
200
+ */
201
+ export declare function removeAllLasers(variant?: LaserVariant, subType?: int, cap?: int): void;
202
+ /**
203
+ * Helper function to remove all of the matching entities in the room.
204
+ *
205
+ * @param entityType The entity type to match.
206
+ * @param entityVariant Optional. The variant to match. -1 by default (which will match every
207
+ * variant).
208
+ * @param entitySubType Optional. The sub-type to match. -1 by default (which will match every
209
+ * sub-type).
210
+ * @param cap Optional. If specified, will only remove the given amount of collectibles.
211
+ */
212
+ export declare function removeAllMatchingEntities(entityType: int, entityVariant?: number, entitySubType?: number, cap?: int | undefined): void;
213
+ /**
214
+ * Helper function to remove all of the pickups in the room.
215
+ *
216
+ * @param variant Optional. If specified, will only remove pickups that match this variant.
217
+ * @param subType Optional. If specified, will only remove pickups that match this sub-type.
218
+ * @param cap Optional. If specified, will only remove the given amount of pickups.
219
+ */
220
+ export declare function removeAllPickups(variant?: PickupVariant, subType?: int, cap?: int): void;
221
+ /**
222
+ * Helper function to remove all of the projectiles in the room.
223
+ *
224
+ * @param variant Optional. If specified, will only remove projectiles that match this variant.
225
+ * @param subType Optional. If specified, will only remove projectiles that match this sub-type.
226
+ * @param cap Optional. If specified, will only remove the given amount of projectiles.
227
+ */
228
+ export declare function removeAllProjectiles(variant?: ProjectileVariant, subType?: int, cap?: int): void;
229
+ /**
230
+ * Helper function to remove all of the tears in the room.
231
+ *
232
+ * @param variant Optional. If specified, will only remove tears that match this variant.
233
+ * @param subType Optional. If specified, will only remove tears that match this sub-type.
234
+ * @param cap Optional. If specified, will only remove the given amount of tears.
235
+ */
236
+ export declare function removeAllTears(variant?: TearVariant, subType?: int, cap?: int): void;
166
237
  /**
167
238
  * Helper function to set the position of every entity in the room based on a map of positions. If
168
239
  * an entity is found that does not have matching element in the provided map, then that entity will
@@ -210,68 +210,65 @@ function ____exports.getTears(self, matchingVariant, matchingSubType)
210
210
  end
211
211
  return tears
212
212
  end
213
- function ____exports.removeEntities(self, entities)
214
- for ____, entity in ipairs(entities) do
215
- entity:Remove()
213
+ function ____exports.removeEntities(self, entities, cap)
214
+ local numEntitiesRemoved = 0
215
+ do
216
+ local i = 0
217
+ while i < #entities do
218
+ local entity = entities[i + 1]
219
+ entity:Remove()
220
+ numEntitiesRemoved = numEntitiesRemoved + 1
221
+ if cap ~= nil and numEntitiesRemoved >= cap then
222
+ return
223
+ end
224
+ i = i + 1
225
+ end
216
226
  end
217
227
  end
218
- function ____exports.removeAllBombs(self)
219
- local bombs = ____exports.getBombs(nil)
220
- for ____, bomb in ipairs(bombs) do
221
- bomb:Remove()
222
- end
228
+ function ____exports.removeAllBombs(self, variant, subType, cap)
229
+ local bombs = ____exports.getBombs(nil, variant, subType)
230
+ ____exports.removeEntities(nil, bombs, cap)
223
231
  end
224
- function ____exports.removeAllEffects(self)
225
- local effects = ____exports.getEffects(nil)
226
- for ____, effect in ipairs(effects) do
227
- effect:Remove()
228
- end
232
+ function ____exports.removeAllEffects(self, variant, subType, cap)
233
+ local effects = ____exports.getEffects(nil, variant, subType)
234
+ ____exports.removeEntities(nil, effects, cap)
229
235
  end
230
- function ____exports.removeAllFamiliars(self)
231
- local familiars = ____exports.getFamiliars(nil)
232
- for ____, familiar in ipairs(familiars) do
233
- familiar:Remove()
234
- end
236
+ function ____exports.removeAllFamiliars(self, variant, subType, cap)
237
+ local familiars = ____exports.getFamiliars(nil, variant, subType)
238
+ ____exports.removeEntities(nil, familiars, cap)
235
239
  end
236
- function ____exports.removeAllKnives(self)
237
- local knives = ____exports.getKnives(nil)
238
- for ____, knife in ipairs(knives) do
239
- knife:Remove()
240
- end
240
+ function ____exports.removeAllKnives(self, variant, subType, cap)
241
+ local knives = ____exports.getKnives(nil, variant, subType)
242
+ ____exports.removeEntities(nil, knives, cap)
241
243
  end
242
- function ____exports.removeAllLasers(self)
243
- local lasers = ____exports.getLasers(nil)
244
- for ____, laser in ipairs(lasers) do
245
- laser:Remove()
246
- end
244
+ function ____exports.removeAllLasers(self, variant, subType, cap)
245
+ local lasers = ____exports.getLasers(nil, variant, subType)
246
+ ____exports.removeEntities(nil, lasers, cap)
247
247
  end
248
- function ____exports.removeAllMatchingEntities(self, entityType, entityVariant, entitySubType)
248
+ function ____exports.removeAllMatchingEntities(self, entityType, entityVariant, entitySubType, cap)
249
249
  if entityVariant == nil then
250
250
  entityVariant = -1
251
251
  end
252
252
  if entitySubType == nil then
253
253
  entitySubType = -1
254
254
  end
255
+ if cap == nil then
256
+ cap = nil
257
+ end
255
258
  local entities = Isaac.FindByType(entityType, entityVariant, entitySubType)
256
- ____exports.removeEntities(nil, entities)
259
+ ____exports.removeEntities(nil, entities, cap)
257
260
  end
258
- function ____exports.removeAllPickups(self)
259
- local pickups = ____exports.getPickups(nil)
260
- for ____, pickup in ipairs(pickups) do
261
- pickup:Remove()
262
- end
261
+ function ____exports.removeAllPickups(self, variant, subType, cap)
262
+ local pickups = ____exports.getPickups(nil, variant, subType)
263
+ ____exports.removeEntities(nil, pickups, cap)
263
264
  end
264
- function ____exports.removeAllProjectiles(self)
265
- local projectiles = ____exports.getProjectiles(nil)
266
- for ____, projectile in ipairs(projectiles) do
267
- projectile:Remove()
268
- end
265
+ function ____exports.removeAllProjectiles(self, variant, subType, cap)
266
+ local projectiles = ____exports.getProjectiles(nil, variant, subType)
267
+ ____exports.removeEntities(nil, projectiles, cap)
269
268
  end
270
- function ____exports.removeAllTears(self)
271
- local tears = ____exports.getTears(nil)
272
- for ____, tear in ipairs(tears) do
273
- tear:Remove()
274
- end
269
+ function ____exports.removeAllTears(self, variant, subType, cap)
270
+ local tears = ____exports.getTears(nil, variant, subType)
271
+ ____exports.removeEntities(nil, tears, cap)
275
272
  end
276
273
  function ____exports.setEntityPositions(self, entityPositions, entities)
277
274
  if entities == nil then
@@ -39,7 +39,8 @@ export declare function isAllPressurePlatesPushed(): boolean;
39
39
  */
40
40
  export declare function isPostBossVoidPortal(gridEntity: GridEntity): boolean;
41
41
  /**
42
- * Helper function to remove most grid entities in the room.
42
+ * Helper function to all grid entities in the room except for ones matching the grid entity types
43
+ * provided.
43
44
  *
44
45
  * Example:
45
46
  * ```
@@ -50,7 +51,20 @@ export declare function isPostBossVoidPortal(gridEntity: GridEntity): boolean;
50
51
  * ```
51
52
  */
52
53
  export declare function removeAllGridEntitiesExceptFor(...gridEntityTypes: GridEntityType[]): void;
53
- export declare function removeAllMatchingGridEntities(gridEntityType: GridEntityType): void;
54
+ /**
55
+ * Helper function to remove all of the grid entities in the room that match the grid entity types
56
+ * provided.
57
+ *
58
+ * Example:
59
+ * ```
60
+ * removeAllMatchingGridEntities(
61
+ * GridEntityType.GRID_ROCK,
62
+ * GridEntityType.GRID_ROCKB,
63
+ * GridEntityType.GRID_ROCKT,
64
+ * );
65
+ * ```
66
+ */
67
+ export declare function removeAllMatchingGridEntities(...gridEntityType: GridEntityType[]): void;
54
68
  /**
55
69
  * Helper function to remove a grid entity simply by providing the grid entity object.
56
70
  *
@@ -130,8 +130,8 @@ function ____exports.removeAllGridEntitiesExceptFor(self, ...)
130
130
  end
131
131
  roomUpdateSafe(nil)
132
132
  end
133
- function ____exports.removeAllMatchingGridEntities(self, gridEntityType)
134
- local gridEntities = ____exports.getGridEntities(nil, gridEntityType)
133
+ function ____exports.removeAllMatchingGridEntities(self, ...)
134
+ local gridEntities = ____exports.getGridEntities(nil, ...)
135
135
  for ____, gridEntity in ipairs(gridEntities) do
136
136
  ____exports.removeGridEntity(nil, gridEntity, false)
137
137
  end
@@ -35,4 +35,9 @@ export declare function isDyingEggyWithNoSpidersLeft(npc: EntityNPC): boolean;
35
35
  * enemies.
36
36
  */
37
37
  export declare function isRaglingDeathPatch(npc: EntityNPC): boolean;
38
- export declare function removeAllNPCs(): void;
38
+ /**
39
+ * Helper function to remove all NPCs in the room.
40
+ *
41
+ * @param cap Optional. If specified, will only remove the given amount of NPCs.
42
+ */
43
+ export declare function removeAllNPCs(cap?: int): void;
@@ -6,6 +6,7 @@ local ____constants = require("constants")
6
6
  local EGGY_STATE_FRAME_OF_FINAL_SPIDER = ____constants.EGGY_STATE_FRAME_OF_FINAL_SPIDER
7
7
  local ____entity = require("functions.entity")
8
8
  local getEntities = ____entity.getEntities
9
+ local removeEntities = ____entity.removeEntities
9
10
  function ____exports.getBosses(self)
10
11
  local bosses = {}
11
12
  for ____, npc in ipairs(____exports.getNPCs(nil)) do
@@ -94,10 +95,8 @@ function ____exports.getAliveNPCs(self)
94
95
  end
95
96
  return aliveNPCs
96
97
  end
97
- function ____exports.removeAllNPCs(self)
98
+ function ____exports.removeAllNPCs(self, cap)
98
99
  local npcs = ____exports.getNPCs(nil)
99
- for ____, npc in ipairs(npcs) do
100
- npc:Remove()
101
- end
100
+ removeEntities(nil, npcs, cap)
102
101
  end
103
102
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.492",
3
+ "version": "1.0.493",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",