isaacscript-common 1.0.541 → 1.0.545
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/functions/cards.d.ts +2 -2
- package/dist/functions/collectibles.d.ts +2 -1
- package/dist/functions/collectibles.lua +1 -1
- package/dist/functions/entity.d.ts +27 -10
- package/dist/functions/entity.lua +20 -10
- package/dist/functions/gridEntity.d.ts +6 -2
- package/dist/functions/gridEntity.lua +10 -1
- package/dist/functions/npc.d.ts +2 -1
- package/dist/functions/npc.lua +1 -1
- package/dist/functions/pills.d.ts +1 -1
- package/dist/functions/revive.lua +2 -2
- package/dist/functions/transformations.d.ts +10 -0
- package/dist/functions/transformations.lua +11 -4
- package/dist/functions/trinketGive.d.ts +15 -12
- package/dist/functions/trinketGive.lua +15 -1
- package/dist/functions/trinkets.d.ts +11 -0
- package/dist/functions/trinkets.lua +18 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.lua +9 -1
- package/dist/maps/transformationMaps.d.ts +5 -0
- package/dist/maps/transformationMaps.lua +56 -0
- package/dist/maps/transformationNameMap.d.ts +2 -0
- package/dist/maps/transformationNameMap.lua +5 -0
- package/dist/types/TrinketSituation.d.ts +7 -0
- package/dist/types/TrinketSituation.lua +3 -0
- package/package.json +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
/**
|
|
3
|
-
* Helper function to get a card
|
|
3
|
+
* Helper function to get a card description from a Card enum value.
|
|
4
4
|
*
|
|
5
5
|
* Example:
|
|
6
6
|
* ```
|
|
7
7
|
* const card = Card.CARD_FOOL;
|
|
8
|
-
* const
|
|
8
|
+
* const cardDescription = getCardDescription(card); // cardDescription is "Where journey begins"
|
|
9
9
|
* ```
|
|
10
10
|
*/
|
|
11
11
|
export declare function getCardDescription(card: Card | int): string;
|
|
@@ -68,8 +68,9 @@ export declare function isSingleUseCollectible(collectibleType: CollectibleType
|
|
|
68
68
|
* @param collectibleType Optional. If specified, will only remove collectibles that match this
|
|
69
69
|
* collectible type.
|
|
70
70
|
* @param cap Optional. If specified, will only remove the given amount of collectibles.
|
|
71
|
+
* @returns True if one or more collectibles was removed, false otherwise.
|
|
71
72
|
*/
|
|
72
|
-
export declare function removeAllCollectibles(collectibleType?: CollectibleType | int, cap?: int):
|
|
73
|
+
export declare function removeAllCollectibles(collectibleType?: CollectibleType | int, cap?: int): boolean;
|
|
73
74
|
/**
|
|
74
75
|
* Helper function to remove all pickup delay on a collectible. By default, collectibles have a 20
|
|
75
76
|
* frame delay before they can be picked up by a player.
|
|
@@ -151,7 +151,7 @@ function ____exports.isSingleUseCollectible(self, collectibleType)
|
|
|
151
151
|
return SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES:has(collectibleType)
|
|
152
152
|
end
|
|
153
153
|
function ____exports.removeAllCollectibles(self, collectibleType, cap)
|
|
154
|
-
removeAllPickups(nil, PickupVariant.PICKUP_COLLECTIBLE, collectibleType, cap)
|
|
154
|
+
return removeAllPickups(nil, PickupVariant.PICKUP_COLLECTIBLE, collectibleType, cap)
|
|
155
155
|
end
|
|
156
156
|
function ____exports.removeCollectiblePickupDelay(self, collectible)
|
|
157
157
|
if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
|
|
@@ -152,53 +152,66 @@ export declare function getSlots(matchingVariant?: number, matchingSubType?: num
|
|
|
152
152
|
* ```
|
|
153
153
|
*/
|
|
154
154
|
export declare function getTears(matchingVariant?: number, matchingSubType?: number): EntityTear[];
|
|
155
|
+
/**
|
|
156
|
+
* Helper function to measure an entity's velocity to see if it is moving.
|
|
157
|
+
*
|
|
158
|
+
* @param entity The entity whose velocity to measure.
|
|
159
|
+
* @param threshold Optional. The threshold from 0 to consider to be moving. 0.01 by default.
|
|
160
|
+
*/
|
|
161
|
+
export declare function isEntityMoving(entity: Entity, threshold?: number): boolean;
|
|
155
162
|
/**
|
|
156
163
|
* Helper function to remove all of the entities in the supplied array.
|
|
157
164
|
*
|
|
158
165
|
* @param entities The array of entities to remove.
|
|
159
166
|
* @param cap Optional. If specified, will only remove the given amount of entities.
|
|
167
|
+
* @returns True if one or more entities was removed, false otherwise.
|
|
160
168
|
*/
|
|
161
|
-
export declare function removeEntities(entities: Entity[], cap?: int):
|
|
169
|
+
export declare function removeEntities(entities: Entity[], cap?: int): boolean;
|
|
162
170
|
/**
|
|
163
171
|
* Helper function to remove all of the bombs in the room.
|
|
164
172
|
*
|
|
165
173
|
* @param variant Optional. If specified, will only remove bombs that match this variant.
|
|
166
174
|
* @param subType Optional. If specified, will only remove bombs that match this sub-type.
|
|
167
175
|
* @param cap Optional. If specified, will only remove the given amount of bombs.
|
|
176
|
+
* @returns True if one or more bombs was removed, false otherwise.
|
|
168
177
|
*/
|
|
169
|
-
export declare function removeAllBombs(variant?: BombVariant | int, subType?: int, cap?: int):
|
|
178
|
+
export declare function removeAllBombs(variant?: BombVariant | int, subType?: int, cap?: int): boolean;
|
|
170
179
|
/**
|
|
171
180
|
* Helper function to remove all of the effects in the room.
|
|
172
181
|
*
|
|
173
182
|
* @param variant Optional. If specified, will only remove effects that match this variant.
|
|
174
183
|
* @param subType Optional. If specified, will only remove effects that match this sub-type.
|
|
175
184
|
* @param cap Optional. If specified, will only remove the given amount of effects.
|
|
185
|
+
* @returns True if one or more effects was removed, false otherwise.
|
|
176
186
|
*/
|
|
177
|
-
export declare function removeAllEffects(variant?: EffectVariant, subType?: int, cap?: int):
|
|
187
|
+
export declare function removeAllEffects(variant?: EffectVariant, subType?: int, cap?: int): boolean;
|
|
178
188
|
/**
|
|
179
189
|
* Helper function to remove all of the familiars in the room.
|
|
180
190
|
*
|
|
181
191
|
* @param variant Optional. If specified, will only remove familiars that match this variant.
|
|
182
192
|
* @param subType Optional. If specified, will only remove familiars that match this sub-type.
|
|
183
193
|
* @param cap Optional. If specified, will only remove the given amount of familiars.
|
|
194
|
+
* @returns True if one or more familiars was removed, false otherwise.
|
|
184
195
|
*/
|
|
185
|
-
export declare function removeAllFamiliars(variant?: FamiliarVariant | int, subType?: int, cap?: int):
|
|
196
|
+
export declare function removeAllFamiliars(variant?: FamiliarVariant | int, subType?: int, cap?: int): boolean;
|
|
186
197
|
/**
|
|
187
198
|
* Helper function to remove all of the knives in the room.
|
|
188
199
|
*
|
|
189
200
|
* @param variant Optional. If specified, will only remove knives that match this variant.
|
|
190
201
|
* @param subType Optional. If specified, will only remove knives that match this sub-type.
|
|
191
202
|
* @param cap Optional. If specified, will only remove the given amount of knives.
|
|
203
|
+
* @returns True if one or more knives was removed, false otherwise.
|
|
192
204
|
*/
|
|
193
|
-
export declare function removeAllKnives(variant?: KnifeVariant | int, subType?: int, cap?: int):
|
|
205
|
+
export declare function removeAllKnives(variant?: KnifeVariant | int, subType?: int, cap?: int): boolean;
|
|
194
206
|
/**
|
|
195
207
|
* Helper function to remove all of the lasers in the room.
|
|
196
208
|
*
|
|
197
209
|
* @param variant Optional. If specified, will only remove lasers that match this variant.
|
|
198
210
|
* @param subType Optional. If specified, will only remove lasers that match this sub-type.
|
|
199
211
|
* @param cap Optional. If specified, will only remove the given amount of lasers.
|
|
212
|
+
* @returns True if one or more lasers was removed, false otherwise.
|
|
200
213
|
*/
|
|
201
|
-
export declare function removeAllLasers(variant?: LaserVariant | int, subType?: int, cap?: int):
|
|
214
|
+
export declare function removeAllLasers(variant?: LaserVariant | int, subType?: int, cap?: int): boolean;
|
|
202
215
|
/**
|
|
203
216
|
* Helper function to remove all of the matching entities in the room.
|
|
204
217
|
*
|
|
@@ -208,32 +221,36 @@ export declare function removeAllLasers(variant?: LaserVariant | int, subType?:
|
|
|
208
221
|
* @param entitySubType Optional. The sub-type to match. -1 by default (which will match every
|
|
209
222
|
* sub-type).
|
|
210
223
|
* @param cap Optional. If specified, will only remove the given amount of collectibles.
|
|
224
|
+
* @returns True if one or more entities was removed, false otherwise.
|
|
211
225
|
*/
|
|
212
|
-
export declare function removeAllMatchingEntities(entityType: int, entityVariant?: number, entitySubType?: number, cap?: int | undefined):
|
|
226
|
+
export declare function removeAllMatchingEntities(entityType: int, entityVariant?: number, entitySubType?: number, cap?: int | undefined): boolean;
|
|
213
227
|
/**
|
|
214
228
|
* Helper function to remove all of the pickups in the room.
|
|
215
229
|
*
|
|
216
230
|
* @param variant Optional. If specified, will only remove pickups that match this variant.
|
|
217
231
|
* @param subType Optional. If specified, will only remove pickups that match this sub-type.
|
|
218
232
|
* @param cap Optional. If specified, will only remove the given amount of pickups.
|
|
233
|
+
* @returns True if one or more pickups was removed, false otherwise.
|
|
219
234
|
*/
|
|
220
|
-
export declare function removeAllPickups(variant?: PickupVariant | int, subType?: int, cap?: int):
|
|
235
|
+
export declare function removeAllPickups(variant?: PickupVariant | int, subType?: int, cap?: int): boolean;
|
|
221
236
|
/**
|
|
222
237
|
* Helper function to remove all of the projectiles in the room.
|
|
223
238
|
*
|
|
224
239
|
* @param variant Optional. If specified, will only remove projectiles that match this variant.
|
|
225
240
|
* @param subType Optional. If specified, will only remove projectiles that match this sub-type.
|
|
226
241
|
* @param cap Optional. If specified, will only remove the given amount of projectiles.
|
|
242
|
+
* @returns True if one or more projectiles was removed, false otherwise.
|
|
227
243
|
*/
|
|
228
|
-
export declare function removeAllProjectiles(variant?: ProjectileVariant | int, subType?: int, cap?: int):
|
|
244
|
+
export declare function removeAllProjectiles(variant?: ProjectileVariant | int, subType?: int, cap?: int): boolean;
|
|
229
245
|
/**
|
|
230
246
|
* Helper function to remove all of the tears in the room.
|
|
231
247
|
*
|
|
232
248
|
* @param variant Optional. If specified, will only remove tears that match this variant.
|
|
233
249
|
* @param subType Optional. If specified, will only remove tears that match this sub-type.
|
|
234
250
|
* @param cap Optional. If specified, will only remove the given amount of tears.
|
|
251
|
+
* @returns True if one or more tears was removed, false otherwise.
|
|
235
252
|
*/
|
|
236
|
-
export declare function removeAllTears(variant?: TearVariant | int, subType?: int, cap?: int):
|
|
253
|
+
export declare function removeAllTears(variant?: TearVariant | int, subType?: int, cap?: int): boolean;
|
|
237
254
|
/**
|
|
238
255
|
* Helper function to set the position of every entity in the room based on a map of positions. If
|
|
239
256
|
* an entity is found that does not have matching element in the provided map, then that entity will
|
|
@@ -210,7 +210,16 @@ function ____exports.getTears(self, matchingVariant, matchingSubType)
|
|
|
210
210
|
end
|
|
211
211
|
return tears
|
|
212
212
|
end
|
|
213
|
+
function ____exports.isEntityMoving(self, entity, threshold)
|
|
214
|
+
if threshold == nil then
|
|
215
|
+
threshold = 0.01
|
|
216
|
+
end
|
|
217
|
+
return entity.Velocity:Length() >= threshold
|
|
218
|
+
end
|
|
213
219
|
function ____exports.removeEntities(self, entities, cap)
|
|
220
|
+
if #entities == 0 then
|
|
221
|
+
return false
|
|
222
|
+
end
|
|
214
223
|
local numEntitiesRemoved = 0
|
|
215
224
|
do
|
|
216
225
|
local i = 0
|
|
@@ -219,31 +228,32 @@ function ____exports.removeEntities(self, entities, cap)
|
|
|
219
228
|
entity:Remove()
|
|
220
229
|
numEntitiesRemoved = numEntitiesRemoved + 1
|
|
221
230
|
if (cap ~= nil) and (numEntitiesRemoved >= cap) then
|
|
222
|
-
return
|
|
231
|
+
return true
|
|
223
232
|
end
|
|
224
233
|
i = i + 1
|
|
225
234
|
end
|
|
226
235
|
end
|
|
236
|
+
return true
|
|
227
237
|
end
|
|
228
238
|
function ____exports.removeAllBombs(self, variant, subType, cap)
|
|
229
239
|
local bombs = ____exports.getBombs(nil, variant, subType)
|
|
230
|
-
____exports.removeEntities(nil, bombs, cap)
|
|
240
|
+
return ____exports.removeEntities(nil, bombs, cap)
|
|
231
241
|
end
|
|
232
242
|
function ____exports.removeAllEffects(self, variant, subType, cap)
|
|
233
243
|
local effects = ____exports.getEffects(nil, variant, subType)
|
|
234
|
-
____exports.removeEntities(nil, effects, cap)
|
|
244
|
+
return ____exports.removeEntities(nil, effects, cap)
|
|
235
245
|
end
|
|
236
246
|
function ____exports.removeAllFamiliars(self, variant, subType, cap)
|
|
237
247
|
local familiars = ____exports.getFamiliars(nil, variant, subType)
|
|
238
|
-
____exports.removeEntities(nil, familiars, cap)
|
|
248
|
+
return ____exports.removeEntities(nil, familiars, cap)
|
|
239
249
|
end
|
|
240
250
|
function ____exports.removeAllKnives(self, variant, subType, cap)
|
|
241
251
|
local knives = ____exports.getKnives(nil, variant, subType)
|
|
242
|
-
____exports.removeEntities(nil, knives, cap)
|
|
252
|
+
return ____exports.removeEntities(nil, knives, cap)
|
|
243
253
|
end
|
|
244
254
|
function ____exports.removeAllLasers(self, variant, subType, cap)
|
|
245
255
|
local lasers = ____exports.getLasers(nil, variant, subType)
|
|
246
|
-
____exports.removeEntities(nil, lasers, cap)
|
|
256
|
+
return ____exports.removeEntities(nil, lasers, cap)
|
|
247
257
|
end
|
|
248
258
|
function ____exports.removeAllMatchingEntities(self, entityType, entityVariant, entitySubType, cap)
|
|
249
259
|
if entityVariant == nil then
|
|
@@ -256,19 +266,19 @@ function ____exports.removeAllMatchingEntities(self, entityType, entityVariant,
|
|
|
256
266
|
cap = nil
|
|
257
267
|
end
|
|
258
268
|
local entities = Isaac.FindByType(entityType, entityVariant, entitySubType)
|
|
259
|
-
____exports.removeEntities(nil, entities, cap)
|
|
269
|
+
return ____exports.removeEntities(nil, entities, cap)
|
|
260
270
|
end
|
|
261
271
|
function ____exports.removeAllPickups(self, variant, subType, cap)
|
|
262
272
|
local pickups = ____exports.getPickups(nil, variant, subType)
|
|
263
|
-
____exports.removeEntities(nil, pickups, cap)
|
|
273
|
+
return ____exports.removeEntities(nil, pickups, cap)
|
|
264
274
|
end
|
|
265
275
|
function ____exports.removeAllProjectiles(self, variant, subType, cap)
|
|
266
276
|
local projectiles = ____exports.getProjectiles(nil, variant, subType)
|
|
267
|
-
____exports.removeEntities(nil, projectiles, cap)
|
|
277
|
+
return ____exports.removeEntities(nil, projectiles, cap)
|
|
268
278
|
end
|
|
269
279
|
function ____exports.removeAllTears(self, variant, subType, cap)
|
|
270
280
|
local tears = ____exports.getTears(nil, variant, subType)
|
|
271
|
-
____exports.removeEntities(nil, tears, cap)
|
|
281
|
+
return ____exports.removeEntities(nil, tears, cap)
|
|
272
282
|
end
|
|
273
283
|
function ____exports.setEntityPositions(self, entityPositions, entities)
|
|
274
284
|
if entities == nil then
|
|
@@ -55,8 +55,10 @@ export declare function isPostBossVoidPortal(gridEntity: GridEntity): boolean;
|
|
|
55
55
|
* GridEntityType.GRID_DOOR,
|
|
56
56
|
* );
|
|
57
57
|
* ```
|
|
58
|
+
*
|
|
59
|
+
* @returns True if one or more grid entities was removed, false otherwise.
|
|
58
60
|
*/
|
|
59
|
-
export declare function removeAllGridEntitiesExceptFor(...gridEntityTypes: GridEntityType[]):
|
|
61
|
+
export declare function removeAllGridEntitiesExceptFor(...gridEntityTypes: GridEntityType[]): boolean;
|
|
60
62
|
/**
|
|
61
63
|
* Helper function to remove all of the grid entities in the room that match the grid entity types
|
|
62
64
|
* provided.
|
|
@@ -69,8 +71,10 @@ export declare function removeAllGridEntitiesExceptFor(...gridEntityTypes: GridE
|
|
|
69
71
|
* GridEntityType.GRID_ROCKT,
|
|
70
72
|
* );
|
|
71
73
|
* ```
|
|
74
|
+
*
|
|
75
|
+
* @returns True if one or more grid entities was removed, false otherwise.
|
|
72
76
|
*/
|
|
73
|
-
export declare function removeAllMatchingGridEntities(...gridEntityType: GridEntityType[]):
|
|
77
|
+
export declare function removeAllMatchingGridEntities(...gridEntityType: GridEntityType[]): boolean;
|
|
74
78
|
/**
|
|
75
79
|
* Helper function to remove a grid entity simply by providing the grid entity object.
|
|
76
80
|
*
|
|
@@ -135,20 +135,29 @@ function ____exports.removeAllGridEntitiesExceptFor(self, ...)
|
|
|
135
135
|
local gridEntityTypes = {...}
|
|
136
136
|
local gridEntityTypeExceptions = __TS__New(Set, gridEntityTypes)
|
|
137
137
|
local gridEntities = ____exports.getGridEntities(nil)
|
|
138
|
+
local removedOneOrMoreGridEntities = false
|
|
138
139
|
for ____, gridEntity in ipairs(gridEntities) do
|
|
139
140
|
local gridEntityType = gridEntity:GetType()
|
|
140
141
|
if not gridEntityTypeExceptions:has(gridEntityType) then
|
|
141
142
|
____exports.removeGridEntity(nil, gridEntity, false)
|
|
143
|
+
removedOneOrMoreGridEntities = true
|
|
142
144
|
end
|
|
143
145
|
end
|
|
144
|
-
|
|
146
|
+
if removedOneOrMoreGridEntities then
|
|
147
|
+
roomUpdateSafe(nil)
|
|
148
|
+
end
|
|
149
|
+
return removedOneOrMoreGridEntities
|
|
145
150
|
end
|
|
146
151
|
function ____exports.removeAllMatchingGridEntities(self, ...)
|
|
147
152
|
local gridEntities = ____exports.getGridEntities(nil, ...)
|
|
153
|
+
if #gridEntities == 0 then
|
|
154
|
+
return false
|
|
155
|
+
end
|
|
148
156
|
for ____, gridEntity in ipairs(gridEntities) do
|
|
149
157
|
____exports.removeGridEntity(nil, gridEntity, false)
|
|
150
158
|
end
|
|
151
159
|
roomUpdateSafe(nil)
|
|
160
|
+
return true
|
|
152
161
|
end
|
|
153
162
|
function ____exports.setGridEntityInvisible(self, gridEntity)
|
|
154
163
|
local sprite = gridEntity:GetSprite()
|
package/dist/functions/npc.d.ts
CHANGED
|
@@ -39,5 +39,6 @@ export declare function isRaglingDeathPatch(npc: EntityNPC): boolean;
|
|
|
39
39
|
* Helper function to remove all NPCs in the room.
|
|
40
40
|
*
|
|
41
41
|
* @param cap Optional. If specified, will only remove the given amount of NPCs.
|
|
42
|
+
* @returns True if one or more NPCs was removed, false otherwise.
|
|
42
43
|
*/
|
|
43
|
-
export declare function removeAllNPCs(cap?: int):
|
|
44
|
+
export declare function removeAllNPCs(cap?: int): boolean;
|
package/dist/functions/npc.lua
CHANGED
|
@@ -6,7 +6,7 @@ local ____sprite = require("functions.sprite")
|
|
|
6
6
|
local getFinalFrameOfAnimation = ____sprite.getFinalFrameOfAnimation
|
|
7
7
|
local ____trinketGive = require("functions.trinketGive")
|
|
8
8
|
local giveTrinketsBack = ____trinketGive.giveTrinketsBack
|
|
9
|
-
local
|
|
9
|
+
local temporarilyRemoveTrinket = ____trinketGive.temporarilyRemoveTrinket
|
|
10
10
|
function ____exports.willMysteriousPaperRevive(self, player)
|
|
11
11
|
local game = Game()
|
|
12
12
|
local gameFrameCount = game:GetFrameCount()
|
|
@@ -17,7 +17,7 @@ function ____exports.willMysteriousPaperRevive(self, player)
|
|
|
17
17
|
return (frameOfDeath % 4) == 3
|
|
18
18
|
end
|
|
19
19
|
function ____exports.willPlayerRevive(self, player)
|
|
20
|
-
local trinketSituation =
|
|
20
|
+
local trinketSituation = temporarilyRemoveTrinket(nil, player, TrinketType.TRINKET_MYSTERIOUS_PAPER)
|
|
21
21
|
local willRevive = player:WillPlayerRevive() or ((trinketSituation ~= nil) and ____exports.willMysteriousPaperRevive(nil, player))
|
|
22
22
|
giveTrinketsBack(nil, player, trinketSituation)
|
|
23
23
|
return willRevive
|
|
@@ -2,3 +2,13 @@
|
|
|
2
2
|
/** Returns the number of items that a player has towards a particular transformation. */
|
|
3
3
|
export declare function getPlayerNumTransformationCollectibles(player: EntityPlayer, playerForm: PlayerForm): int;
|
|
4
4
|
export declare function getTransformationsForItem(collectibleType: CollectibleType | int): Set<PlayerForm>;
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to get a transformation name from a PlayerForm enum.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* ```
|
|
10
|
+
* const transformationName = getTransformationName(PlayerForm.PLAYERFORM_LORD_OF_THE_FLIES);
|
|
11
|
+
* // transformationName is "Beelzebub"
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTransformationName(transformation: PlayerForm): string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
require("lualib_bundle");
|
|
3
3
|
local ____exports = {}
|
|
4
|
-
local
|
|
5
|
-
local ITEM_TO_TRANSFORMATION_MAP =
|
|
6
|
-
local TRANSFORMATIONS_NOT_BASED_ON_ITEMS =
|
|
7
|
-
local TRANSFORMATION_TO_ITEMS_MAP =
|
|
4
|
+
local ____transformationMaps = require("maps.transformationMaps")
|
|
5
|
+
local ITEM_TO_TRANSFORMATION_MAP = ____transformationMaps.ITEM_TO_TRANSFORMATION_MAP
|
|
6
|
+
local TRANSFORMATIONS_NOT_BASED_ON_ITEMS = ____transformationMaps.TRANSFORMATIONS_NOT_BASED_ON_ITEMS
|
|
7
|
+
local TRANSFORMATION_TO_ITEMS_MAP = ____transformationMaps.TRANSFORMATION_TO_ITEMS_MAP
|
|
8
|
+
local ____transformationNameMap = require("maps.transformationNameMap")
|
|
9
|
+
local TRANSFORMATION_NAME_MAP = ____transformationNameMap.TRANSFORMATION_NAME_MAP
|
|
8
10
|
local ____util = require("functions.util")
|
|
9
11
|
local copySet = ____util.copySet
|
|
10
12
|
function ____exports.getPlayerNumTransformationCollectibles(self, player, playerForm)
|
|
@@ -31,4 +33,9 @@ function ____exports.getTransformationsForItem(self, collectibleType)
|
|
|
31
33
|
local transformations = ITEM_TO_TRANSFORMATION_MAP:get(collectibleType)
|
|
32
34
|
return ((transformations == nil) and __TS__New(Set)) or copySet(nil, transformations)
|
|
33
35
|
end
|
|
36
|
+
function ____exports.getTransformationName(self, transformation)
|
|
37
|
+
local defaultName = "Unknown"
|
|
38
|
+
local transformationName = TRANSFORMATION_NAME_MAP:get(transformation)
|
|
39
|
+
return ((transformationName == nil) and defaultName) or transformationName
|
|
40
|
+
end
|
|
34
41
|
return ____exports
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
|
|
3
|
-
trinketTypeRemoved: TrinketType | int;
|
|
4
|
-
trinket1: TrinketType | int;
|
|
5
|
-
trinket2: TrinketType | int;
|
|
6
|
-
numSmeltedTrinkets: int;
|
|
7
|
-
}
|
|
2
|
+
import { TrinketSituation } from "../types/TrinketSituation";
|
|
8
3
|
/**
|
|
9
|
-
* Helper function to temporarily remove a trinket from the player. Use this in
|
|
10
|
-
* `giveTrinketBack` function to take away and give back a trinket on the same
|
|
11
|
-
* correctly handles multiple trinket slots and ensures that all copies of the
|
|
12
|
-
* including smelted trinkets.
|
|
4
|
+
* Helper function to temporarily remove a specific kind of trinket from the player. Use this in
|
|
5
|
+
* combination with the `giveTrinketBack` function to take away and give back a trinket on the same
|
|
6
|
+
* frame. This function correctly handles multiple trinket slots and ensures that all copies of the
|
|
7
|
+
* trinket are removed, including smelted trinkets.
|
|
13
8
|
*
|
|
14
9
|
* Note that for simplicity, this function assumes that all smelted trinkets are non-golden.
|
|
15
10
|
*
|
|
16
|
-
* @returns
|
|
11
|
+
* @returns Undefined if the player does not have the trinket, or TrinketSituation if they do.
|
|
17
12
|
*/
|
|
18
|
-
export declare function
|
|
13
|
+
export declare function temporarilyRemoveTrinket(player: EntityPlayer, trinketType: TrinketType | int): TrinketSituation | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to temporarily removes a player's held trinkets, if any. This will not remove any
|
|
16
|
+
* smelted trinkets. Use this in combination with the `giveTrinketBack` function to take away and
|
|
17
|
+
* give back trinkets on the same frame.
|
|
18
|
+
*
|
|
19
|
+
* @returns Undefined if the player does not have any trinkets, or TrinketSituation if they do.
|
|
20
|
+
*/
|
|
21
|
+
export declare function temporarilyRemoveTrinkets(player: EntityPlayer): TrinketSituation | undefined;
|
|
19
22
|
/**
|
|
20
23
|
* Helper function to restore the player's trinkets back to the way they were before the
|
|
21
24
|
* `temporarilyRemoveTrinket` function was used. It will re-smelt any smelted trinkets that were
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____constants = require("constants")
|
|
4
4
|
local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
|
|
5
|
-
function ____exports.
|
|
5
|
+
function ____exports.temporarilyRemoveTrinket(self, player, trinketType)
|
|
6
6
|
if not player:HasTrinket(trinketType) then
|
|
7
7
|
return nil
|
|
8
8
|
end
|
|
@@ -24,6 +24,20 @@ function ____exports.temporarilyRemoveTrinkets(self, player, trinketType)
|
|
|
24
24
|
end
|
|
25
25
|
return {trinketTypeRemoved = trinketType, trinket1 = trinket1, trinket2 = trinket2, numSmeltedTrinkets = numSmeltedTrinkets}
|
|
26
26
|
end
|
|
27
|
+
function ____exports.temporarilyRemoveTrinkets(self, player)
|
|
28
|
+
local trinket1 = player:GetTrinket(0)
|
|
29
|
+
local trinket2 = player:GetTrinket(1)
|
|
30
|
+
if (trinket1 == TrinketType.TRINKET_NULL) and (trinket2 == TrinketType.TRINKET_NULL) then
|
|
31
|
+
return nil
|
|
32
|
+
end
|
|
33
|
+
if trinket1 ~= TrinketType.TRINKET_NULL then
|
|
34
|
+
player:TryRemoveTrinket(trinket1)
|
|
35
|
+
end
|
|
36
|
+
if trinket2 ~= TrinketType.TRINKET_NULL then
|
|
37
|
+
player:TryRemoveTrinket(trinket2)
|
|
38
|
+
end
|
|
39
|
+
return {trinketTypeRemoved = TrinketType.TRINKET_NULL, trinket1 = trinket1, trinket2 = trinket2, numSmeltedTrinkets = 0}
|
|
40
|
+
end
|
|
27
41
|
function ____exports.giveTrinketsBack(self, player, trinketSituation)
|
|
28
42
|
if trinketSituation == nil then
|
|
29
43
|
return
|
|
@@ -41,3 +41,14 @@ export declare function getTrinketName(trinketType: TrinketType | int): string;
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function hasOpenTrinketSlot(player: EntityPlayer): boolean;
|
|
43
43
|
export declare function isGoldenTrinket(trinketType: TrinketType | int): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Helper function to smelt a trinket. Before smelting, this function will automatically remove the
|
|
46
|
+
* trinkets that the player is holding, if any, and then give them back after the new trinket is
|
|
47
|
+
* smelted.
|
|
48
|
+
*
|
|
49
|
+
* @param player The player to smelt the trinkets to.
|
|
50
|
+
* @param trinketType The trinket type to smelt.
|
|
51
|
+
* @param numTrinkets Optional. If specified, will smelt the given number of trinkets. Use this to
|
|
52
|
+
* avoid calling this function multiple times. 1 by default.
|
|
53
|
+
*/
|
|
54
|
+
export declare function smeltTrinket(player: EntityPlayer, trinketType: TrinketType | int, numTrinkets?: number): void;
|
|
@@ -7,6 +7,9 @@ local ____trinketDescriptionMap = require("maps.trinketDescriptionMap")
|
|
|
7
7
|
local TRINKET_DESCRIPTION_MAP = ____trinketDescriptionMap.TRINKET_DESCRIPTION_MAP
|
|
8
8
|
local ____trinketNameMap = require("maps.trinketNameMap")
|
|
9
9
|
local TRINKET_NAME_MAP = ____trinketNameMap.TRINKET_NAME_MAP
|
|
10
|
+
local ____trinketGive = require("functions.trinketGive")
|
|
11
|
+
local giveTrinketsBack = ____trinketGive.giveTrinketsBack
|
|
12
|
+
local temporarilyRemoveTrinkets = ____trinketGive.temporarilyRemoveTrinkets
|
|
10
13
|
function ____exports.getMaxTrinketID(self)
|
|
11
14
|
local itemConfig = Isaac.GetItemConfig()
|
|
12
15
|
return itemConfig:GetTrinkets().Size - 1
|
|
@@ -86,4 +89,19 @@ end
|
|
|
86
89
|
function ____exports.isGoldenTrinket(self, trinketType)
|
|
87
90
|
return trinketType > GOLDEN_TRINKET_SHIFT
|
|
88
91
|
end
|
|
92
|
+
function ____exports.smeltTrinket(self, player, trinketType, numTrinkets)
|
|
93
|
+
if numTrinkets == nil then
|
|
94
|
+
numTrinkets = 1
|
|
95
|
+
end
|
|
96
|
+
local trinketSituation = temporarilyRemoveTrinkets(nil, player)
|
|
97
|
+
do
|
|
98
|
+
local i = 0
|
|
99
|
+
while i < numTrinkets do
|
|
100
|
+
player:AddTrinket(trinketType)
|
|
101
|
+
player:UseActiveItem(CollectibleType.COLLECTIBLE_SMELTER, false, false, true, false)
|
|
102
|
+
i = i + 1
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
giveTrinketsBack(nil, player, trinketSituation)
|
|
106
|
+
end
|
|
89
107
|
return ____exports
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,8 @@ export * from "./maps/collectibleNameMap";
|
|
|
56
56
|
export * from "./maps/gridEntityXMLMap";
|
|
57
57
|
export * from "./maps/pillEffectNameMap";
|
|
58
58
|
export * from "./maps/roomShapeToTopLeftWallGridIndexMap";
|
|
59
|
-
export * from "./maps/
|
|
59
|
+
export * from "./maps/transformationMaps";
|
|
60
|
+
export * from "./maps/transformationNameMap";
|
|
60
61
|
export * from "./maps/trinketNameMap";
|
|
61
62
|
export * from "./sets/cards";
|
|
62
63
|
export * from "./types/CallbackParametersCustom";
|
|
@@ -72,4 +73,5 @@ export * from "./types/PickingUpItem";
|
|
|
72
73
|
export * from "./types/PlayerHealth";
|
|
73
74
|
export * from "./types/PocketItemDescription";
|
|
74
75
|
export * from "./types/PocketItemType";
|
|
76
|
+
export * from "./types/TrinketSituation";
|
|
75
77
|
export * from "./upgradeMod";
|
package/dist/index.lua
CHANGED
|
@@ -455,7 +455,15 @@ do
|
|
|
455
455
|
end
|
|
456
456
|
end
|
|
457
457
|
do
|
|
458
|
-
local ____export = require("maps.
|
|
458
|
+
local ____export = require("maps.transformationMaps")
|
|
459
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
460
|
+
if ____exportKey ~= "default" then
|
|
461
|
+
____exports[____exportKey] = ____exportValue
|
|
462
|
+
end
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
do
|
|
466
|
+
local ____export = require("maps.transformationNameMap")
|
|
459
467
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
460
468
|
if ____exportKey ~= "default" then
|
|
461
469
|
____exports[____exportKey] = ____exportValue
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
export declare const TRANSFORMATION_TO_TAG_MAP: Map<PlayerForm, ItemConfigTag>;
|
|
3
|
+
export declare const TRANSFORMATIONS_NOT_BASED_ON_ITEMS: Set<PlayerForm>;
|
|
4
|
+
export declare const TRANSFORMATION_TO_ITEMS_MAP: Map<PlayerForm, Set<number>>;
|
|
5
|
+
export declare const ITEM_TO_TRANSFORMATION_MAP: Map<number, Set<PlayerForm>>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
require("lualib_bundle");
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local initMaps
|
|
5
|
+
local ____collectibles = require("functions.collectibles")
|
|
6
|
+
local collectibleHasTag = ____collectibles.collectibleHasTag
|
|
7
|
+
local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
|
|
8
|
+
function initMaps(self)
|
|
9
|
+
for ____, playerForm in __TS__Iterator(
|
|
10
|
+
____exports.TRANSFORMATION_TO_TAG_MAP:keys()
|
|
11
|
+
) do
|
|
12
|
+
____exports.TRANSFORMATION_TO_ITEMS_MAP:set(
|
|
13
|
+
playerForm,
|
|
14
|
+
__TS__New(Set)
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
do
|
|
18
|
+
local collectibleType = 1
|
|
19
|
+
while collectibleType <= getMaxCollectibleID(nil) do
|
|
20
|
+
for ____, ____value in __TS__Iterator(
|
|
21
|
+
____exports.TRANSFORMATION_TO_TAG_MAP:entries()
|
|
22
|
+
) do
|
|
23
|
+
local playerForm
|
|
24
|
+
playerForm = ____value[1]
|
|
25
|
+
local tag
|
|
26
|
+
tag = ____value[2]
|
|
27
|
+
do
|
|
28
|
+
if not collectibleHasTag(nil, collectibleType, tag) then
|
|
29
|
+
goto __continue5
|
|
30
|
+
end
|
|
31
|
+
local items = ____exports.TRANSFORMATION_TO_ITEMS_MAP:get(playerForm)
|
|
32
|
+
if items == nil then
|
|
33
|
+
error(
|
|
34
|
+
"Failed to get the items for transformation: " .. tostring(playerForm)
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
items:add(collectibleType)
|
|
38
|
+
local transformations = ____exports.ITEM_TO_TRANSFORMATION_MAP:get(collectibleType)
|
|
39
|
+
if transformations == nil then
|
|
40
|
+
transformations = __TS__New(Set)
|
|
41
|
+
____exports.ITEM_TO_TRANSFORMATION_MAP:set(collectibleType, transformations)
|
|
42
|
+
end
|
|
43
|
+
transformations:add(playerForm)
|
|
44
|
+
end
|
|
45
|
+
::__continue5::
|
|
46
|
+
end
|
|
47
|
+
collectibleType = collectibleType + 1
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
____exports.TRANSFORMATION_TO_TAG_MAP = __TS__New(Map, {{PlayerForm.PLAYERFORM_GUPPY, 32}, {PlayerForm.PLAYERFORM_LORD_OF_THE_FLIES, 64}, {PlayerForm.PLAYERFORM_MUSHROOM, 256}, {PlayerForm.PLAYERFORM_ANGEL, 1024}, {PlayerForm.PLAYERFORM_BOB, 128}, {PlayerForm.PLAYERFORM_DRUGS, 2}, {PlayerForm.PLAYERFORM_MOM, 4}, {PlayerForm.PLAYERFORM_BABY, 512}, {PlayerForm.PLAYERFORM_EVIL_ANGEL, 2048}, {PlayerForm.PLAYERFORM_POOP, 4096}, {PlayerForm.PLAYERFORM_BOOK_WORM, 8192}, {PlayerForm.PLAYERFORM_SPIDERBABY, 16384}})
|
|
52
|
+
____exports.TRANSFORMATIONS_NOT_BASED_ON_ITEMS = __TS__New(Set, {PlayerForm.PLAYERFORM_ADULTHOOD, PlayerForm.PLAYERFORM_STOMPY, PlayerForm.PLAYERFORM_FLIGHT})
|
|
53
|
+
____exports.TRANSFORMATION_TO_ITEMS_MAP = __TS__New(Map)
|
|
54
|
+
____exports.ITEM_TO_TRANSFORMATION_MAP = __TS__New(Map)
|
|
55
|
+
initMaps(nil)
|
|
56
|
+
return ____exports
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
require("lualib_bundle");
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
____exports.TRANSFORMATION_NAME_MAP = __TS__New(Map, {{PlayerForm.PLAYERFORM_GUPPY, "Guppy"}, {PlayerForm.PLAYERFORM_LORD_OF_THE_FLIES, "Beelzebub"}, {PlayerForm.PLAYERFORM_MUSHROOM, "Fun Guy"}, {PlayerForm.PLAYERFORM_ANGEL, "Seraphim"}, {PlayerForm.PLAYERFORM_BOB, "Bob"}, {PlayerForm.PLAYERFORM_DRUGS, "Spun"}, {PlayerForm.PLAYERFORM_MOM, "Yes Mother?"}, {PlayerForm.PLAYERFORM_BABY, "Conjoined"}, {PlayerForm.PLAYERFORM_EVIL_ANGEL, "Leviathan"}, {PlayerForm.PLAYERFORM_POOP, "Oh Crap"}, {PlayerForm.PLAYERFORM_BOOK_WORM, "Bookworm"}, {PlayerForm.PLAYERFORM_ADULTHOOD, "Adult"}, {PlayerForm.PLAYERFORM_SPIDERBABY, "Spider Baby"}, {PlayerForm.PLAYERFORM_STOMPY, "Stompy"}, {PlayerForm.PLAYERFORM_FLIGHT, "Flight"}})
|
|
5
|
+
return ____exports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.545",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
29
|
-
"isaacscript-lint": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.306",
|
|
29
|
+
"isaacscript-lint": "^1.0.73",
|
|
30
30
|
"typedoc": "^0.22.10",
|
|
31
31
|
"typescript": "4.4.4",
|
|
32
32
|
"typescript-to-lua": "1.1.1"
|