isaacscript-common 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/cachedClasses.d.ts +6 -4
  2. package/cachedClasses.lua +4 -4
  3. package/callbacks/postPickupInitFirst.d.ts +1 -0
  4. package/callbacks/postPickupInitFirst.lua +55 -0
  5. package/callbacks/postSlotDestroyed.d.ts +1 -0
  6. package/callbacks/postSlotDestroyed.lua +66 -0
  7. package/callbacks/postSlotRender.lua +3 -21
  8. package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
  9. package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
  10. package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
  11. package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
  12. package/callbacks/subscriptions/postPickupInitFirst.d.ts +3 -0
  13. package/callbacks/subscriptions/postPickupInitFirst.lua +29 -0
  14. package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
  15. package/callbacks/subscriptions/postPitRender.d.ts +1 -0
  16. package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
  17. package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
  18. package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
  19. package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
  20. package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
  21. package/callbacks/subscriptions/postRockRender.d.ts +1 -0
  22. package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
  23. package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
  24. package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
  25. package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
  26. package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
  27. package/classes/DefaultMap.d.ts +1 -2
  28. package/classes/DefaultMap.lua +1 -4
  29. package/enums/ModCallbackCustom.d.ts +61 -39
  30. package/enums/ModCallbackCustom.lua +40 -38
  31. package/features/debugDisplay/exports.d.ts +17 -0
  32. package/features/debugDisplay/v.d.ts +17 -0
  33. package/features/deployJSONRoom.d.ts +1 -0
  34. package/features/saveDataManager/load.lua +12 -8
  35. package/features/saveDataManager/main.lua +10 -3
  36. package/features/saveDataManager/merge.lua +33 -21
  37. package/features/saveDataManager/save.lua +12 -7
  38. package/functions/array.d.ts +2 -0
  39. package/functions/bombs.d.ts +3 -0
  40. package/functions/bombs.lua +12 -0
  41. package/functions/chargeBar.d.ts +1 -0
  42. package/functions/collectibles.d.ts +13 -8
  43. package/functions/collectibles.lua +24 -11
  44. package/functions/deepCopy.lua +35 -26
  45. package/functions/deepCopyTests.lua +8 -5
  46. package/functions/direction.d.ts +8 -0
  47. package/functions/direction.lua +27 -0
  48. package/functions/doors.d.ts +1 -0
  49. package/functions/doors.lua +5 -0
  50. package/functions/entity.d.ts +4 -4
  51. package/functions/entity.lua +8 -8
  52. package/functions/entitySpecific.d.ts +20 -20
  53. package/functions/entitySpecific.lua +10 -10
  54. package/functions/enums.d.ts +2 -0
  55. package/functions/globals.lua +2 -10
  56. package/functions/gridEntitySpecific.d.ts +5 -0
  57. package/functions/isaacAPIClass.d.ts +4 -4
  58. package/functions/isaacAPIClass.lua +6 -6
  59. package/functions/jsonRoom.d.ts +2 -0
  60. package/functions/log.lua +3 -3
  61. package/functions/pickups.d.ts +9 -9
  62. package/functions/player.d.ts +7 -0
  63. package/functions/player.lua +44 -9
  64. package/functions/playerHealth.d.ts +3 -0
  65. package/functions/playerHealth.lua +87 -68
  66. package/functions/playerIndex.d.ts +2 -0
  67. package/functions/positionVelocity.d.ts +3 -0
  68. package/functions/random.d.ts +2 -0
  69. package/functions/revive.d.ts +2 -0
  70. package/functions/rng.d.ts +1 -0
  71. package/functions/saveFile.d.ts +15 -0
  72. package/functions/saveFile.lua +106 -0
  73. package/functions/serialization.lua +2 -2
  74. package/functions/set.d.ts +1 -0
  75. package/functions/sprite.d.ts +2 -0
  76. package/functions/table.d.ts +12 -0
  77. package/functions/table.lua +34 -0
  78. package/functions/tears.d.ts +1 -0
  79. package/functions/tstlClass.d.ts +34 -0
  80. package/functions/tstlClass.lua +54 -9
  81. package/functions/ui.d.ts +2 -0
  82. package/functions/utils.d.ts +15 -0
  83. package/functions/utils.lua +20 -0
  84. package/functions/vector.lua +4 -16
  85. package/index.d.ts +2 -0
  86. package/index.lua +16 -0
  87. package/initCustomCallbacks.lua +6 -0
  88. package/interfaces/AddCallbackParameterCustom.d.ts +2 -0
  89. package/interfaces/ChargeBarSprites.d.ts +1 -0
  90. package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
  91. package/objects/callbackRegisterFunctions.lua +3 -0
  92. package/objects/oppositeDoorSlots.d.ts +4 -0
  93. package/objects/oppositeDoorSlots.lua +15 -0
  94. package/package.json +1 -1
  95. package/types/AnyEntity.d.ts +10 -0
@@ -138,18 +138,18 @@ export declare function npcFireProjectiles(npc: EntityNPC, position: Vector, vel
138
138
  * @param bombVariant Optional. If specified, will only remove bombs that match this variant.
139
139
  * @param subType Optional. If specified, will only remove bombs that match this sub-type.
140
140
  * @param cap Optional. If specified, will only remove the given amount of bombs.
141
- * @returns True if one or more bombs were removed, false otherwise.
141
+ * @returns An array of the bombs that were removed.
142
142
  */
143
- export declare function removeAllBombs(bombVariant?: BombVariant, subType?: int, cap?: int): boolean;
143
+ export declare function removeAllBombs(bombVariant?: BombVariant, subType?: int, cap?: int): EntityBomb[];
144
144
  /**
145
145
  * Helper function to remove all of the effects in the room.
146
146
  *
147
147
  * @param effectVariant Optional. If specified, will only remove effects that match this variant.
148
148
  * @param subType Optional. If specified, will only remove effects that match this sub-type.
149
149
  * @param cap Optional. If specified, will only remove the given amount of effects.
150
- * @returns True if one or more effects were removed, false otherwise.
150
+ * @returns An array of the effects that were removed.
151
151
  */
152
- export declare function removeAllEffects(effectVariant?: EffectVariant, subType?: int, cap?: int): boolean;
152
+ export declare function removeAllEffects(effectVariant?: EffectVariant, subType?: int, cap?: int): EntityEffect[];
153
153
  /**
154
154
  * Helper function to remove all of the familiars in the room.
155
155
  *
@@ -157,43 +157,43 @@ export declare function removeAllEffects(effectVariant?: EffectVariant, subType?
157
157
  * variant.
158
158
  * @param subType Optional. If specified, will only remove familiars that match this sub-type.
159
159
  * @param cap Optional. If specified, will only remove the given amount of familiars.
160
- * @returns True if one or more familiars were removed, false otherwise.
160
+ * @returns An array of the familiars that were removed.
161
161
  */
162
- export declare function removeAllFamiliars(familiarVariant?: FamiliarVariant, subType?: int, cap?: int): boolean;
162
+ export declare function removeAllFamiliars(familiarVariant?: FamiliarVariant, subType?: int, cap?: int): EntityFamiliar[];
163
163
  /**
164
164
  * Helper function to remove all of the `EntityType.KNIFE` in the room.
165
165
  *
166
166
  * @param knifeVariant Optional. If specified, will only remove knives that match this variant.
167
167
  * @param subType Optional. If specified, will only remove knives that match this sub-type.
168
168
  * @param cap Optional. If specified, will only remove the given amount of knives.
169
- * @returns True if one or more knives were removed, false otherwise.
169
+ * @returns An array of the knives that were removed.
170
170
  */
171
- export declare function removeAllKnives(knifeVariant?: KnifeVariant, subType?: int, cap?: int): boolean;
171
+ export declare function removeAllKnives(knifeVariant?: KnifeVariant, subType?: int, cap?: int): EntityKnife[];
172
172
  /**
173
173
  * Helper function to remove all of the `EntityType.LASER` in the room.
174
174
  *
175
175
  * @param laserVariant Optional. If specified, will only remove lasers that match this variant.
176
176
  * @param subType Optional. If specified, will only remove lasers that match this sub-type.
177
177
  * @param cap Optional. If specified, will only remove the given amount of lasers.
178
- * @returns True if one or more lasers were removed, false otherwise.
178
+ * @returns An array of the lasers that were removed.
179
179
  */
180
- export declare function removeAllLasers(laserVariant?: LaserVariant, subType?: int, cap?: int): boolean;
180
+ export declare function removeAllLasers(laserVariant?: LaserVariant, subType?: int, cap?: int): EntityLaser[];
181
181
  /**
182
182
  * Helper function to remove all NPCs in the room.
183
183
  *
184
184
  * @param cap Optional. If specified, will only remove the given amount of NPCs.
185
- * @returns True if one or more NPCs were removed, false otherwise.
185
+ * @returns An array of the NPCs that were removed.
186
186
  */
187
- export declare function removeAllNPCs(cap?: int): boolean;
187
+ export declare function removeAllNPCs(cap?: int): EntityNPC[];
188
188
  /**
189
189
  * Helper function to remove all of the pickups in the room.
190
190
  *
191
191
  * @param pickupVariant Optional. If specified, will only remove pickups that match this variant.
192
192
  * @param subType Optional. If specified, will only remove pickups that match this sub-type.
193
193
  * @param cap Optional. If specified, will only remove the given amount of pickups.
194
- * @returns True if one or more pickups were removed, false otherwise.
194
+ * @returns An array of the pickups that were removed.
195
195
  */
196
- export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?: int, cap?: int): boolean;
196
+ export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?: int, cap?: int): EntityPickup[];
197
197
  /**
198
198
  * Helper function to remove all of the `EntityType.PROJECTILE` in the room.
199
199
  *
@@ -201,27 +201,27 @@ export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?
201
201
  * variant.
202
202
  * @param subType Optional. If specified, will only remove projectiles that match this sub-type.
203
203
  * @param cap Optional. If specified, will only remove the given amount of projectiles.
204
- * @returns True if one or more projectiles were removed, false otherwise.
204
+ * @returns An array of the projectiles that were removed.
205
205
  */
206
- export declare function removeAllProjectiles(projectileVariant?: ProjectileVariant, subType?: int, cap?: int): boolean;
206
+ export declare function removeAllProjectiles(projectileVariant?: ProjectileVariant, subType?: int, cap?: int): EntityProjectile[];
207
207
  /**
208
208
  * Helper function to remove all of the `EntityType.SLOT` in the room.
209
209
  *
210
210
  * @param slotVariant Optional. If specified, will only remove slots that match this variant.
211
211
  * @param subType Optional. If specified, will only remove slots that match this sub-type.
212
212
  * @param cap Optional. If specified, will only remove the given amount of slots.
213
- * @returns True if one or more slots were removed, false otherwise.
213
+ * @returns An array of the slots that were removed.
214
214
  */
215
- export declare function removeAllSlots(slotVariant?: SlotVariant, subType?: int, cap?: int): boolean;
215
+ export declare function removeAllSlots(slotVariant?: SlotVariant, subType?: int, cap?: int): Entity[];
216
216
  /**
217
217
  * Helper function to remove all of the `EntityType.TEAR` in the room.
218
218
  *
219
219
  * @param tearVariant Optional. If specified, will only remove tears that match this variant.
220
220
  * @param subType Optional. If specified, will only remove tears that match this sub-type.
221
221
  * @param cap Optional. If specified, will only remove the given amount of tears.
222
- * @returns True if one or more tears were removed, false otherwise.
222
+ * @returns An array of the tears that were removed.
223
223
  */
224
- export declare function removeAllTears(tearVariant?: TearVariant, subType?: int, cap?: int): boolean;
224
+ export declare function removeAllTears(tearVariant?: TearVariant, subType?: int, cap?: int): EntityTear[];
225
225
  /** Helper function to spawn a `EntityType.BOMB` (4). */
226
226
  export declare function spawnBomb(bombVariant: BombVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityBomb;
227
227
  /** Helper function to spawn a `EntityType.BOMB` (4) with a specific seed. */
@@ -288,7 +288,7 @@ end
288
288
  -- @param bombVariant Optional. If specified, will only remove bombs that match this variant.
289
289
  -- @param subType Optional. If specified, will only remove bombs that match this sub-type.
290
290
  -- @param cap Optional. If specified, will only remove the given amount of bombs.
291
- -- @returns True if one or more bombs were removed, false otherwise.
291
+ -- @returns An array of the bombs that were removed.
292
292
  function ____exports.removeAllBombs(self, bombVariant, subType, cap)
293
293
  local bombs = ____exports.getBombs(nil, bombVariant, subType)
294
294
  return removeEntities(nil, bombs, cap)
@@ -298,7 +298,7 @@ end
298
298
  -- @param effectVariant Optional. If specified, will only remove effects that match this variant.
299
299
  -- @param subType Optional. If specified, will only remove effects that match this sub-type.
300
300
  -- @param cap Optional. If specified, will only remove the given amount of effects.
301
- -- @returns True if one or more effects were removed, false otherwise.
301
+ -- @returns An array of the effects that were removed.
302
302
  function ____exports.removeAllEffects(self, effectVariant, subType, cap)
303
303
  local effects = ____exports.getEffects(nil, effectVariant, subType)
304
304
  return removeEntities(nil, effects, cap)
@@ -309,7 +309,7 @@ end
309
309
  -- variant.
310
310
  -- @param subType Optional. If specified, will only remove familiars that match this sub-type.
311
311
  -- @param cap Optional. If specified, will only remove the given amount of familiars.
312
- -- @returns True if one or more familiars were removed, false otherwise.
312
+ -- @returns An array of the familiars that were removed.
313
313
  function ____exports.removeAllFamiliars(self, familiarVariant, subType, cap)
314
314
  local familiars = ____exports.getFamiliars(nil, familiarVariant, subType)
315
315
  return removeEntities(nil, familiars, cap)
@@ -319,7 +319,7 @@ end
319
319
  -- @param knifeVariant Optional. If specified, will only remove knives that match this variant.
320
320
  -- @param subType Optional. If specified, will only remove knives that match this sub-type.
321
321
  -- @param cap Optional. If specified, will only remove the given amount of knives.
322
- -- @returns True if one or more knives were removed, false otherwise.
322
+ -- @returns An array of the knives that were removed.
323
323
  function ____exports.removeAllKnives(self, knifeVariant, subType, cap)
324
324
  local knives = ____exports.getKnives(nil, knifeVariant, subType)
325
325
  return removeEntities(nil, knives, cap)
@@ -329,7 +329,7 @@ end
329
329
  -- @param laserVariant Optional. If specified, will only remove lasers that match this variant.
330
330
  -- @param subType Optional. If specified, will only remove lasers that match this sub-type.
331
331
  -- @param cap Optional. If specified, will only remove the given amount of lasers.
332
- -- @returns True if one or more lasers were removed, false otherwise.
332
+ -- @returns An array of the lasers that were removed.
333
333
  function ____exports.removeAllLasers(self, laserVariant, subType, cap)
334
334
  local lasers = ____exports.getLasers(nil, laserVariant, subType)
335
335
  return removeEntities(nil, lasers, cap)
@@ -337,7 +337,7 @@ end
337
337
  --- Helper function to remove all NPCs in the room.
338
338
  --
339
339
  -- @param cap Optional. If specified, will only remove the given amount of NPCs.
340
- -- @returns True if one or more NPCs were removed, false otherwise.
340
+ -- @returns An array of the NPCs that were removed.
341
341
  function ____exports.removeAllNPCs(self, cap)
342
342
  local npcs = ____exports.getNPCs(nil)
343
343
  return removeEntities(nil, npcs, cap)
@@ -347,7 +347,7 @@ end
347
347
  -- @param pickupVariant Optional. If specified, will only remove pickups that match this variant.
348
348
  -- @param subType Optional. If specified, will only remove pickups that match this sub-type.
349
349
  -- @param cap Optional. If specified, will only remove the given amount of pickups.
350
- -- @returns True if one or more pickups were removed, false otherwise.
350
+ -- @returns An array of the pickups that were removed.
351
351
  function ____exports.removeAllPickups(self, pickupVariant, subType, cap)
352
352
  local pickups = ____exports.getPickups(nil, pickupVariant, subType)
353
353
  return removeEntities(nil, pickups, cap)
@@ -358,7 +358,7 @@ end
358
358
  -- variant.
359
359
  -- @param subType Optional. If specified, will only remove projectiles that match this sub-type.
360
360
  -- @param cap Optional. If specified, will only remove the given amount of projectiles.
361
- -- @returns True if one or more projectiles were removed, false otherwise.
361
+ -- @returns An array of the projectiles that were removed.
362
362
  function ____exports.removeAllProjectiles(self, projectileVariant, subType, cap)
363
363
  local projectiles = ____exports.getProjectiles(nil, projectileVariant, subType)
364
364
  return removeEntities(nil, projectiles, cap)
@@ -368,7 +368,7 @@ end
368
368
  -- @param slotVariant Optional. If specified, will only remove slots that match this variant.
369
369
  -- @param subType Optional. If specified, will only remove slots that match this sub-type.
370
370
  -- @param cap Optional. If specified, will only remove the given amount of slots.
371
- -- @returns True if one or more slots were removed, false otherwise.
371
+ -- @returns An array of the slots that were removed.
372
372
  function ____exports.removeAllSlots(self, slotVariant, subType, cap)
373
373
  local slots = ____exports.getSlots(nil, slotVariant, subType)
374
374
  return removeEntities(nil, slots, cap)
@@ -378,7 +378,7 @@ end
378
378
  -- @param tearVariant Optional. If specified, will only remove tears that match this variant.
379
379
  -- @param subType Optional. If specified, will only remove tears that match this sub-type.
380
380
  -- @param cap Optional. If specified, will only remove the given amount of tears.
381
- -- @returns True if one or more tears were removed, false otherwise.
381
+ -- @returns An array of the tears that were removed.
382
382
  function ____exports.removeAllTears(self, tearVariant, subType, cap)
383
383
  local tears = ____exports.getTears(nil, tearVariant, subType)
384
384
  return removeEntities(nil, tears, cap)
@@ -1,4 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
2
4
  /**
3
5
  * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
4
6
  * when you iterate over them, you will get both the names of the enums and the values of the enums,
@@ -4,7 +4,6 @@ local __TS__New = ____lualib.__TS__New
4
4
  local __TS__ArraySort = ____lualib.__TS__ArraySort
5
5
  local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
6
6
  local ____exports = {}
7
- local twoDimensionalSort
8
7
  local ____debug = require("functions.debug")
9
8
  local isLuaDebugEnabled = ____debug.isLuaDebugEnabled
10
9
  local ____log = require("functions.log")
@@ -12,15 +11,8 @@ local log = ____log.log
12
11
  local ____set = require("functions.set")
13
12
  local addSetsToSet = ____set.addSetsToSet
14
13
  local copySet = ____set.copySet
15
- function twoDimensionalSort(self, a, b)
16
- if a[1] == nil or b[1] == nil then
17
- error("Failed to two-dimensional sort since the first element of the array was undefined.")
18
- end
19
- if a[1] == b[1] then
20
- return 0
21
- end
22
- return a[1] < b[1] and -1 or 1
23
- end
14
+ local ____utils = require("functions.utils")
15
+ local twoDimensionalSort = ____utils.twoDimensionalSort
24
16
  local DEFAULT_GLOBALS = __TS__New(Set, {
25
17
  "ActionTriggers",
26
18
  "ActiveSlot",
@@ -1,4 +1,9 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
4
+ /// <reference types="isaac-typescript-definitions" />
5
+ /// <reference types="isaac-typescript-definitions" />
6
+ /// <reference types="isaac-typescript-definitions" />
2
7
  /** Helper function to get all of the `GridEntityPit` in the room. */
3
8
  export declare function getPits(): GridEntityPit[];
4
9
  /** Helper function to get all of the `GridEntityPoop` in the room. */
@@ -1,14 +1,14 @@
1
1
  import { IsaacAPIClass } from "../types/private/IsaacAPIClass";
2
2
  /**
3
- * Helper function to get the type of a class from the Isaac API. This is contained within the
4
- * "__type" metatable key. In this context, the type of the class is equivalent to the name.
3
+ * Helper function to get the name of a class from the Isaac API. This is contained within the
4
+ * "__type" metatable key.
5
5
  *
6
- * For example, a `Vector` class is has a type of "Vector".
6
+ * For example, a `Vector` class is has a name of "Vector".
7
7
  *
8
8
  * Returns undefined if the object is not of type `userdata` or if the "__type" metatable key does
9
9
  * not exist.
10
10
  */
11
- export declare function getIsaacAPIClassType(object: unknown): string | undefined;
11
+ export declare function getIsaacAPIClassName(object: unknown): string | undefined;
12
12
  /**
13
13
  * Helper function to check if something is an instantiated class from the Isaac API. (All classes
14
14
  * from the Isaac API have a type of "userdata" in Lua with a metatable key of "__type" equal to the
@@ -1,14 +1,14 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
3
3
  local ____exports = {}
4
- --- Helper function to get the type of a class from the Isaac API. This is contained within the
5
- -- "__type" metatable key. In this context, the type of the class is equivalent to the name.
4
+ --- Helper function to get the name of a class from the Isaac API. This is contained within the
5
+ -- "__type" metatable key.
6
6
  --
7
- -- For example, a `Vector` class is has a type of "Vector".
7
+ -- For example, a `Vector` class is has a name of "Vector".
8
8
  --
9
9
  -- Returns undefined if the object is not of type `userdata` or if the "__type" metatable key does
10
10
  -- not exist.
11
- function ____exports.getIsaacAPIClassType(self, object)
11
+ function ____exports.getIsaacAPIClassName(self, object)
12
12
  local objectType = type(object)
13
13
  if objectType ~= "userdata" then
14
14
  return nil
@@ -27,11 +27,11 @@ end
27
27
  -- from the Isaac API have a type of "userdata" in Lua with a metatable key of "__type" equal to the
28
28
  -- name of the class.)
29
29
  function ____exports.isIsaacAPIClass(self, object)
30
- local isaacAPIClassType = ____exports.getIsaacAPIClassType(nil, object)
30
+ local isaacAPIClassType = ____exports.getIsaacAPIClassName(nil, object)
31
31
  return isaacAPIClassType ~= nil
32
32
  end
33
33
  function ____exports.isIsaacAPIClassOfType(self, object, classType)
34
- local isaacAPIClassType = ____exports.getIsaacAPIClassType(nil, object)
34
+ local isaacAPIClassType = ____exports.getIsaacAPIClassName(nil, object)
35
35
  return isaacAPIClassType == classType or isaacAPIClassType == "const " .. classType
36
36
  end
37
37
  --- Helper function to check if an instantiated Isaac API class is equal to another one of the same
@@ -1,4 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
2
4
  import { JSONRoom } from "../interfaces/JSONRoom";
3
5
  export declare function getJSONRoomOfVariant(jsonRooms: JSONRoom[], variant: int): JSONRoom | undefined;
4
6
  export declare function getJSONRoomsOfSubType(jsonRooms: JSONRoom[], subType: int): JSONRoom[];
package/functions/log.lua CHANGED
@@ -35,7 +35,7 @@ local hasFlag = ____flag.hasFlag
35
35
  local ____gridEntity = require("functions.gridEntity")
36
36
  local getGridEntities = ____gridEntity.getGridEntities
37
37
  local ____isaacAPIClass = require("functions.isaacAPIClass")
38
- local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
38
+ local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
39
39
  local ____player = require("functions.player")
40
40
  local getEffectsList = ____player.getEffectsList
41
41
  local getPlayerName = ____player.getPlayerName
@@ -474,7 +474,7 @@ function ____exports.logTable(____table, parentTables)
474
474
  end
475
475
  numKeys = numKeys + 1
476
476
  end
477
- ____exports.log("The size of the table was: " .. tostring(numKeys))
477
+ ____exports.log((indentation .. "The size of the table was: ") .. tostring(numKeys))
478
478
  end
479
479
  --- Helper function for printing out every tear flag that is turned on. Useful when debugging.
480
480
  function ____exports.logTearFlags(flags)
@@ -497,7 +497,7 @@ function ____exports.logUserdata(userdata)
497
497
  ____exports.log("Userdata: [no metatable]")
498
498
  return
499
499
  end
500
- local classType = getIsaacAPIClassType(nil, userdata)
500
+ local classType = getIsaacAPIClassName(nil, userdata)
501
501
  if classType == nil then
502
502
  ____exports.log("Userdata: [no class type]")
503
503
  else
@@ -33,7 +33,7 @@ export declare function isRedHeart(pickup: EntityPickup): boolean;
33
33
  * @param cap Optional. If specified, will only remove the given amount of cards.
34
34
  * @returns True if one or more cards were removed, false otherwise.
35
35
  */
36
- export declare function removeAllBatteries(batterySubType?: BatterySubType, cap?: int): boolean;
36
+ export declare function removeAllBatteries(batterySubType?: BatterySubType, cap?: int): EntityPickupBattery[];
37
37
  /**
38
38
  * Helper function to remove all of the cards in the room.
39
39
  *
@@ -41,7 +41,7 @@ export declare function removeAllBatteries(batterySubType?: BatterySubType, cap?
41
41
  * @param cap Optional. If specified, will only remove the given amount of cards.
42
42
  * @returns True if one or more cards were removed, false otherwise.
43
43
  */
44
- export declare function removeAllCards(card?: Card, cap?: int): boolean;
44
+ export declare function removeAllCards(card?: Card, cap?: int): EntityPickupCard[];
45
45
  /**
46
46
  * Helper function to remove all of the coins in the room.
47
47
  *
@@ -49,7 +49,7 @@ export declare function removeAllCards(card?: Card, cap?: int): boolean;
49
49
  * @param cap Optional. If specified, will only remove the given amount of coins.
50
50
  * @returns True if one or more coins were removed, false otherwise.
51
51
  */
52
- export declare function removeAllCoins(coinSubType?: CoinSubType, cap?: int): boolean;
52
+ export declare function removeAllCoins(coinSubType?: CoinSubType, cap?: int): EntityPickupCoin[];
53
53
  /**
54
54
  * Helper function to remove all of the collectibles in the room.
55
55
  *
@@ -58,7 +58,7 @@ export declare function removeAllCoins(coinSubType?: CoinSubType, cap?: int): bo
58
58
  * @param cap Optional. If specified, will only remove the given amount of collectibles.
59
59
  * @returns True if one or more collectibles were removed, false otherwise.
60
60
  */
61
- export declare function removeAllCollectibles(collectibleType?: CollectibleType, cap?: int): boolean;
61
+ export declare function removeAllCollectibles(collectibleType?: CollectibleType, cap?: int): EntityPickupCollectible[];
62
62
  /**
63
63
  * Helper function to remove all of the hearts in the room.
64
64
  *
@@ -66,7 +66,7 @@ export declare function removeAllCollectibles(collectibleType?: CollectibleType,
66
66
  * @param cap Optional. If specified, will only remove the given amount of hearts.
67
67
  * @returns True if one or more hearts were removed, false otherwise.
68
68
  */
69
- export declare function removeAllHearts(heartSubType?: HeartSubType, cap?: int): boolean;
69
+ export declare function removeAllHearts(heartSubType?: HeartSubType, cap?: int): EntityPickupHeart[];
70
70
  /**
71
71
  * Helper function to remove all of the keys in the room.
72
72
  *
@@ -74,7 +74,7 @@ export declare function removeAllHearts(heartSubType?: HeartSubType, cap?: int):
74
74
  * @param cap Optional. If specified, will only remove the given amount of keys.
75
75
  * @returns True if one or more keys were removed, false otherwise.
76
76
  */
77
- export declare function removeAllKeys(keySubType?: KeySubType, cap?: int): boolean;
77
+ export declare function removeAllKeys(keySubType?: KeySubType, cap?: int): EntityPickupKey[];
78
78
  /**
79
79
  * Helper function to remove all of the pills in the room.
80
80
  *
@@ -82,7 +82,7 @@ export declare function removeAllKeys(keySubType?: KeySubType, cap?: int): boole
82
82
  * @param cap Optional. If specified, will only remove the given amount of pills.
83
83
  * @returns True if one or more pills were removed, false otherwise.
84
84
  */
85
- export declare function removeAllPills(pillColor?: PillColor, cap?: int): boolean;
85
+ export declare function removeAllPills(pillColor?: PillColor, cap?: int): EntityPickupPill[];
86
86
  /**
87
87
  * Helper function to remove all of the sacks (i.e. grab bags) in the room.
88
88
  *
@@ -90,7 +90,7 @@ export declare function removeAllPills(pillColor?: PillColor, cap?: int): boolea
90
90
  * @param cap Optional. If specified, will only remove the given amount of trinkets.
91
91
  * @returns True if one or more trinkets were removed, false otherwise.
92
92
  */
93
- export declare function removeAllSacks(sackSubType?: SackSubType, cap?: int): boolean;
93
+ export declare function removeAllSacks(sackSubType?: SackSubType, cap?: int): EntityPickupSack[];
94
94
  /**
95
95
  * Helper function to remove all of the trinkets in the room.
96
96
  *
@@ -99,7 +99,7 @@ export declare function removeAllSacks(sackSubType?: SackSubType, cap?: int): bo
99
99
  * @param cap Optional. If specified, will only remove the given amount of trinkets.
100
100
  * @returns True if one or more trinkets were removed, false otherwise.
101
101
  */
102
- export declare function removeAllTrinkets(trinketType?: TrinketType, cap?: int): boolean;
102
+ export declare function removeAllTrinkets(trinketType?: TrinketType, cap?: int): EntityPickupTrinket[];
103
103
  /**
104
104
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.LIL_BATTERY` (90).
105
105
  */
@@ -100,6 +100,8 @@ export declare function getPlayerCollectibleCount(player: EntityPlayer, ...colle
100
100
  * the player has.
101
101
  */
102
102
  export declare function getPlayerCollectibleMap(player: EntityPlayer): Map<CollectibleType, int>;
103
+ /** Helper function to get the player from a tear, laser, bomb, etc. */
104
+ export declare function getPlayerFromTear(entity: Entity): EntityPlayer | undefined;
103
105
  /**
104
106
  * Returns the number of red hearts that the player has, excluding any rotten hearts. For example,
105
107
  * if the player has one full black heart, one full soul heart, and one half black heart, this
@@ -207,6 +209,11 @@ export declare function isBethany(player: EntityPlayer): boolean;
207
209
  * for. Returns true if the player is any of the supplied characters.
208
210
  */
209
211
  export declare function isCharacter(player: EntityPlayer, ...characters: PlayerType[]): boolean;
212
+ /**
213
+ * Helper function to see if a damage source is from a player. Use this instead of comparing to the
214
+ * entity directly because it takes familiars into account.
215
+ */
216
+ export declare function isDamageFromPlayer(damageSource: Entity): boolean;
210
217
  /**
211
218
  * Helper function for detecting when a player is Eden or Tainted Eden. Useful for situations where
212
219
  * you want to know if the starting stats were randomized, for example.
@@ -15,6 +15,7 @@ local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
15
15
  local CacheFlag = ____isaac_2Dtypescript_2Ddefinitions.CacheFlag
16
16
  local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
17
17
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
18
+ local FamiliarVariant = ____isaac_2Dtypescript_2Ddefinitions.FamiliarVariant
18
19
  local NullItemID = ____isaac_2Dtypescript_2Ddefinitions.NullItemID
19
20
  local PlayerForm = ____isaac_2Dtypescript_2Ddefinitions.PlayerForm
20
21
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
@@ -377,6 +378,30 @@ function ____exports.getPlayerCollectibleMap(self, player)
377
378
  end
378
379
  return collectibleMap
379
380
  end
381
+ --- Helper function to get the player from a tear, laser, bomb, etc.
382
+ function ____exports.getPlayerFromTear(self, entity)
383
+ if entity.Parent ~= nil then
384
+ local player = entity.Parent:ToPlayer()
385
+ if player ~= nil then
386
+ return player
387
+ end
388
+ local familiar = entity.Parent:ToFamiliar()
389
+ if familiar ~= nil and familiar.Variant == FamiliarVariant.INCUBUS then
390
+ return familiar.Player
391
+ end
392
+ end
393
+ if entity.SpawnerEntity ~= nil then
394
+ local player = entity.SpawnerEntity:ToPlayer()
395
+ if player ~= nil then
396
+ return player
397
+ end
398
+ local familiar = entity.SpawnerEntity:ToFamiliar()
399
+ if familiar ~= nil and familiar.Variant == FamiliarVariant.INCUBUS then
400
+ return familiar.Player
401
+ end
402
+ end
403
+ return nil
404
+ end
380
405
  --- Returns the number of red hearts that the player has, excluding any rotten hearts. For example,
381
406
  -- if the player has one full black heart, one full soul heart, and one half black heart, this
382
407
  -- function returns 3.
@@ -567,6 +592,16 @@ function ____exports.isBethany(self, player)
567
592
  local character = player:GetPlayerType()
568
593
  return character == PlayerType.BETHANY or character == PlayerType.BETHANY_B
569
594
  end
595
+ --- Helper function to see if a damage source is from a player. Use this instead of comparing to the
596
+ -- entity directly because it takes familiars into account.
597
+ function ____exports.isDamageFromPlayer(self, damageSource)
598
+ local player = damageSource:ToPlayer()
599
+ if player ~= nil then
600
+ return true
601
+ end
602
+ local indirectPlayer = ____exports.getPlayerFromTear(nil, damageSource)
603
+ return indirectPlayer ~= nil
604
+ end
570
605
  --- Helper function for detecting when a player is Eden or Tainted Eden. Useful for situations where
571
606
  -- you want to know if the starting stats were randomized, for example.
572
607
  function ____exports.isEden(self, player)
@@ -684,9 +719,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
684
719
  itemPool:RemoveCollectible(collectibleType)
685
720
  end
686
721
  repeat
687
- local ____switch113 = activeSlot
688
- local ____cond113 = ____switch113 == ActiveSlot.PRIMARY
689
- if ____cond113 then
722
+ local ____switch122 = activeSlot
723
+ local ____cond122 = ____switch122 == ActiveSlot.PRIMARY
724
+ if ____cond122 then
690
725
  do
691
726
  if primaryCollectibleType ~= CollectibleType.NULL then
692
727
  player:RemoveCollectible(primaryCollectibleType)
@@ -695,8 +730,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
695
730
  break
696
731
  end
697
732
  end
698
- ____cond113 = ____cond113 or ____switch113 == ActiveSlot.SECONDARY
699
- if ____cond113 then
733
+ ____cond122 = ____cond122 or ____switch122 == ActiveSlot.SECONDARY
734
+ if ____cond122 then
700
735
  do
701
736
  if primaryCollectibleType ~= CollectibleType.NULL then
702
737
  player:RemoveCollectible(primaryCollectibleType)
@@ -711,16 +746,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
711
746
  break
712
747
  end
713
748
  end
714
- ____cond113 = ____cond113 or ____switch113 == ActiveSlot.POCKET
715
- if ____cond113 then
749
+ ____cond122 = ____cond122 or ____switch122 == ActiveSlot.POCKET
750
+ if ____cond122 then
716
751
  do
717
752
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
718
753
  player:SetActiveCharge(charge, activeSlot)
719
754
  break
720
755
  end
721
756
  end
722
- ____cond113 = ____cond113 or ____switch113 == ActiveSlot.POCKET_SINGLE_USE
723
- if ____cond113 then
757
+ ____cond122 = ____cond122 or ____switch122 == ActiveSlot.POCKET_SINGLE_USE
758
+ if ____cond122 then
724
759
  do
725
760
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
726
761
  break
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
2
3
  import { HealthType } from "../enums/HealthType";
3
4
  import { PlayerHealth } from "../interfaces/PlayerHealth";
4
5
  export declare function addPlayerHealthType(player: EntityPlayer, healthType: HealthType, numHearts: int): void;
@@ -11,6 +12,8 @@ export declare function addPlayerHealthType(player: EntityPlayer, healthType: He
11
12
  */
12
13
  export declare function getPlayerHealth(player: EntityPlayer): PlayerHealth;
13
14
  export declare function getPlayerHealthType(player: EntityPlayer, healthType: HealthType): int;
15
+ export declare function playerConvertBlackHeartsToSoulHearts(player: EntityPlayer): void;
16
+ export declare function playerConvertSoulHeartsToBlackHearts(player: EntityPlayer): void;
14
17
  export declare function removeAllPlayerHealth(player: EntityPlayer): void;
15
18
  /**
16
19
  * Helper function to set a player's health to a specific state. You can use this in combination