isaacscript-common 1.2.107 → 1.2.108

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.
@@ -64,7 +64,14 @@ function storePickupsInMap(self, pickups)
64
64
  function(____, pickup) return pickup.Price ~= 0 end
65
65
  )
66
66
  for ____, pickup in ipairs(pickupsWithPrice) do
67
- v.room.pickupMap:set(pickup.Index, {variant = pickup.Variant, subType = pickup.SubType, price = pickup.Price, initSeed = pickup.InitSeed})
67
+ v.room.pickupMap:set(pickup.Index, {
68
+ variant = pickup.Variant,
69
+ subType = pickup.SubType,
70
+ position = pickup.Position,
71
+ velocity = pickup.Velocity,
72
+ price = pickup.Price,
73
+ initSeed = pickup.InitSeed
74
+ })
68
75
  end
69
76
  end
70
77
  function storePlayersInMap(self, players)
@@ -1,5 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  export declare function collectibleHasTag(collectibleType: CollectibleType | int, tag: ItemConfigTag): boolean;
3
+ export declare function clearCollectibleSprite(collectible: EntityPickup): void;
3
4
  export declare function collectibleHasCacheFlag(collectibleType: CollectibleType | int, cacheFlag: CacheFlag): boolean;
4
5
  /**
5
6
  * Helper function to get the in-game description for a collectible. Returns "Unknown" if the
@@ -98,24 +99,24 @@ export declare function setCollectiblesRerolledForItemTracker(): void;
98
99
  export declare function setCollectibleBlind(collectible: EntityPickup): void;
99
100
  /**
100
101
  * Helper function to remove the collectible from a collectible pedestal and make it appear as if a
101
- * player has already taken the item. This is accomplished by setting its sprite to an empty/missing
102
- * PNG file.
102
+ * player has already taken the item. This is accomplished by changing the sub-type to
103
+ * `CollectibleType.COLLECTIBLE_NULL` and then setting the sprite to an empty/missing PNG file.
103
104
  *
104
- * For more information, see the documentation for the "emptySprite" helper function.
105
+ * For more information, see the documentation for the "clearSprite" helper function.
105
106
  */
106
107
  export declare function setCollectibleEmpty(collectible: EntityPickup): void;
107
108
  /**
108
109
  * Helper function to change the sprite of a collectible pedestal entity.
109
110
  *
110
111
  * For more information about removing the collectible sprite, see the documentation for the
111
- * "emptySprite" helper function.
112
+ * "clearSprite" helper function.
112
113
  *
113
114
  * @param collectible The collectible whose sprite you want to modify.
114
- * @param pngPath Optional. Equal to the spritesheet path to load (e.g.
115
- * "gfx/items/collectibles/collectibles_001_thesadonion.png"). If not specified, will remove the
116
- * sprite, making it appear like the collectible has already been taken by the player.
115
+ * @param pngPath Equal to either the spritesheet path to load (e.g.
116
+ * "gfx/items/collectibles/collectibles_001_thesadonion.png") or undefined. If undefined, the sprite
117
+ * will be removed, making it appear like the collectible has already been taken by the player.
117
118
  */
118
- export declare function setCollectibleSprite(collectible: EntityPickup, pngPath?: string): void;
119
+ export declare function setCollectibleSprite(collectible: EntityPickup, pngPath: string | undefined): void;
119
120
  /**
120
121
  * Helper function to change the collectible on a pedestal. Simply updating the SubType property is
121
122
  * not sufficient because the sprite will not change.
@@ -38,6 +38,9 @@ function ____exports.collectibleHasTag(self, collectibleType, tag)
38
38
  end
39
39
  return itemConfigItem:HasTags(tag)
40
40
  end
41
+ function ____exports.clearCollectibleSprite(self, collectible)
42
+ ____exports.setCollectibleSprite(nil, collectible, nil)
43
+ end
41
44
  function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
42
45
  local itemConfig = Isaac.GetItemConfig()
43
46
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
@@ -185,7 +188,7 @@ function ____exports.setCollectibleEmpty(self, collectible)
185
188
  error("You cannot set a collectible to be empty for pickups of variant: " .. tostring(collectible.Variant))
186
189
  end
187
190
  collectible.SubType = CollectibleType.COLLECTIBLE_NULL
188
- ____exports.setCollectibleSprite(nil, collectible)
191
+ ____exports.clearCollectibleSprite(nil, collectible)
189
192
  end
190
193
  function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
191
194
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
@@ -13,3 +13,12 @@
13
13
  * Tainted Keeper. False by default.
14
14
  */
15
15
  export declare function spawnCollectible(collectibleType: CollectibleType | int, position: Vector, seed?: number, options?: boolean, forceFreeItem?: boolean): EntityPickup;
16
+ /**
17
+ * Helper function to spawn an empty collectible. Doing this is tricky since spawning a collectible
18
+ * with `CollectibleType.COLLECTIBLE_NULL` will result in spawning a collectible with a random type
19
+ * from the current room's item pool.
20
+ *
21
+ * Instead, this function arbitrarily spawns a collectible with
22
+ * `CollectibleType.COLLECTIBLE_SAD_ONION`, and then converts it to an empty pedestal afterward.
23
+ */
24
+ export declare function spawnEmptyCollectible(position: Vector, seed?: number): void;
@@ -6,6 +6,7 @@ local ____featuresInitialized = require("featuresInitialized")
6
6
  local areFeaturesInitialized = ____featuresInitialized.areFeaturesInitialized
7
7
  local ____collectibles = require("functions.collectibles")
8
8
  local isQuestCollectible = ____collectibles.isQuestCollectible
9
+ local setCollectibleEmpty = ____collectibles.setCollectibleEmpty
9
10
  local ____player = require("functions.player")
10
11
  local anyPlayerIs = ____player.anyPlayerIs
11
12
  function ____exports.spawnCollectible(self, collectibleType, position, seed, options, forceFreeItem)
@@ -46,4 +47,18 @@ function ____exports.spawnCollectible(self, collectibleType, position, seed, opt
46
47
  end
47
48
  return collectible
48
49
  end
50
+ function ____exports.spawnEmptyCollectible(self, position, seed)
51
+ if seed == nil then
52
+ seed = Random()
53
+ end
54
+ local collectible = ____exports.spawnCollectible(
55
+ nil,
56
+ CollectibleType.COLLECTIBLE_SAD_ONION,
57
+ position,
58
+ seed,
59
+ false,
60
+ true
61
+ )
62
+ setCollectibleEmpty(nil, collectible)
63
+ end
49
64
  return ____exports
@@ -2,6 +2,8 @@
2
2
  export interface PickupDescription {
3
3
  variant: PickupVariant | int;
4
4
  subType: int;
5
+ position: Vector;
6
+ velocity: Vector;
5
7
  price: int;
6
8
  initSeed: int;
7
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.107",
3
+ "version": "1.2.108",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",