isaacscript-common 20.1.0 → 20.1.1

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.
package/dist/index.d.ts CHANGED
@@ -1268,16 +1268,22 @@ export declare function clearCollectibleSprite(collectible: EntityPickup): void;
1268
1268
  export declare function clearFloorDisplayFlags(): void;
1269
1269
 
1270
1270
  /**
1271
- * Helper function to clear all layers or specific layers from a sprite.
1271
+ * Helper function to clear all layers or specific layers from a sprite without unloading the
1272
+ * attached anm2 file.
1272
1273
  *
1273
- * This function is variadic, so pass as many layer IDs as you want to clear. If no specific layers
1274
- * are passed, it will clear every layer.
1274
+ * This function is variadic, which means you can pass as many layer IDs as you want to clear. If no
1275
+ * specific layers are passed, the function will clear every layer.
1275
1276
  *
1276
- * Since there is no official API method to "clear" a sprite, we can work around it by setting the
1277
- * spritesheet to a non-existent or completely transparent file. If the path to the spritesheet does
1278
- * not exist, then this function might cause spurious errors to appear in the "log.txt file". To
1279
- * silence these errors, create a transparent 1 pixel PNG file in your mod's resources folder at the
1280
- * path corresponding to the "EMPTY_PNG_PATH" constant.
1277
+ * If you want to clear all of the layers of a sprite and don't care about unloading the attached
1278
+ * anm2 file, then use the `Sprite.Reset` method instead.
1279
+ *
1280
+ * Since there is no official API method to clear specific layers from a sprite, we work around it
1281
+ * by setting the spritesheet to a transparent PNG file corresponding to the `EMPTY_PNG_PATH`
1282
+ * constant.
1283
+ *
1284
+ * This function will still work identically if PNG file does not exist, but it will cause a
1285
+ * spurious error to appear in the "log.txt" file. If silencing these errors is desired, you can
1286
+ * create a transparent 1 pixel PNG file in your mod's resources folder at `EMPTY_PNG_PATH`.
1281
1287
  */
1282
1288
  export declare function clearSprite(sprite: Sprite, ...layerIDs: int[]): void;
1283
1289
 
@@ -13843,10 +13849,11 @@ export declare function setEntityVelocities(entityVelocities: Map<PtrHash, Vecto
13843
13849
  export declare function setFloorDisplayFlags(displayFlagsMap: Map<int, BitFlags<DisplayFlag>>): void;
13844
13850
 
13845
13851
  /**
13846
- * Helper function to make a grid entity invisible. This is accomplished by setting its sprite to an
13847
- * empty/missing PNG file.
13852
+ * Helper function to make a grid entity invisible. This is accomplished by resetting the sprite.
13848
13853
  *
13849
- * For more information, see the documentation for the `clearSprite` helper function.
13854
+ * Note that this function is destructive such that once you make a grid entity invisible, it can no
13855
+ * longer become visible. (This is because the information about the sprite is lost when it is
13856
+ * reset.)
13850
13857
  */
13851
13858
  export declare function setGridEntityInvisible(gridEntity: GridEntity): void;
13852
13859
 
@@ -13940,8 +13947,8 @@ export declare function setTracebackFunctionsGlobal(): void;
13940
13947
  * @param trinket The trinket whose sprite you want to modify.
13941
13948
  * @param pngPath Equal to either the spritesheet path to load (e.g.
13942
13949
  * "gfx/items/trinkets/trinket_001_swallowedpenny.png") or undefined. If undefined,
13943
- * the sprite will be removed, making it appear like the collectible has already been
13944
- * taken by the player.
13950
+ * the sprite will be removed, making the trinket effectively invisible (except for
13951
+ * the shadow underneath it).
13945
13952
  */
13946
13953
  export declare function setTrinketSprite(trinket: EntityPickup, pngPath: string | undefined): void;
13947
13954
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 20.1.0
3
+ isaacscript-common 20.1.1
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -25948,8 +25948,6 @@ local ____math = require("src.functions.math")
25948
25948
  local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
25949
25949
  local ____rooms = require("src.functions.rooms")
25950
25950
  local roomUpdateSafe = ____rooms.roomUpdateSafe
25951
- local ____sprites = require("src.functions.sprites")
25952
- local clearSprite = ____sprites.clearSprite
25953
25951
  local ____types = require("src.functions.types")
25954
25952
  local asNumber = ____types.asNumber
25955
25953
  local isNumber = ____types.isNumber
@@ -26289,7 +26287,7 @@ function ____exports.removeGridEntities(self, gridEntities, updateRoom, cap)
26289
26287
  end
26290
26288
  function ____exports.setGridEntityInvisible(self, gridEntity)
26291
26289
  local sprite = gridEntity:GetSprite()
26292
- clearSprite(nil, sprite)
26290
+ sprite:Reset()
26293
26291
  end
26294
26292
  function ____exports.spawnGiantPoop(self, topLeftGridIndex)
26295
26293
  local room = game:GetRoom()
@@ -27429,7 +27427,7 @@ function ____exports.setTrinketSprite(self, trinket, pngPath)
27429
27427
  end
27430
27428
  local sprite = trinket:GetSprite()
27431
27429
  if pngPath == nil then
27432
- clearSprite(nil, sprite, TRINKET_SPRITE_LAYER)
27430
+ clearSprite(nil, sprite)
27433
27431
  else
27434
27432
  sprite:ReplaceSpritesheet(TRINKET_SPRITE_LAYER, pngPath)
27435
27433
  sprite:LoadGraphics()
@@ -1 +1 @@
1
- {"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,uBAAuB,EAEvB,eAAe,EAEf,oBAAoB,EACpB,aAAa,EAEb,QAAQ,EACR,WAAW,EAIZ,MAAM,8BAA8B,CAAC;AAgBtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAyB7D,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAEtE;AAED,iGAAiG;AACjG,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,GACnB,OAAO,CAOT;AAED,6FAA6F;AAC7F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAsBT;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,GAC/B,oBAAoB,CAOtB;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAeR;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,eAAe,EAAE,eAAe,GAC/B,GAAG,CAYL;AAED;;;GAGG;AACH,wBAAgB,6BAA6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EAAE,eAAe,GAAG,OAAO,CAG7E;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,CAgB7E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gCAAgC,CAC9C,eAAe,EAAE,eAAe,GAC/B,IAAI,CAQN;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAS5E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CASnE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAUnE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAuBtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAqBN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,YAAY,EACzB,kBAAkB,EAAE,eAAe,GAClC,IAAI,CA2BN;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAK5D"}
1
+ {"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../../src/functions/collectibles.ts"],"names":[],"mappings":"AA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CAC9C,eAAe,EAAE,eAAe,GAC/B,IAAI,CAQN;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAS5E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CASnE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAUnE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAuBtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAqBN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,YAAY,EACzB,kBAAkB,EAAE,eAAe,GAClC,IAAI,CA2BN;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAK5D"}
@@ -183,10 +183,11 @@ export declare function removeGridEntities<T extends AnyGridEntity>(gridEntities
183
183
  */
184
184
  export declare function removeGridEntity(gridEntityOrGridIndex: GridEntity | int, updateRoom: boolean): void;
185
185
  /**
186
- * Helper function to make a grid entity invisible. This is accomplished by setting its sprite to an
187
- * empty/missing PNG file.
186
+ * Helper function to make a grid entity invisible. This is accomplished by resetting the sprite.
188
187
  *
189
- * For more information, see the documentation for the `clearSprite` helper function.
188
+ * Note that this function is destructive such that once you make a grid entity invisible, it can no
189
+ * longer become visible. (This is because the information about the sprite is lost when it is
190
+ * reset.)
190
191
  */
191
192
  export declare function setGridEntityInvisible(gridEntity: GridEntity): void;
192
193
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"gridEntities.d.ts","sourceRoot":"","sources":["../../../src/functions/gridEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EACd,iBAAiB,EAIlB,MAAM,8BAA8B,CAAC;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,CAkBtE"}
@@ -33,8 +33,6 @@ local ____math = require("src.functions.math")
33
33
  local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
34
34
  local ____rooms = require("src.functions.rooms")
35
35
  local roomUpdateSafe = ____rooms.roomUpdateSafe
36
- local ____sprites = require("src.functions.sprites")
37
- local clearSprite = ____sprites.clearSprite
38
36
  local ____types = require("src.functions.types")
39
37
  local asNumber = ____types.asNumber
40
38
  local isNumber = ____types.isNumber
@@ -502,13 +500,14 @@ function ____exports.removeGridEntities(self, gridEntities, updateRoom, cap)
502
500
  end
503
501
  return gridEntitiesRemoved
504
502
  end
505
- --- Helper function to make a grid entity invisible. This is accomplished by setting its sprite to an
506
- -- empty/missing PNG file.
503
+ --- Helper function to make a grid entity invisible. This is accomplished by resetting the sprite.
507
504
  --
508
- -- For more information, see the documentation for the `clearSprite` helper function.
505
+ -- Note that this function is destructive such that once you make a grid entity invisible, it can no
506
+ -- longer become visible. (This is because the information about the sprite is lost when it is
507
+ -- reset.)
509
508
  function ____exports.setGridEntityInvisible(self, gridEntity)
510
509
  local sprite = gridEntity:GetSprite()
511
- clearSprite(nil, sprite)
510
+ sprite:Reset()
512
511
  end
513
512
  --- Helper function to spawn a giant poop. This is performed by spawning each of the four quadrant
514
513
  -- grid entities in the appropriate positions.
@@ -2,16 +2,22 @@
2
2
  /// <reference types="isaac-typescript-definitions" />
3
3
  /// <reference types="isaac-typescript-definitions" />
4
4
  /**
5
- * Helper function to clear all layers or specific layers from a sprite.
5
+ * Helper function to clear all layers or specific layers from a sprite without unloading the
6
+ * attached anm2 file.
6
7
  *
7
- * This function is variadic, so pass as many layer IDs as you want to clear. If no specific layers
8
- * are passed, it will clear every layer.
8
+ * This function is variadic, which means you can pass as many layer IDs as you want to clear. If no
9
+ * specific layers are passed, the function will clear every layer.
9
10
  *
10
- * Since there is no official API method to "clear" a sprite, we can work around it by setting the
11
- * spritesheet to a non-existent or completely transparent file. If the path to the spritesheet does
12
- * not exist, then this function might cause spurious errors to appear in the "log.txt file". To
13
- * silence these errors, create a transparent 1 pixel PNG file in your mod's resources folder at the
14
- * path corresponding to the "EMPTY_PNG_PATH" constant.
11
+ * If you want to clear all of the layers of a sprite and don't care about unloading the attached
12
+ * anm2 file, then use the `Sprite.Reset` method instead.
13
+ *
14
+ * Since there is no official API method to clear specific layers from a sprite, we work around it
15
+ * by setting the spritesheet to a transparent PNG file corresponding to the `EMPTY_PNG_PATH`
16
+ * constant.
17
+ *
18
+ * This function will still work identically if PNG file does not exist, but it will cause a
19
+ * spurious error to appear in the "log.txt" file. If silencing these errors is desired, you can
20
+ * create a transparent 1 pixel PNG file in your mod's resources folder at `EMPTY_PNG_PATH`.
15
21
  */
16
22
  export declare function clearSprite(sprite: Sprite, ...layerIDs: int[]): void;
17
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../../src/functions/sprites.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,CAWpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,GAAG,CAmBL;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,EACf,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GACd,OAAO,CAaT;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,GAAG,GACX,OAAO,CAIT"}
1
+ {"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../../src/functions/sprites.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,CAWpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,GAAG,CAmBL;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,EACf,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GACd,OAAO,CAaT;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,GAAG,GACX,OAAO,CAIT"}
@@ -12,16 +12,22 @@ function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
12
12
  local kColor2 = sprite2:GetTexel(position, VectorZero, 1, layerID)
13
13
  return kColorEquals(nil, kColor1, kColor2)
14
14
  end
15
- --- Helper function to clear all layers or specific layers from a sprite.
15
+ --- Helper function to clear all layers or specific layers from a sprite without unloading the
16
+ -- attached anm2 file.
16
17
  --
17
- -- This function is variadic, so pass as many layer IDs as you want to clear. If no specific layers
18
- -- are passed, it will clear every layer.
18
+ -- This function is variadic, which means you can pass as many layer IDs as you want to clear. If no
19
+ -- specific layers are passed, the function will clear every layer.
19
20
  --
20
- -- Since there is no official API method to "clear" a sprite, we can work around it by setting the
21
- -- spritesheet to a non-existent or completely transparent file. If the path to the spritesheet does
22
- -- not exist, then this function might cause spurious errors to appear in the "log.txt file". To
23
- -- silence these errors, create a transparent 1 pixel PNG file in your mod's resources folder at the
24
- -- path corresponding to the "EMPTY_PNG_PATH" constant.
21
+ -- If you want to clear all of the layers of a sprite and don't care about unloading the attached
22
+ -- anm2 file, then use the `Sprite.Reset` method instead.
23
+ --
24
+ -- Since there is no official API method to clear specific layers from a sprite, we work around it
25
+ -- by setting the spritesheet to a transparent PNG file corresponding to the `EMPTY_PNG_PATH`
26
+ -- constant.
27
+ --
28
+ -- This function will still work identically if PNG file does not exist, but it will cause a
29
+ -- spurious error to appear in the "log.txt" file. If silencing these errors is desired, you can
30
+ -- create a transparent 1 pixel PNG file in your mod's resources folder at `EMPTY_PNG_PATH`.
25
31
  function ____exports.clearSprite(self, sprite, ...)
26
32
  local layerIDs = {...}
27
33
  if #layerIDs == 0 then
@@ -80,8 +80,8 @@ export declare function newTrinketSprite(trinketType: TrinketType): Sprite;
80
80
  * @param trinket The trinket whose sprite you want to modify.
81
81
  * @param pngPath Equal to either the spritesheet path to load (e.g.
82
82
  * "gfx/items/trinkets/trinket_001_swallowedpenny.png") or undefined. If undefined,
83
- * the sprite will be removed, making it appear like the collectible has already been
84
- * taken by the player.
83
+ * the sprite will be removed, making the trinket effectively invisible (except for
84
+ * the shadow underneath it).
85
85
  */
86
86
  export declare function setTrinketSprite(trinket: EntityPickup, pngPath: string | undefined): void;
87
87
  /** Helper function to check in the item config if a given trinket has a given cache flag. */
@@ -1 +1 @@
1
- {"version":3,"file":"trinkets.d.ts","sourceRoot":"","sources":["../../../src/functions/trinkets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAGT,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAmCtC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAE1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,GAAG,GAAG,SAAS,CAkBxE;AAED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H,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CActE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAOtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAc/D;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,IAAI,WAAW,EAAE,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAOhE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAYjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAiBN;AAED,6FAA6F;AAC7F,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,OAAO,CAOT"}
@@ -167,8 +167,8 @@ end
167
167
  -- @param trinket The trinket whose sprite you want to modify.
168
168
  -- @param pngPath Equal to either the spritesheet path to load (e.g.
169
169
  -- "gfx/items/trinkets/trinket_001_swallowedpenny.png") or undefined. If undefined,
170
- -- the sprite will be removed, making it appear like the collectible has already been
171
- -- taken by the player.
170
+ -- the sprite will be removed, making the trinket effectively invisible (except for
171
+ -- the shadow underneath it).
172
172
  function ____exports.setTrinketSprite(self, trinket, pngPath)
173
173
  if not isTrinket(nil, trinket) then
174
174
  local entityID = getEntityID(nil, trinket)
@@ -176,7 +176,7 @@ function ____exports.setTrinketSprite(self, trinket, pngPath)
176
176
  end
177
177
  local sprite = trinket:GetSprite()
178
178
  if pngPath == nil then
179
- clearSprite(nil, sprite, TRINKET_SPRITE_LAYER)
179
+ clearSprite(nil, sprite)
180
180
  else
181
181
  sprite:ReplaceSpritesheet(TRINKET_SPRITE_LAYER, pngPath)
182
182
  sprite:LoadGraphics()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "20.1.0",
3
+ "version": "20.1.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/src/index",
23
23
  "types": "dist/src/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^10.1.3"
25
+ "isaac-typescript-definitions": "^10.1.4"
26
26
  }
27
27
  }
@@ -526,7 +526,8 @@ export function newCollectibleSprite(collectibleType: CollectibleType): Sprite {
526
526
  sprite.Load(COLLECTIBLE_ANM2_PATH, false);
527
527
 
528
528
  // We want to clear the pedestal layers so that the returned sprite only has the collectible
529
- // image.
529
+ // image. We can't use the `Sprite.Reset` method for this purpose because that would unload the
530
+ // anm2 file.
530
531
  clearSprite(sprite);
531
532
 
532
533
  const gfxFileName = getCollectibleGfxFilename(collectibleType);
@@ -21,7 +21,6 @@ import { removeEntities } from "./entities";
21
21
  import { getEffects } from "./entitiesSpecific";
22
22
  import { isCircleIntersectingRectangle } from "./math";
23
23
  import { roomUpdateSafe } from "./rooms";
24
- import { clearSprite } from "./sprites";
25
24
  import { asNumber, isNumber } from "./types";
26
25
  import { eRange, iRange } from "./utils";
27
26
  import { isVector, vectorEquals } from "./vector";
@@ -630,14 +629,15 @@ export function removeGridEntity(
630
629
  }
631
630
 
632
631
  /**
633
- * Helper function to make a grid entity invisible. This is accomplished by setting its sprite to an
634
- * empty/missing PNG file.
632
+ * Helper function to make a grid entity invisible. This is accomplished by resetting the sprite.
635
633
  *
636
- * For more information, see the documentation for the `clearSprite` helper function.
634
+ * Note that this function is destructive such that once you make a grid entity invisible, it can no
635
+ * longer become visible. (This is because the information about the sprite is lost when it is
636
+ * reset.)
637
637
  */
638
638
  export function setGridEntityInvisible(gridEntity: GridEntity): void {
639
639
  const sprite = gridEntity.GetSprite();
640
- clearSprite(sprite);
640
+ sprite.Reset();
641
641
  }
642
642
 
643
643
  /**
@@ -3,16 +3,22 @@ import { kColorEquals } from "./kColor";
3
3
  import { eRange } from "./utils";
4
4
 
5
5
  /**
6
- * Helper function to clear all layers or specific layers from a sprite.
6
+ * Helper function to clear all layers or specific layers from a sprite without unloading the
7
+ * attached anm2 file.
7
8
  *
8
- * This function is variadic, so pass as many layer IDs as you want to clear. If no specific layers
9
- * are passed, it will clear every layer.
9
+ * This function is variadic, which means you can pass as many layer IDs as you want to clear. If no
10
+ * specific layers are passed, the function will clear every layer.
10
11
  *
11
- * Since there is no official API method to "clear" a sprite, we can work around it by setting the
12
- * spritesheet to a non-existent or completely transparent file. If the path to the spritesheet does
13
- * not exist, then this function might cause spurious errors to appear in the "log.txt file". To
14
- * silence these errors, create a transparent 1 pixel PNG file in your mod's resources folder at the
15
- * path corresponding to the "EMPTY_PNG_PATH" constant.
12
+ * If you want to clear all of the layers of a sprite and don't care about unloading the attached
13
+ * anm2 file, then use the `Sprite.Reset` method instead.
14
+ *
15
+ * Since there is no official API method to clear specific layers from a sprite, we work around it
16
+ * by setting the spritesheet to a transparent PNG file corresponding to the `EMPTY_PNG_PATH`
17
+ * constant.
18
+ *
19
+ * This function will still work identically if PNG file does not exist, but it will cause a
20
+ * spurious error to appear in the "log.txt" file. If silencing these errors is desired, you can
21
+ * create a transparent 1 pixel PNG file in your mod's resources folder at `EMPTY_PNG_PATH`.
16
22
  */
17
23
  export function clearSprite(sprite: Sprite, ...layerIDs: int[]): void {
18
24
  if (layerIDs.length === 0) {
@@ -212,8 +212,8 @@ export function newTrinketSprite(trinketType: TrinketType): Sprite {
212
212
  * @param trinket The trinket whose sprite you want to modify.
213
213
  * @param pngPath Equal to either the spritesheet path to load (e.g.
214
214
  * "gfx/items/trinkets/trinket_001_swallowedpenny.png") or undefined. If undefined,
215
- * the sprite will be removed, making it appear like the collectible has already been
216
- * taken by the player.
215
+ * the sprite will be removed, making the trinket effectively invisible (except for
216
+ * the shadow underneath it).
217
217
  */
218
218
  export function setTrinketSprite(
219
219
  trinket: EntityPickup,
@@ -228,7 +228,9 @@ export function setTrinketSprite(
228
228
 
229
229
  const sprite = trinket.GetSprite();
230
230
  if (pngPath === undefined) {
231
- clearSprite(sprite, TRINKET_SPRITE_LAYER);
231
+ // We use `clearSpriteLayer` instead of `Sprite.Reset` to maintain parity with the
232
+ // `setCollectibleSprite` function.
233
+ clearSprite(sprite);
232
234
  } else {
233
235
  sprite.ReplaceSpritesheet(TRINKET_SPRITE_LAYER, pngPath);
234
236
  sprite.LoadGraphics();