isaacscript-common 1.2.236 → 1.2.237

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,28 +1,113 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /** Helper function to get all of the card entities in the room. */
3
+ export declare function getCards(matchingSubType?: number): EntityPickup[];
4
+ /** Helper function to get all of the coin pickup entities in the room. */
2
5
  export declare function getCoins(matchingSubType?: number): EntityPickup[];
6
+ /** Helper function to get all of the collectible entities in the room. */
7
+ export declare function getCollectibles(matchingSubType?: number): EntityPickup[];
8
+ /** Helper function to get all of the heart pickup entities in the room. */
3
9
  export declare function getHearts(matchingSubType?: number): EntityPickup[];
10
+ /** Helper function to get all of the key pickup entities in the room. */
4
11
  export declare function getKeys(matchingSubType?: number): EntityPickup[];
5
- /**
6
- * Helper function to get all of the pickups in the room.
7
- *
8
- * Example:
9
- * ```ts
10
- * // Make all of the pickups in the room invisible
11
- * for (const pickup of getPickups()) {
12
- * pickup.Visible = false;
13
- * }
14
- * ```
15
- */
16
- export declare function getPickups(matchingVariant?: PickupVariant | int, matchingSubType?: number): EntityPickup[];
12
+ /** Helper function to get all of the pill entities in the room. */
13
+ export declare function getPills(matchingSubType?: number): EntityPickup[];
14
+ /** Helper function to get all of the red heart pickup entities in the room. */
17
15
  export declare function getRedHearts(): EntityPickup[];
16
+ /** Helper function to get all of the trinket entities in the room. */
17
+ export declare function getTrinkets(matchingSubType?: number): EntityPickup[];
18
18
  export declare function isChest(pickup: EntityPickup): boolean;
19
19
  export declare function isRedHeart(pickup: EntityPickup): boolean;
20
20
  /**
21
- * Helper function to remove all of the pickups in the room.
21
+ * Helper function to remove all of the cards in the room.
22
+ *
23
+ * @param card Optional. If specified, will only remove cards that match this sub-type.
24
+ * @param cap Optional. If specified, will only remove the given amount of cards.
25
+ * @returns True if one or more cards were removed, false otherwise.
26
+ */
27
+ export declare function removeAllCards(card?: Card | int, cap?: int): boolean;
28
+ /**
29
+ * Helper function to remove all of the coins in the room.
30
+ *
31
+ * @param coinSubType Optional. If specified, will only remove coins that match this sub-type.
32
+ * @param cap Optional. If specified, will only remove the given amount of coins.
33
+ * @returns True if one or more coins were removed, false otherwise.
34
+ */
35
+ export declare function removeAllCoins(coinSubType?: CoinSubType | int, cap?: int): boolean;
36
+ /**
37
+ * Helper function to remove all of the collectibles in the room.
38
+ *
39
+ * @param collectibleType Optional. If specified, will only remove collectibles that match this
40
+ * collectible type.
41
+ * @param cap Optional. If specified, will only remove the given amount of collectibles.
42
+ * @returns True if one or more collectibles were removed, false otherwise.
43
+ */
44
+ export declare function removeAllCollectibles(collectibleType?: CollectibleType | int, cap?: int): boolean;
45
+ /**
46
+ * Helper function to remove all of the hearts in the room.
47
+ *
48
+ * @param heartSubType Optional. If specified, will only remove hearts that match this sub-type.
49
+ * @param cap Optional. If specified, will only remove the given amount of hearts.
50
+ * @returns True if one or more hearts were removed, false otherwise.
51
+ */
52
+ export declare function removeAllHearts(heartSubType?: HeartSubType | int, cap?: int): boolean;
53
+ /**
54
+ * Helper function to remove all of the keys in the room.
55
+ *
56
+ * @param keySubType Optional. If specified, will only remove keys that match this sub-type.
57
+ * @param cap Optional. If specified, will only remove the given amount of keys.
58
+ * @returns True if one or more keys were removed, false otherwise.
59
+ */
60
+ export declare function removeAllKeys(keySubType?: KeySubType | int, cap?: int): boolean;
61
+ /**
62
+ * Helper function to remove all of the pills in the room.
63
+ *
64
+ * @param pillColor Optional. If specified, will only remove pills that match this color.
65
+ * @param cap Optional. If specified, will only remove the given amount of pills.
66
+ * @returns True if one or more pills were removed, false otherwise.
67
+ */
68
+ export declare function removeAllPills(pillColor?: PillColor, cap?: int): boolean;
69
+ /**
70
+ * Helper function to remove all of the trinkets in the room.
22
71
  *
23
- * @param variant Optional. If specified, will only remove pickups that match this variant.
24
- * @param subType Optional. If specified, will only remove pickups that match this sub-type.
25
- * @param cap Optional. If specified, will only remove the given amount of pickups.
26
- * @returns True if one or more pickups was removed, false otherwise.
72
+ * @param trinketType Optional. If specified, will only remove trinkets that match this trinket
73
+ * type.
74
+ * @param cap Optional. If specified, will only remove the given amount of trinkets.
75
+ * @returns True if one or more trinkets were removed, false otherwise.
76
+ */
77
+ export declare function removeAllTrinkets(trinketType?: TrinketType | int, cap?: int): boolean;
78
+ /**
79
+ * Helper function to spawn a `EntityType.ENTITY_PICKUP` (5) with variant
80
+ * `PickupVariant.PICKUP_TAROTCARD` (300).
81
+ */
82
+ export declare function spawnCard(subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
83
+ export declare function spawnCardWithSeed(subType: int, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
84
+ /**
85
+ * Helper function to spawn a `EntityType.ENTITY_PICKUP` (5) with variant
86
+ * `PickupVariant.PICKUP_COIN` (20).
87
+ */
88
+ export declare function spawnCoin(subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
89
+ export declare function spawnCoinWithSeed(subType: int, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
90
+ /**
91
+ * Helper function to spawn a `EntityType.ENTITY_PICKUP` (5) with variant
92
+ * `PickupVariant.PICKUP_HEART` (10).
93
+ */
94
+ export declare function spawnHeart(subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
95
+ export declare function spawnHeartWithSeed(subType: int, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
96
+ /**
97
+ * Helper function to spawn a `EntityType.ENTITY_PICKUP` (5) with variant
98
+ * `PickupVariant.PICKUP_KEY` (30).
99
+ */
100
+ export declare function spawnKey(subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
101
+ export declare function spawnKeyWithSeed(subType: int, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
102
+ /**
103
+ * Helper function to spawn a `EntityType.ENTITY_PICKUP` (5) with variant
104
+ * `PickupVariant.PICKUP_PILL` (70).
105
+ */
106
+ export declare function spawnPill(subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
107
+ export declare function spawnPillWithSeed(subType: int, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
108
+ /**
109
+ * Helper function to spawn a `EntityType.ENTITY_PICKUP` (5) with variant
110
+ * `PickupVariant.PICKUP_TRINKET` (350).
27
111
  */
28
- export declare function removeAllPickups(variant?: PickupVariant | int, subType?: int, cap?: int): boolean;
112
+ export declare function spawnTrinket(subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
113
+ export declare function spawnTrinketWithSeed(subType: int, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
@@ -1,48 +1,51 @@
1
1
  local ____lualib = require("lualib_bundle")
2
- local __TS__ArrayPush = ____lualib.__TS__ArrayPush
3
2
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
4
3
  local ____exports = {}
4
+ local ____constants = require("constants")
5
+ local VectorZero = ____constants.VectorZero
5
6
  local ____chestPickupVariantsSet = require("sets.chestPickupVariantsSet")
6
7
  local CHEST_PICKUP_VARIANTS = ____chestPickupVariantsSet.CHEST_PICKUP_VARIANTS
7
8
  local ____redHeartSubTypesSet = require("sets.redHeartSubTypesSet")
8
9
  local RED_HEART_SUB_TYPES_SET = ____redHeartSubTypesSet.RED_HEART_SUB_TYPES_SET
9
- local ____entity = require("functions.entity")
10
- local getEntities = ____entity.getEntities
11
- local removeEntities = ____entity.removeEntities
12
- function ____exports.getPickups(self, matchingVariant, matchingSubType)
13
- if matchingVariant == nil then
14
- matchingVariant = -1
15
- end
10
+ local ____entitySpecific = require("functions.entitySpecific")
11
+ local getPickups = ____entitySpecific.getPickups
12
+ local removeAllPickups = ____entitySpecific.removeAllPickups
13
+ local spawnPickup = ____entitySpecific.spawnPickup
14
+ function ____exports.getCards(self, matchingSubType)
16
15
  if matchingSubType == nil then
17
16
  matchingSubType = -1
18
17
  end
19
- local entities = getEntities(nil, EntityType.ENTITY_PICKUP, matchingVariant, matchingSubType)
20
- local pickups = {}
21
- for ____, entity in ipairs(entities) do
22
- local pickup = entity:ToPickup()
23
- if pickup ~= nil then
24
- __TS__ArrayPush(pickups, pickup)
25
- end
26
- end
27
- return pickups
18
+ return getPickups(nil, 300, matchingSubType)
28
19
  end
29
20
  function ____exports.getCoins(self, matchingSubType)
30
21
  if matchingSubType == nil then
31
22
  matchingSubType = -1
32
23
  end
33
- return ____exports.getPickups(nil, 20, matchingSubType)
24
+ return getPickups(nil, 20, matchingSubType)
25
+ end
26
+ function ____exports.getCollectibles(self, matchingSubType)
27
+ if matchingSubType == nil then
28
+ matchingSubType = -1
29
+ end
30
+ return getPickups(nil, 100, matchingSubType)
34
31
  end
35
32
  function ____exports.getHearts(self, matchingSubType)
36
33
  if matchingSubType == nil then
37
34
  matchingSubType = -1
38
35
  end
39
- return ____exports.getPickups(nil, 10, matchingSubType)
36
+ return getPickups(nil, 10, matchingSubType)
40
37
  end
41
38
  function ____exports.getKeys(self, matchingSubType)
42
39
  if matchingSubType == nil then
43
40
  matchingSubType = -1
44
41
  end
45
- return ____exports.getPickups(nil, 30, matchingSubType)
42
+ return getPickups(nil, 30, matchingSubType)
43
+ end
44
+ function ____exports.getPills(self, matchingSubType)
45
+ if matchingSubType == nil then
46
+ matchingSubType = -1
47
+ end
48
+ return getPickups(nil, 70, matchingSubType)
46
49
  end
47
50
  function ____exports.getRedHearts(self)
48
51
  local hearts = ____exports.getHearts(nil)
@@ -51,14 +54,253 @@ function ____exports.getRedHearts(self)
51
54
  function(____, heart) return RED_HEART_SUB_TYPES_SET:has(heart.SubType) end
52
55
  )
53
56
  end
57
+ function ____exports.getTrinkets(self, matchingSubType)
58
+ if matchingSubType == nil then
59
+ matchingSubType = -1
60
+ end
61
+ return getPickups(nil, 350, matchingSubType)
62
+ end
54
63
  function ____exports.isChest(self, pickup)
55
64
  return CHEST_PICKUP_VARIANTS:has(pickup.Variant)
56
65
  end
57
66
  function ____exports.isRedHeart(self, pickup)
58
67
  return pickup.Variant == 10 and RED_HEART_SUB_TYPES_SET:has(pickup.SubType)
59
68
  end
60
- function ____exports.removeAllPickups(self, variant, subType, cap)
61
- local pickups = ____exports.getPickups(nil, variant, subType)
62
- return removeEntities(nil, pickups, cap)
69
+ function ____exports.removeAllCards(self, card, cap)
70
+ return removeAllPickups(nil, 300, card, cap)
71
+ end
72
+ function ____exports.removeAllCoins(self, coinSubType, cap)
73
+ return removeAllPickups(nil, 20, coinSubType, cap)
74
+ end
75
+ function ____exports.removeAllCollectibles(self, collectibleType, cap)
76
+ return removeAllPickups(nil, 100, collectibleType, cap)
77
+ end
78
+ function ____exports.removeAllHearts(self, heartSubType, cap)
79
+ return removeAllPickups(nil, 10, heartSubType, cap)
80
+ end
81
+ function ____exports.removeAllKeys(self, keySubType, cap)
82
+ return removeAllPickups(nil, 30, keySubType, cap)
83
+ end
84
+ function ____exports.removeAllPills(self, pillColor, cap)
85
+ return removeAllPickups(nil, 70, pillColor, cap)
86
+ end
87
+ function ____exports.removeAllTrinkets(self, trinketType, cap)
88
+ return removeAllPickups(nil, 350, trinketType, cap)
89
+ end
90
+ function ____exports.spawnCard(self, subType, position, velocity, spawner, seed)
91
+ if velocity == nil then
92
+ velocity = VectorZero
93
+ end
94
+ if spawner == nil then
95
+ spawner = nil
96
+ end
97
+ if seed == nil then
98
+ seed = nil
99
+ end
100
+ return spawnPickup(
101
+ nil,
102
+ 300,
103
+ subType,
104
+ position,
105
+ velocity,
106
+ spawner,
107
+ seed
108
+ )
109
+ end
110
+ function ____exports.spawnCardWithSeed(self, subType, position, seed, velocity, spawner)
111
+ if velocity == nil then
112
+ velocity = VectorZero
113
+ end
114
+ if spawner == nil then
115
+ spawner = nil
116
+ end
117
+ return ____exports.spawnCard(
118
+ nil,
119
+ subType,
120
+ position,
121
+ velocity,
122
+ spawner,
123
+ seed
124
+ )
125
+ end
126
+ function ____exports.spawnCoin(self, subType, position, velocity, spawner, seed)
127
+ if velocity == nil then
128
+ velocity = VectorZero
129
+ end
130
+ if spawner == nil then
131
+ spawner = nil
132
+ end
133
+ if seed == nil then
134
+ seed = nil
135
+ end
136
+ return spawnPickup(
137
+ nil,
138
+ 20,
139
+ subType,
140
+ position,
141
+ velocity,
142
+ spawner,
143
+ seed
144
+ )
145
+ end
146
+ function ____exports.spawnCoinWithSeed(self, subType, position, seed, velocity, spawner)
147
+ if velocity == nil then
148
+ velocity = VectorZero
149
+ end
150
+ if spawner == nil then
151
+ spawner = nil
152
+ end
153
+ return ____exports.spawnCoin(
154
+ nil,
155
+ subType,
156
+ position,
157
+ velocity,
158
+ spawner,
159
+ seed
160
+ )
161
+ end
162
+ function ____exports.spawnHeart(self, subType, position, velocity, spawner, seed)
163
+ if velocity == nil then
164
+ velocity = VectorZero
165
+ end
166
+ if spawner == nil then
167
+ spawner = nil
168
+ end
169
+ if seed == nil then
170
+ seed = nil
171
+ end
172
+ return spawnPickup(
173
+ nil,
174
+ 10,
175
+ subType,
176
+ position,
177
+ velocity,
178
+ spawner,
179
+ seed
180
+ )
181
+ end
182
+ function ____exports.spawnHeartWithSeed(self, subType, position, seed, velocity, spawner)
183
+ if velocity == nil then
184
+ velocity = VectorZero
185
+ end
186
+ if spawner == nil then
187
+ spawner = nil
188
+ end
189
+ return ____exports.spawnHeart(
190
+ nil,
191
+ subType,
192
+ position,
193
+ velocity,
194
+ spawner,
195
+ seed
196
+ )
197
+ end
198
+ function ____exports.spawnKey(self, subType, position, velocity, spawner, seed)
199
+ if velocity == nil then
200
+ velocity = VectorZero
201
+ end
202
+ if spawner == nil then
203
+ spawner = nil
204
+ end
205
+ if seed == nil then
206
+ seed = nil
207
+ end
208
+ return spawnPickup(
209
+ nil,
210
+ 30,
211
+ subType,
212
+ position,
213
+ velocity,
214
+ spawner,
215
+ seed
216
+ )
217
+ end
218
+ function ____exports.spawnKeyWithSeed(self, subType, position, seed, velocity, spawner)
219
+ if velocity == nil then
220
+ velocity = VectorZero
221
+ end
222
+ if spawner == nil then
223
+ spawner = nil
224
+ end
225
+ return ____exports.spawnKey(
226
+ nil,
227
+ subType,
228
+ position,
229
+ velocity,
230
+ spawner,
231
+ seed
232
+ )
233
+ end
234
+ function ____exports.spawnPill(self, subType, position, velocity, spawner, seed)
235
+ if velocity == nil then
236
+ velocity = VectorZero
237
+ end
238
+ if spawner == nil then
239
+ spawner = nil
240
+ end
241
+ if seed == nil then
242
+ seed = nil
243
+ end
244
+ return spawnPickup(
245
+ nil,
246
+ 70,
247
+ subType,
248
+ position,
249
+ velocity,
250
+ spawner,
251
+ seed
252
+ )
253
+ end
254
+ function ____exports.spawnPillWithSeed(self, subType, position, seed, velocity, spawner)
255
+ if velocity == nil then
256
+ velocity = VectorZero
257
+ end
258
+ if spawner == nil then
259
+ spawner = nil
260
+ end
261
+ return ____exports.spawnPill(
262
+ nil,
263
+ subType,
264
+ position,
265
+ velocity,
266
+ spawner,
267
+ seed
268
+ )
269
+ end
270
+ function ____exports.spawnTrinket(self, subType, position, velocity, spawner, seed)
271
+ if velocity == nil then
272
+ velocity = VectorZero
273
+ end
274
+ if spawner == nil then
275
+ spawner = nil
276
+ end
277
+ if seed == nil then
278
+ seed = nil
279
+ end
280
+ return spawnPickup(
281
+ nil,
282
+ 350,
283
+ subType,
284
+ position,
285
+ velocity,
286
+ spawner,
287
+ seed
288
+ )
289
+ end
290
+ function ____exports.spawnTrinketWithSeed(self, subType, position, seed, velocity, spawner)
291
+ if velocity == nil then
292
+ velocity = VectorZero
293
+ end
294
+ if spawner == nil then
295
+ spawner = nil
296
+ end
297
+ return ____exports.spawnTrinket(
298
+ nil,
299
+ subType,
300
+ position,
301
+ velocity,
302
+ spawner,
303
+ seed
304
+ )
63
305
  end
64
306
  return ____exports
@@ -1,9 +1,5 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- local ____cachedClasses = require("cachedClasses")
4
- local game = ____cachedClasses.game
5
- local ____constants = require("constants")
6
- local VectorZero = ____constants.VectorZero
7
3
  local ____preventCollectibleRotate = require("features.preventCollectibleRotate")
8
4
  local preventCollectibleRotate = ____preventCollectibleRotate.preventCollectibleRotate
9
5
  local ____featuresInitialized = require("featuresInitialized")
@@ -11,6 +7,8 @@ local areFeaturesInitialized = ____featuresInitialized.areFeaturesInitialized
11
7
  local ____collectibles = require("functions.collectibles")
12
8
  local isQuestCollectible = ____collectibles.isQuestCollectible
13
9
  local setCollectibleEmpty = ____collectibles.setCollectibleEmpty
10
+ local ____entitySpecific = require("functions.entitySpecific")
11
+ local spawnPickupWithSeed = ____entitySpecific.spawnPickupWithSeed
14
12
  local ____player = require("functions.player")
15
13
  local anyPlayerIs = ____player.anyPlayerIs
16
14
  local ____rng = require("functions.rng")
@@ -27,18 +25,13 @@ function ____exports.spawnCollectible(self, collectibleType, position, seedOrRNG
27
25
  forceFreeItem = false
28
26
  end
29
27
  local seed = isRNG(nil, seedOrRNG) and seedOrRNG:Next() or seedOrRNG
30
- local collectible = game:Spawn(
31
- EntityType.ENTITY_PICKUP,
32
- 100,
33
- position,
34
- VectorZero,
28
+ local collectible = spawnPickupWithSeed(
35
29
  nil,
30
+ 100,
36
31
  collectibleType,
32
+ position,
37
33
  seed
38
- ):ToPickup()
39
- if collectible == nil then
40
- error("Failed to spawn a collectible.")
41
- end
34
+ )
42
35
  if options then
43
36
  collectible.OptionsPickupIndex = 1
44
37
  end
@@ -34,8 +34,6 @@ export declare function getTrinketDescription(trinketType: TrinketType | int): s
34
34
  * ```
35
35
  */
36
36
  export declare function getTrinketName(trinketType: TrinketType | int): string;
37
- /** Helper function to get all of the trinket entities in the room. */
38
- export declare function getTrinkets(matchingSubType?: number): EntityPickup[];
39
37
  /**
40
38
  * Returns whether or not the player can hold an additional trinket, beyond what they are currently
41
39
  * carrying. This takes into account items that modify the max number of trinkets, like Mom's Purse.
@@ -12,8 +12,6 @@ local DEFAULT_TRINKET_NAME = ____trinketNameMap.DEFAULT_TRINKET_NAME
12
12
  local TRINKET_NAME_MAP = ____trinketNameMap.TRINKET_NAME_MAP
13
13
  local ____flag = require("functions.flag")
14
14
  local hasFlag = ____flag.hasFlag
15
- local ____pickups = require("functions.pickups")
16
- local getPickups = ____pickups.getPickups
17
15
  local ____player = require("functions.player")
18
16
  local isCharacter = ____player.isCharacter
19
17
  local useActiveItemTemp = ____player.useActiveItemTemp
@@ -65,12 +63,6 @@ function ____exports.getTrinketName(self, trinketType)
65
63
  end
66
64
  return DEFAULT_TRINKET_NAME
67
65
  end
68
- function ____exports.getTrinkets(self, matchingSubType)
69
- if matchingSubType == nil then
70
- matchingSubType = -1
71
- end
72
- return getPickups(nil, 350, matchingSubType)
73
- end
74
66
  function ____exports.hasOpenTrinketSlot(self, player)
75
67
  if isCharacter(nil, player, PlayerType.PLAYER_THESOUL_B) then
76
68
  return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.236",
3
+ "version": "1.2.237",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",