isaacscript-common 2.3.2 → 3.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/cachedClasses.d.ts +6 -4
- package/cachedClasses.lua +24 -0
- package/callbacks/customRevive.lua +2 -0
- package/callbacks/itemPickup.lua +2 -0
- package/callbacks/postBombInitLate.lua +2 -0
- package/callbacks/postBoneSwing.lua +2 -0
- package/callbacks/postCollectibleInitFirst.lua +2 -0
- package/callbacks/postCursedTeleport.lua +2 -0
- package/callbacks/postCustomDoorEnter.lua +44 -0
- package/callbacks/postDoorRender.lua +2 -0
- package/callbacks/postDoorUpdate.lua +2 -0
- package/callbacks/postEffectInitLate.lua +2 -0
- package/callbacks/postEffectStateChanged.lua +2 -0
- package/callbacks/postEsauJr.lua +2 -0
- package/callbacks/postFamiliarInitLate.lua +2 -0
- package/callbacks/postFamiliarStateChanged.lua +2 -0
- package/callbacks/postFlip.lua +2 -0
- package/callbacks/postGreedModeWave.lua +2 -0
- package/callbacks/postGridEntity.lua +2 -0
- package/callbacks/postGridEntityCollision.lua +2 -0
- package/callbacks/postGridEntityRender.lua +2 -0
- package/callbacks/postHolyMantleRemoved.lua +2 -0
- package/callbacks/postKnifeInitLate.lua +2 -0
- package/callbacks/postLaserInitLate.lua +2 -0
- package/callbacks/postNPCInitLate.lua +2 -0
- package/callbacks/postNPCStateChanged.lua +2 -0
- package/callbacks/postNewRoomEarly.lua +2 -0
- package/callbacks/postPickupCollect.lua +2 -0
- package/callbacks/postPickupInitFirst.d.ts +1 -0
- package/callbacks/postPickupInitFirst.lua +55 -0
- package/callbacks/postPickupInitLate.lua +2 -0
- package/callbacks/postPickupStateChanged.lua +2 -0
- package/callbacks/postPitRender.lua +2 -0
- package/callbacks/postPitUpdate.lua +2 -0
- package/callbacks/postPlayerChangeHealth.lua +2 -0
- package/callbacks/postPlayerChangeType.lua +2 -0
- package/callbacks/postPlayerFatalDamage.lua +2 -0
- package/callbacks/postPlayerInitLate.lua +2 -0
- package/callbacks/postPlayerReordered.lua +2 -0
- package/callbacks/postPoopRender.lua +2 -0
- package/callbacks/postPoopUpdate.lua +2 -0
- package/callbacks/postPressurePlateRender.lua +2 -0
- package/callbacks/postPressurePlateUpdate.lua +2 -0
- package/callbacks/postProjectileInitLate.lua +2 -0
- package/callbacks/postPurchase.lua +2 -0
- package/callbacks/postRockRender.lua +2 -0
- package/callbacks/postRockUpdate.lua +2 -0
- package/callbacks/postRoomClearChanged.lua +2 -0
- package/callbacks/postSacrifice.lua +2 -0
- package/callbacks/postSlotDestroyed.d.ts +1 -0
- package/callbacks/postSlotDestroyed.lua +66 -0
- package/callbacks/postSlotInitUpdate.lua +2 -0
- package/callbacks/postSlotRender.lua +5 -21
- package/callbacks/postSpikesRender.lua +2 -0
- package/callbacks/postSpikesUpdate.lua +2 -0
- package/callbacks/postTNTRender.lua +2 -0
- package/callbacks/postTNTUpdate.lua +2 -0
- package/callbacks/postTearInitLate.lua +2 -0
- package/callbacks/postTearInitVeryLate.lua +2 -0
- package/callbacks/postTransformation.lua +2 -0
- package/callbacks/postTrinketBreak.lua +2 -0
- package/callbacks/preBerserkDeath.lua +2 -0
- package/callbacks/preNewLevel.lua +2 -0
- package/callbacks/reorderedCallbacks.lua +16 -0
- package/callbacks/subscriptions/postBombInitLate.lua +6 -0
- package/callbacks/subscriptions/postBoneSwing.lua +6 -0
- package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
- package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
- package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
- package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
- package/callbacks/subscriptions/postCustomRevive.lua +6 -0
- package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
- package/callbacks/subscriptions/postDoorRender.lua +6 -0
- package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
- package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
- package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
- package/callbacks/subscriptions/postEsauJr.lua +6 -0
- package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
- package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
- package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
- package/callbacks/subscriptions/postFirstFlip.lua +6 -0
- package/callbacks/subscriptions/postFlip.lua +6 -0
- package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
- package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
- package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
- package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
- package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
- package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
- package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
- package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
- package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
- package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
- package/callbacks/subscriptions/postItemDischarged.lua +6 -0
- package/callbacks/subscriptions/postItemPickup.lua +6 -0
- package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
- package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
- package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
- package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
- package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
- package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
- package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
- package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
- package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
- package/callbacks/subscriptions/postPickupCollect.lua +6 -0
- package/callbacks/subscriptions/postPickupInitFirst.d.ts +3 -0
- package/callbacks/subscriptions/postPickupInitFirst.lua +29 -0
- package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
- package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
- package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
- package/callbacks/subscriptions/postPitRender.d.ts +1 -0
- package/callbacks/subscriptions/postPitRender.lua +6 -0
- package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPitUpdate.lua +6 -0
- package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
- package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
- package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
- package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
- package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
- package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
- package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
- package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
- package/callbacks/subscriptions/postPoopRender.lua +6 -0
- package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
- package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
- package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
- package/callbacks/subscriptions/postPurchase.lua +6 -0
- package/callbacks/subscriptions/postRockRender.d.ts +1 -0
- package/callbacks/subscriptions/postRockRender.lua +6 -0
- package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postRockUpdate.lua +6 -0
- package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
- package/callbacks/subscriptions/postSacrifice.lua +6 -0
- package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
- package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
- package/callbacks/subscriptions/postSlotInit.lua +6 -0
- package/callbacks/subscriptions/postSlotRender.lua +6 -0
- package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
- package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
- package/callbacks/subscriptions/postSpikesRender.lua +6 -0
- package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
- package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
- package/callbacks/subscriptions/postTNTRender.lua +6 -0
- package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
- package/callbacks/subscriptions/postTearInitLate.lua +6 -0
- package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
- package/callbacks/subscriptions/postTransformation.lua +6 -0
- package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
- package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
- package/callbacks/subscriptions/preCustomRevive.lua +6 -0
- package/callbacks/subscriptions/preItemPickup.lua +6 -0
- package/callbacks/subscriptions/preNewLevel.lua +6 -0
- package/classes/DefaultMap.d.ts +70 -39
- package/classes/DefaultMap.lua +94 -43
- package/classes/ModUpgraded.d.ts +3 -3
- package/classes/ModUpgraded.lua +5 -0
- package/constants.lua +41 -0
- package/constantsFirstLast.lua +63 -0
- package/enums/HealthType.lua +3 -0
- package/enums/ModCallbackCustom.d.ts +62 -40
- package/enums/ModCallbackCustom.lua +46 -38
- package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
- package/enums/private/SerializationBrand.lua +5 -0
- package/features/characterHealthConversion.lua +6 -0
- package/features/characterStats.lua +17 -0
- package/features/debugDisplay/exports.d.ts +17 -0
- package/features/debugDisplay/exports.lua +90 -0
- package/features/debugDisplay/v.d.ts +17 -0
- package/features/deployJSONRoom.d.ts +1 -0
- package/features/deployJSONRoom.lua +56 -0
- package/features/disableInputs.lua +45 -0
- package/features/disableSound.lua +14 -0
- package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
- package/features/extraConsoleCommands/init.lua +16 -0
- package/features/extraConsoleCommands/listCommands.lua +172 -0
- package/features/fadeInRemover.lua +10 -0
- package/features/fastReset.lua +10 -0
- package/features/forgottenSwitch.lua +4 -0
- package/features/getCollectibleItemPoolType.lua +5 -0
- package/features/playerInventory.lua +18 -0
- package/features/ponyDetection.lua +4 -0
- package/features/preventCollectibleRotation.lua +9 -0
- package/features/runInNFrames.lua +50 -0
- package/features/saveDataManager/constants.lua +1 -0
- package/features/saveDataManager/exports.lua +115 -0
- package/features/saveDataManager/load.lua +12 -8
- package/features/saveDataManager/main.lua +16 -3
- package/features/saveDataManager/maps.lua +3 -0
- package/features/saveDataManager/merge.lua +53 -21
- package/features/saveDataManager/save.lua +12 -7
- package/features/sirenHelpers.lua +13 -0
- package/features/taintedLazarusPlayers.lua +11 -0
- package/featuresInitialized.lua +6 -0
- package/functions/array.d.ts +2 -0
- package/functions/array.lua +85 -0
- package/functions/benchmark.lua +6 -0
- package/functions/bombs.d.ts +3 -0
- package/functions/bombs.lua +12 -0
- package/functions/boss.lua +35 -0
- package/functions/cacheFlag.lua +4 -0
- package/functions/cards.lua +60 -0
- package/functions/challenges.lua +1 -0
- package/functions/character.lua +23 -0
- package/functions/charge.lua +39 -0
- package/functions/chargeBar.d.ts +1 -0
- package/functions/chargeBar.lua +4 -0
- package/functions/collectibleCacheFlag.lua +15 -0
- package/functions/collectibleSet.lua +3 -0
- package/functions/collectibleTag.lua +9 -0
- package/functions/collectibles.d.ts +13 -8
- package/functions/collectibles.lua +147 -3
- package/functions/color.lua +18 -0
- package/functions/debug.lua +18 -0
- package/functions/deepCopy.lua +60 -26
- package/functions/deepCopyTests.lua +8 -5
- package/functions/direction.d.ts +8 -0
- package/functions/direction.lua +27 -0
- package/functions/doors.d.ts +1 -0
- package/functions/doors.lua +58 -0
- package/functions/entity.d.ts +4 -4
- package/functions/entity.lua +94 -6
- package/functions/entitySpecific.d.ts +20 -20
- package/functions/entitySpecific.lua +182 -0
- package/functions/entityTypes.d.ts +1 -1
- package/functions/entityTypes.lua +1 -0
- package/functions/enums.d.ts +2 -0
- package/functions/enums.lua +62 -0
- package/functions/familiars.lua +52 -0
- package/functions/flag.lua +77 -0
- package/functions/flying.lua +10 -0
- package/functions/globals.lua +8 -10
- package/functions/gridEntity.lua +105 -0
- package/functions/gridEntitySpecific.d.ts +5 -0
- package/functions/gridEntitySpecific.lua +8 -0
- package/functions/input.lua +11 -0
- package/functions/isaacAPIClass.d.ts +4 -4
- package/functions/isaacAPIClass.lua +15 -3
- package/functions/jsonHelpers.lua +11 -0
- package/functions/jsonRoom.d.ts +2 -0
- package/functions/jsonRoom.lua +5 -0
- package/functions/kColor.lua +9 -0
- package/functions/language.lua +5 -0
- package/functions/log.lua +31 -3
- package/functions/map.lua +18 -0
- package/functions/math.lua +26 -0
- package/functions/npc.lua +24 -0
- package/functions/pickupVariants.d.ts +11 -11
- package/functions/pickupVariants.lua +11 -0
- package/functions/pickups.d.ts +9 -9
- package/functions/pickups.lua +67 -0
- package/functions/pills.lua +45 -0
- package/functions/player.d.ts +7 -0
- package/functions/player.lua +210 -9
- package/functions/playerDataStructures.lua +65 -0
- package/functions/playerHealth.d.ts +3 -0
- package/functions/playerHealth.lua +92 -63
- package/functions/playerIndex.d.ts +2 -0
- package/functions/playerIndex.lua +47 -0
- package/functions/pocketItems.lua +18 -0
- package/functions/positionVelocity.d.ts +3 -0
- package/functions/positionVelocity.lua +46 -0
- package/functions/random.d.ts +2 -0
- package/functions/random.lua +32 -0
- package/functions/revive.d.ts +2 -0
- package/functions/revive.lua +15 -0
- package/functions/rng.d.ts +1 -0
- package/functions/rng.lua +19 -0
- package/functions/roomData.lua +68 -0
- package/functions/roomGrid.lua +21 -0
- package/functions/roomShape.lua +22 -0
- package/functions/rooms.lua +100 -0
- package/functions/run.lua +5 -0
- package/functions/seeds.lua +4 -0
- package/functions/serialization.lua +6 -2
- package/functions/set.d.ts +1 -0
- package/functions/set.lua +22 -0
- package/functions/spawnCollectible.lua +24 -0
- package/functions/sprite.d.ts +2 -0
- package/functions/sprite.lua +25 -0
- package/functions/stage.lua +16 -0
- package/functions/string.lua +6 -0
- package/functions/table.d.ts +12 -0
- package/functions/table.lua +53 -0
- package/functions/tears.d.ts +1 -0
- package/functions/tears.lua +12 -0
- package/functions/transformations.lua +18 -0
- package/functions/trinketCacheFlag.lua +3 -0
- package/functions/trinketGive.lua +24 -0
- package/functions/trinkets.lua +52 -0
- package/functions/tstlClass.d.ts +34 -0
- package/functions/tstlClass.lua +63 -9
- package/functions/ui.d.ts +2 -0
- package/functions/ui.lua +16 -0
- package/functions/utils.d.ts +16 -0
- package/functions/utils.lua +108 -0
- package/functions/vector.lua +13 -16
- package/index.d.ts +1 -0
- package/index.lua +8 -0
- package/initCustomCallbacks.lua +6 -0
- package/interfaces/AddCallbackParameterCustom.d.ts +2 -0
- package/interfaces/ChargeBarSprites.d.ts +1 -0
- package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
- package/lualib_bundle.lua +21 -34
- package/maps/cardMap.lua +1 -0
- package/maps/characterMap.lua +1 -0
- package/maps/defaultPlayerStatMap.lua +1 -0
- package/maps/gridEntityXMLMap.lua +2 -0
- package/maps/pillEffectMap.lua +1 -0
- package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
- package/maps/roomTypeMap.lua +1 -0
- package/objects/LRoomShapeToRectangles.lua +2 -0
- package/objects/callbackRegisterFunctions.lua +3 -0
- package/objects/colors.lua +4 -0
- package/objects/oppositeDoorSlots.d.ts +4 -0
- package/objects/oppositeDoorSlots.lua +15 -0
- package/objects/roomShapeBounds.lua +2 -0
- package/objects/roomShapeLayoutSizes.lua +4 -0
- package/objects/roomShapeToBottomRightPosition.lua +2 -0
- package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
- package/objects/roomShapeToTopLeftPosition.lua +2 -0
- package/objects/roomShapeVolumes.lua +3 -0
- package/package.json +2 -2
- package/patchErrorFunctions.lua +8 -0
- package/sets/bossSets.lua +23 -0
- package/sets/charactersWithNoRedHeartsSet.lua +2 -0
- package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
- package/sets/lostStyleCharactersSet.lua +2 -0
- package/types/AnyEntity.d.ts +10 -0
- package/types/PickingUpItem.lua +7 -0
- package/upgradeMod.d.ts +4 -4
- package/upgradeMod.lua +18 -0
|
@@ -20,6 +20,20 @@ local anyPlayerIs = ____player.anyPlayerIs
|
|
|
20
20
|
local ____rng = require("functions.rng")
|
|
21
21
|
local getRandomSeed = ____rng.getRandomSeed
|
|
22
22
|
local isRNG = ____rng.isRNG
|
|
23
|
+
--- Helper function to spawn a collectible. Use this instead of the `Game.Spawn` method because it
|
|
24
|
+
-- handles the cases of Tainted Keeper collectibles costing coins and preventing quest items from
|
|
25
|
+
-- being rotated by Tainted Isaac's rotation mechanic. (Rotation prevention will only occur in
|
|
26
|
+
-- upgraded mods.)
|
|
27
|
+
--
|
|
28
|
+
-- @param collectibleType The collectible type to spawn.
|
|
29
|
+
-- @param position The position to spawn the collectible at.
|
|
30
|
+
-- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
31
|
+
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
32
|
+
-- @param options Optional. Set to true to make the collectible a "There's Options" style
|
|
33
|
+
-- collectible. Default is false.
|
|
34
|
+
-- @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
|
|
35
|
+
-- Tainted Keeper. Default is false.
|
|
36
|
+
-- @param spawner Optional.
|
|
23
37
|
function ____exports.spawnCollectible(self, collectibleType, position, seedOrRNG, options, forceFreeItem, spawner)
|
|
24
38
|
if seedOrRNG == nil then
|
|
25
39
|
seedOrRNG = getRandomSeed(nil)
|
|
@@ -52,6 +66,16 @@ function ____exports.spawnCollectible(self, collectibleType, position, seedOrRNG
|
|
|
52
66
|
end
|
|
53
67
|
return collectible
|
|
54
68
|
end
|
|
69
|
+
--- Helper function to spawn an empty collectible. Doing this is tricky since spawning a collectible
|
|
70
|
+
-- with `CollectibleType.NULL` will result in spawning a collectible with a random type from the
|
|
71
|
+
-- current room's item pool.
|
|
72
|
+
--
|
|
73
|
+
-- Instead, this function arbitrarily spawns a collectible with `CollectibleType.SAD_ONION`, and
|
|
74
|
+
-- then converts it to an empty pedestal afterward.
|
|
75
|
+
--
|
|
76
|
+
-- @param position The position to spawn the empty collectible at.
|
|
77
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
78
|
+
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
55
79
|
function ____exports.spawnEmptyCollectible(self, position, seedOrRNG)
|
|
56
80
|
if seedOrRNG == nil then
|
|
57
81
|
seedOrRNG = getRandomSeed(nil)
|
package/functions/sprite.d.ts
CHANGED
package/functions/sprite.lua
CHANGED
|
@@ -6,11 +6,22 @@ local ____kColor = require("functions.kColor")
|
|
|
6
6
|
local kColorEquals = ____kColor.kColorEquals
|
|
7
7
|
local ____utils = require("functions.utils")
|
|
8
8
|
local erange = ____utils.erange
|
|
9
|
+
--- Helper function to check if two texels on a sprite are equivalent to each other.
|
|
9
10
|
function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
|
|
10
11
|
local kColor1 = sprite1:GetTexel(position, VectorZero, 1, layerID)
|
|
11
12
|
local kColor2 = sprite2:GetTexel(position, VectorZero, 1, layerID)
|
|
12
13
|
return kColorEquals(nil, kColor1, kColor2)
|
|
13
14
|
end
|
|
15
|
+
--- Helper function to clear a specific layer from a sprite.
|
|
16
|
+
--
|
|
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.
|
|
19
|
+
--
|
|
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.
|
|
14
25
|
function ____exports.clearSprite(self, sprite, ...)
|
|
15
26
|
local layerIDs = {...}
|
|
16
27
|
if #layerIDs == 0 then
|
|
@@ -22,6 +33,15 @@ function ____exports.clearSprite(self, sprite, ...)
|
|
|
22
33
|
end
|
|
23
34
|
sprite:LoadGraphics()
|
|
24
35
|
end
|
|
36
|
+
--- Helper function that returns the number of the final frame in a particular animation for a
|
|
37
|
+
-- sprite. By default, it will use the currently playing animation, but you can also specify a
|
|
38
|
+
-- specific animation to check.
|
|
39
|
+
--
|
|
40
|
+
-- Note that this function is bugged with the Stop Watch or the Broken Watch, since using the
|
|
41
|
+
-- `Sprite.SetFrame` method will reset the internal accumulator used to slow down the playback speed
|
|
42
|
+
-- of the animation. (The `PlaybackSpeed` property of the sprite is not used.) Thus, it is only safe
|
|
43
|
+
-- to use this function on animations that are not slowed down by Stop Watch or Broken Watch, such
|
|
44
|
+
-- as player animations.
|
|
25
45
|
function ____exports.getLastFrameOfAnimation(self, sprite, animation)
|
|
26
46
|
local currentAnimation = sprite:GetAnimation()
|
|
27
47
|
local currentFrame = sprite:GetFrame()
|
|
@@ -36,6 +56,11 @@ function ____exports.getLastFrameOfAnimation(self, sprite, animation)
|
|
|
36
56
|
sprite:SetFrame(currentFrame)
|
|
37
57
|
return finalFrame
|
|
38
58
|
end
|
|
59
|
+
--- Helper function to check if two sprite layers have the same sprite sheet by using the
|
|
60
|
+
-- `Sprite.GetTexel` method.
|
|
61
|
+
--
|
|
62
|
+
-- Since checking every single texel in the entire sprite is very expensive, this function requires
|
|
63
|
+
-- that you provide a range of specific texels to check.
|
|
39
64
|
function ____exports.spriteEquals(self, sprite1, sprite2, layerID, xStart, xFinish, xIncrement, yStart, yFinish, yIncrement)
|
|
40
65
|
do
|
|
41
66
|
local x = xStart
|
package/functions/stage.lua
CHANGED
|
@@ -14,9 +14,16 @@ function ____exports.onRepentanceStage(self)
|
|
|
14
14
|
local stageType = level:GetStageType()
|
|
15
15
|
return ____exports.isRepentanceStage(nil, stageType)
|
|
16
16
|
end
|
|
17
|
+
--- Helper function to convert a numerical `StageType` into the letter suffix supplied to the "stage"
|
|
18
|
+
-- console command. For example, `StageType.REPENTANCE` is the stage type for Downpour, and the
|
|
19
|
+
-- console command to go to Downpour is "stage 1c", so this function converts `StageType.REPENTANCE`
|
|
20
|
+
-- to "c".
|
|
17
21
|
function ____exports.stageTypeToLetter(self, stageType)
|
|
18
22
|
return STAGE_TYPE_TO_LETTER[stageType]
|
|
19
23
|
end
|
|
24
|
+
--- Helper function to account for Repentance floors being offset by 1. For example, Downpour 2 is
|
|
25
|
+
-- the third level of the run, but the game considers it to have a stage of 2. This function will
|
|
26
|
+
-- consider Downpour 2 to have a stage of 3.
|
|
20
27
|
function ____exports.getEffectiveStage(self)
|
|
21
28
|
local level = game:GetLevel()
|
|
22
29
|
local stage = level:GetStage()
|
|
@@ -25,14 +32,17 @@ function ____exports.getEffectiveStage(self)
|
|
|
25
32
|
end
|
|
26
33
|
return stage
|
|
27
34
|
end
|
|
35
|
+
--- Alias for the `Level.GetStage` method.
|
|
28
36
|
function ____exports.getStage(self)
|
|
29
37
|
local level = game:GetLevel()
|
|
30
38
|
return level:GetStage()
|
|
31
39
|
end
|
|
40
|
+
--- Alias for the `Level.GetStageType` method.
|
|
32
41
|
function ____exports.getStageType(self)
|
|
33
42
|
local level = game:GetLevel()
|
|
34
43
|
return level:GetStageType()
|
|
35
44
|
end
|
|
45
|
+
--- Helper function to directly warp to a specific stage using the "stage" console command.
|
|
36
46
|
function ____exports.goToStage(self, stage, stageType)
|
|
37
47
|
local stageTypeLetterSuffix = ____exports.stageTypeToLetter(nil, stageType)
|
|
38
48
|
local command = ("stage " .. tostring(stage)) .. stageTypeLetterSuffix
|
|
@@ -56,6 +66,12 @@ function ____exports.onDarkRoom(self)
|
|
|
56
66
|
local stageType = level:GetStageType()
|
|
57
67
|
return stage == LevelStage.DARK_ROOM_CHEST and stageType == StageType.ORIGINAL
|
|
58
68
|
end
|
|
69
|
+
--- Returns whether or not the player is on the "final floor" of the particular run. The final floor
|
|
70
|
+
-- is defined as one that prevents the player from entering the I AM ERROR room on.
|
|
71
|
+
--
|
|
72
|
+
-- For example, when using Undefined on The Chest, it has a 50% chance of teleporting the player to
|
|
73
|
+
-- the Secret Room and a 50% chance of teleporting the player to the Super Secret Room, because the
|
|
74
|
+
-- I AM ERROR room is never entered into the list of possibilities.
|
|
59
75
|
function ____exports.onFinalFloor(self)
|
|
60
76
|
local level = game:GetLevel()
|
|
61
77
|
local stage = level:GetStage()
|
package/functions/string.lua
CHANGED
|
@@ -13,6 +13,10 @@ end
|
|
|
13
13
|
function ____exports.removeAllCharacters(self, ____string, character)
|
|
14
14
|
return __TS__StringReplaceAll(____string, character, "")
|
|
15
15
|
end
|
|
16
|
+
--- Helper function to remove one or more substrings from a string, if they exist. Returns the
|
|
17
|
+
-- modified string.
|
|
18
|
+
--
|
|
19
|
+
-- This function is variadic, meaning that you can pass as many substrings as you want to remove.
|
|
16
20
|
function ____exports.removeSubstring(self, ____string, ...)
|
|
17
21
|
local substrings = {...}
|
|
18
22
|
for ____, substring in ipairs(substrings) do
|
|
@@ -20,12 +24,14 @@ function ____exports.removeSubstring(self, ____string, ...)
|
|
|
20
24
|
end
|
|
21
25
|
return ____string
|
|
22
26
|
end
|
|
27
|
+
--- Helper function to trim a prefix from a string, if it exists. Returns the trimmed string.
|
|
23
28
|
function ____exports.trimPrefix(self, ____string, prefix)
|
|
24
29
|
if not __TS__StringStartsWith(____string, prefix) then
|
|
25
30
|
return ____string
|
|
26
31
|
end
|
|
27
32
|
return __TS__StringSlice(____string, #prefix)
|
|
28
33
|
end
|
|
34
|
+
--- Helper function to trim a suffix from a string, if it exists. Returns the trimmed string.
|
|
29
35
|
function ____exports.trimSuffix(self, ____string, prefix)
|
|
30
36
|
if not __TS__StringEndsWith(____string, prefix) then
|
|
31
37
|
return ____string
|
package/functions/table.d.ts
CHANGED
|
@@ -27,6 +27,18 @@ export declare function getNumbersFromTable(table: LuaTable<string, unknown>, ob
|
|
|
27
27
|
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
28
28
|
*/
|
|
29
29
|
export declare function getStringsFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to iterate over a table deterministically. This is useful because by default, the
|
|
32
|
+
* `pairs` function will return the keys of a Lua table in a random order.
|
|
33
|
+
*
|
|
34
|
+
* This function will sort the table entries based on the value of the key.
|
|
35
|
+
*
|
|
36
|
+
* @param table The table to iterate over.
|
|
37
|
+
* @param func The function to run for each iteration.
|
|
38
|
+
* @param deterministic Optional. Whether to iterate deterministically. True by default. You can
|
|
39
|
+
* dynamically set to false in situations where you need extra performance.
|
|
40
|
+
*/
|
|
41
|
+
export declare function iterateTableDeterministically<K, V>(table: LuaTable<K, V>, func: (key: K, value: V) => void, deterministic?: boolean): void;
|
|
30
42
|
/**
|
|
31
43
|
* Helper function to check if a Lua table has all of the provided keys.
|
|
32
44
|
*
|
package/functions/table.lua
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
3
|
+
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
3
4
|
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
4
5
|
local ____exports = {}
|
|
6
|
+
local ____utils = require("functions.utils")
|
|
7
|
+
local twoDimensionalSort = ____utils.twoDimensionalSort
|
|
8
|
+
--- In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
|
|
9
|
+
-- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
|
|
5
10
|
function ____exports.clearTable(self, ____table)
|
|
6
11
|
for key in pairs(____table) do
|
|
7
12
|
____table[key] = nil
|
|
8
13
|
end
|
|
9
14
|
end
|
|
15
|
+
--- Helper function to copy specific values from a object to a table.
|
|
10
16
|
function ____exports.copyValuesToTable(self, object, keys, ____table)
|
|
11
17
|
local otherTable = object
|
|
12
18
|
for ____, key in ipairs(keys) do
|
|
@@ -14,6 +20,10 @@ function ____exports.copyValuesToTable(self, object, keys, ____table)
|
|
|
14
20
|
____table[key] = value
|
|
15
21
|
end
|
|
16
22
|
end
|
|
23
|
+
--- Helper function to safely get boolean values from a Lua table. Will throw an error if the
|
|
24
|
+
-- specific value does not exist on the table.
|
|
25
|
+
--
|
|
26
|
+
-- This function is variadic, meaning that you can specify N arguments to get N values.
|
|
17
27
|
function ____exports.getBooleansFromTable(self, ____table, objectName, ...)
|
|
18
28
|
local keys = {...}
|
|
19
29
|
local booleans = {}
|
|
@@ -30,6 +40,10 @@ function ____exports.getBooleansFromTable(self, ____table, objectName, ...)
|
|
|
30
40
|
end
|
|
31
41
|
return booleans
|
|
32
42
|
end
|
|
43
|
+
--- Helper function to safely get number values from a Lua table. Will throw an error if the specific
|
|
44
|
+
-- value does not exist on the table or if it cannot be converted to a number.
|
|
45
|
+
--
|
|
46
|
+
-- This function is variadic, meaning that you can specify N arguments to get N values.
|
|
33
47
|
function ____exports.getNumbersFromTable(self, ____table, objectName, ...)
|
|
34
48
|
local keys = {...}
|
|
35
49
|
local numbers = {}
|
|
@@ -52,6 +66,10 @@ function ____exports.getNumbersFromTable(self, ____table, objectName, ...)
|
|
|
52
66
|
end
|
|
53
67
|
return numbers
|
|
54
68
|
end
|
|
69
|
+
--- Helper function to safely get string values from a Lua table. Will throw an error if the specific
|
|
70
|
+
-- value does not exist on the table.
|
|
71
|
+
--
|
|
72
|
+
-- This function is variadic, meaning that you can specify N arguments to get N values.
|
|
55
73
|
function ____exports.getStringsFromTable(self, ____table, objectName, ...)
|
|
56
74
|
local keys = {...}
|
|
57
75
|
local strings = {}
|
|
@@ -69,6 +87,41 @@ function ____exports.getStringsFromTable(self, ____table, objectName, ...)
|
|
|
69
87
|
end
|
|
70
88
|
return strings
|
|
71
89
|
end
|
|
90
|
+
--- Helper function to iterate over a table deterministically. This is useful because by default, the
|
|
91
|
+
-- `pairs` function will return the keys of a Lua table in a random order.
|
|
92
|
+
--
|
|
93
|
+
-- This function will sort the table entries based on the value of the key.
|
|
94
|
+
--
|
|
95
|
+
-- @param table The table to iterate over.
|
|
96
|
+
-- @param func The function to run for each iteration.
|
|
97
|
+
-- @param deterministic Optional. Whether to iterate deterministically. True by default. You can
|
|
98
|
+
-- dynamically set to false in situations where you need extra performance.
|
|
99
|
+
function ____exports.iterateTableDeterministically(self, ____table, func, deterministic)
|
|
100
|
+
if deterministic == nil then
|
|
101
|
+
deterministic = true
|
|
102
|
+
end
|
|
103
|
+
if not deterministic then
|
|
104
|
+
for key, value in pairs(____table) do
|
|
105
|
+
func(nil, key, value)
|
|
106
|
+
end
|
|
107
|
+
return
|
|
108
|
+
end
|
|
109
|
+
local entriesArray = {}
|
|
110
|
+
for key, value in pairs(____table) do
|
|
111
|
+
local entry = {key, value}
|
|
112
|
+
entriesArray[#entriesArray + 1] = entry
|
|
113
|
+
end
|
|
114
|
+
__TS__ArraySort(entriesArray, twoDimensionalSort)
|
|
115
|
+
for ____, ____value in ipairs(entriesArray) do
|
|
116
|
+
local key = ____value[1]
|
|
117
|
+
local value = ____value[2]
|
|
118
|
+
func(nil, key, value)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
--- Helper function to check if a Lua table has all of the provided keys.
|
|
122
|
+
--
|
|
123
|
+
-- This function is variadic, meaning that you can specify as many arguments as you want to check
|
|
124
|
+
-- for.
|
|
72
125
|
function ____exports.tableHasKeys(self, ____table, ...)
|
|
73
126
|
local keys = {...}
|
|
74
127
|
return __TS__ArrayEvery(
|
package/functions/tears.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
3
|
/**
|
|
3
4
|
* - Converts the specified amount of tears stat into MaxFireDelay and adds it to the player.
|
|
4
5
|
* - This function should only be used inside the EvaluateCache callback.
|
package/functions/tears.lua
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
--- - The `EntityPlayer` object stores a player's tear rate in the `MaxFireDelay` attribute. This is
|
|
3
|
+
-- equivalent to how many tears the player can shoot per frame.
|
|
4
|
+
-- - If you already have a "tears" stat and you want to convert it back to MaxFireDelay, then use
|
|
5
|
+
-- this function.
|
|
6
|
+
-- - In this context, the "tears stat" represents what is shown on the in-game stat UI.
|
|
2
7
|
function ____exports.getFireDelay(self, tearsStat)
|
|
3
8
|
return math.max(30 / tearsStat - 1, -0.9999)
|
|
4
9
|
end
|
|
10
|
+
--- - The `EntityPlayer` object stores a player's tear rate in the `MaxFireDelay` attribute. This is
|
|
11
|
+
-- equivalent to how many tears the player can shoot per frame.
|
|
12
|
+
-- - If you want to convert this to the "tears" stat that is shown on the in-game stat UI, then use
|
|
13
|
+
-- this function.
|
|
5
14
|
function ____exports.getTearsStat(self, fireDelay)
|
|
6
15
|
return 30 / (fireDelay + 1)
|
|
7
16
|
end
|
|
17
|
+
--- - Converts the specified amount of tears stat into MaxFireDelay and adds it to the player.
|
|
18
|
+
-- - This function should only be used inside the EvaluateCache callback.
|
|
19
|
+
-- - In this context, the "tears stat" represents what is shown on the in-game stat UI.
|
|
8
20
|
function ____exports.addTearsStat(self, player, tearsStat)
|
|
9
21
|
local existingTearsStat = ____exports.getTearsStat(nil, player.MaxFireDelay)
|
|
10
22
|
local newTearsStat = existingTearsStat + tearsStat
|
|
@@ -36,6 +36,14 @@ local TRANSFORMATION_TO_TAG_MAP = __TS__New(Map, {
|
|
|
36
36
|
{PlayerForm.SPIDER_BABY, ItemConfigTag.SPIDER}
|
|
37
37
|
})
|
|
38
38
|
local TRANSFORMATIONS_THAT_GRANT_FLYING = __TS__New(Set, {PlayerForm.GUPPY, PlayerForm.BEELZEBUB, PlayerForm.SERAPHIM, PlayerForm.LEVIATHAN})
|
|
39
|
+
--- Helper function to get all of the collectible types in the game that count towards a particular
|
|
40
|
+
-- transformation.
|
|
41
|
+
--
|
|
42
|
+
-- For example, to get all of the collectible types that count towards Guppy:
|
|
43
|
+
--
|
|
44
|
+
-- ```ts
|
|
45
|
+
-- const guppyCollectibleTypes = getCollectibleTypesForTransformation(PlayerForm.GUPPY);
|
|
46
|
+
-- ```
|
|
39
47
|
function ____exports.getCollectibleTypesForTransformation(self, playerForm)
|
|
40
48
|
local itemConfigTag = TRANSFORMATION_TO_TAG_MAP:get(playerForm)
|
|
41
49
|
if itemConfigTag == nil then
|
|
@@ -43,6 +51,7 @@ function ____exports.getCollectibleTypesForTransformation(self, playerForm)
|
|
|
43
51
|
end
|
|
44
52
|
return getCollectibleTypesWithTag(nil, itemConfigTag)
|
|
45
53
|
end
|
|
54
|
+
--- Returns the number of items that a player has towards a particular transformation.
|
|
46
55
|
function ____exports.getPlayerNumCollectiblesForTransformation(self, player, playerForm)
|
|
47
56
|
local collectibleTypes = ____exports.getCollectibleTypesForTransformation(nil, playerForm)
|
|
48
57
|
return getPlayerCollectibleCount(
|
|
@@ -51,6 +60,7 @@ function ____exports.getPlayerNumCollectiblesForTransformation(self, player, pla
|
|
|
51
60
|
__TS__Spread(collectibleTypes:values())
|
|
52
61
|
)
|
|
53
62
|
end
|
|
63
|
+
--- Returns a set of the player's current transformations.
|
|
54
64
|
function ____exports.getPlayerTransformations(self, player)
|
|
55
65
|
local transformations = __TS__New(Set)
|
|
56
66
|
for ____, playerForm in ipairs(getEnumValues(nil, PlayerForm)) do
|
|
@@ -60,6 +70,14 @@ function ____exports.getPlayerTransformations(self, player)
|
|
|
60
70
|
end
|
|
61
71
|
return transformations
|
|
62
72
|
end
|
|
73
|
+
--- Helper function to get a transformation name from a PlayerForm enum.
|
|
74
|
+
--
|
|
75
|
+
-- For example:
|
|
76
|
+
--
|
|
77
|
+
-- ```ts
|
|
78
|
+
-- const transformationName = getTransformationName(PlayerForm.LORD_OF_THE_FLIES);
|
|
79
|
+
-- // transformationName is "Beelzebub"
|
|
80
|
+
-- ```
|
|
63
81
|
function ____exports.getTransformationName(self, playerForm)
|
|
64
82
|
local transformationName = TRANSFORMATION_NAMES[playerForm]
|
|
65
83
|
return transformationName == nil and DEFAULT_TRANSFORMATION_NAME or transformationName
|
|
@@ -25,6 +25,7 @@ function initCacheFlagMap(self)
|
|
|
25
25
|
CACHE_FLAG_TO_TRINKETS_MAP:set(cacheFlag, trinketsSet)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
|
+
--- Returns a set containing every trinket type with the given cache flag, including modded trinkets.
|
|
28
29
|
function ____exports.getTrinketsForCacheFlag(self, cacheFlag)
|
|
29
30
|
if CACHE_FLAG_TO_TRINKETS_MAP.size == 0 then
|
|
30
31
|
initCacheFlagMap(nil)
|
|
@@ -36,6 +37,8 @@ function ____exports.getTrinketsForCacheFlag(self, cacheFlag)
|
|
|
36
37
|
return copySet(nil, trinketsSet)
|
|
37
38
|
end
|
|
38
39
|
CACHE_FLAG_TO_TRINKETS_MAP = __TS__New(Map)
|
|
40
|
+
--- Returns a map containing every trinket type that the player has that matches the provided
|
|
41
|
+
-- CacheFlag. The values of the map correspond to the multiplier for that trinket.
|
|
39
42
|
function ____exports.getPlayerTrinketsForCacheFlag(self, player, cacheFlag)
|
|
40
43
|
local trinketsForCacheFlag = ____exports.getTrinketsForCacheFlag(nil, cacheFlag)
|
|
41
44
|
local playerTrinkets = __TS__New(Map)
|
|
@@ -9,6 +9,11 @@ local ____trinkets = require("functions.trinkets")
|
|
|
9
9
|
local getGoldenTrinketType = ____trinkets.getGoldenTrinketType
|
|
10
10
|
local ____utils = require("functions.utils")
|
|
11
11
|
local ____repeat = ____utils["repeat"]
|
|
12
|
+
--- Helper function to temporarily removes a player's held trinkets, if any. This will not remove any
|
|
13
|
+
-- smelted trinkets. Use this in combination with the `giveTrinketsBack` function to take away and
|
|
14
|
+
-- give back trinkets on the same frame.
|
|
15
|
+
--
|
|
16
|
+
-- @returns Undefined if the player does not have any trinkets, or TrinketSituation if they do.
|
|
12
17
|
function ____exports.temporarilyRemoveTrinkets(self, player)
|
|
13
18
|
local trinketType1 = player:GetTrinket(TrinketSlot.SLOT_1)
|
|
14
19
|
local trinketType2 = player:GetTrinket(TrinketSlot.SLOT_2)
|
|
@@ -23,6 +28,9 @@ function ____exports.temporarilyRemoveTrinkets(self, player)
|
|
|
23
28
|
end
|
|
24
29
|
return {trinketTypeRemoved = TrinketType.NULL, trinketType1 = trinketType1, trinketType2 = trinketType2, numSmeltedTrinkets = 0}
|
|
25
30
|
end
|
|
31
|
+
--- Helper function to restore the player's trinkets back to the way they were before the
|
|
32
|
+
-- `temporarilyRemoveTrinket` function was used. It will re-smelt any smelted trinkets that were
|
|
33
|
+
-- removed.
|
|
26
34
|
function ____exports.giveTrinketsBack(self, player, trinketSituation)
|
|
27
35
|
if trinketSituation == nil then
|
|
28
36
|
return
|
|
@@ -50,6 +58,14 @@ function ____exports.giveTrinketsBack(self, player, trinketSituation)
|
|
|
50
58
|
player:AddTrinket(trinketSituation.trinketType2, false)
|
|
51
59
|
end
|
|
52
60
|
end
|
|
61
|
+
--- Helper function to smelt a trinket. Before smelting, this function will automatically remove the
|
|
62
|
+
-- trinkets that the player is holding, if any, and then give them back after the new trinket is
|
|
63
|
+
-- smelted.
|
|
64
|
+
--
|
|
65
|
+
-- @param player The player to smelt the trinkets to.
|
|
66
|
+
-- @param trinketType The trinket type to smelt.
|
|
67
|
+
-- @param numTrinkets Optional. If specified, will smelt the given number of trinkets. Use this to
|
|
68
|
+
-- avoid calling this function multiple times. Default is 1.
|
|
53
69
|
function ____exports.smeltTrinket(self, player, trinketType, numTrinkets)
|
|
54
70
|
if numTrinkets == nil then
|
|
55
71
|
numTrinkets = 1
|
|
@@ -65,6 +81,14 @@ function ____exports.smeltTrinket(self, player, trinketType, numTrinkets)
|
|
|
65
81
|
)
|
|
66
82
|
____exports.giveTrinketsBack(nil, player, trinketSituation)
|
|
67
83
|
end
|
|
84
|
+
--- Helper function to temporarily remove a specific kind of trinket from the player. Use this in
|
|
85
|
+
-- combination with the `giveTrinketsBack` function to take away and give back a trinket on the same
|
|
86
|
+
-- frame. This function correctly handles multiple trinket slots and ensures that all copies of the
|
|
87
|
+
-- trinket are removed, including smelted trinkets.
|
|
88
|
+
--
|
|
89
|
+
-- Note that one smelted golden trinket is the same as two smelted normal trinkets.
|
|
90
|
+
--
|
|
91
|
+
-- @returns Undefined if the player does not have the trinket, or TrinketSituation if they do.
|
|
68
92
|
function ____exports.temporarilyRemoveTrinket(self, player, trinketType)
|
|
69
93
|
if not player:HasTrinket(trinketType) then
|
|
70
94
|
return nil
|
package/functions/trinkets.lua
CHANGED
|
@@ -28,17 +28,41 @@ local ____sprite = require("functions.sprite")
|
|
|
28
28
|
local clearSprite = ____sprite.clearSprite
|
|
29
29
|
local ____utils = require("functions.utils")
|
|
30
30
|
local irange = ____utils.irange
|
|
31
|
+
--- Add this to a `TrinketType` to get the corresponding golden trinket type.
|
|
32
|
+
--
|
|
33
|
+
-- Corresponds to the vanilla `PillColor.TRINKET_GOLDEN_FLAG` value.
|
|
34
|
+
--
|
|
35
|
+
-- 1 << 15
|
|
31
36
|
local GOLDEN_TRINKET_ADJUSTMENT = 32768
|
|
32
37
|
local TRINKET_SPRITE_LAYER = 0
|
|
38
|
+
--- Helper function to get the corresponding golden trinket type from a normal trinket type.
|
|
39
|
+
--
|
|
40
|
+
-- For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
|
|
41
|
+
-- corresponds to the golden trinket sub-type for Swallowed Penny.
|
|
33
42
|
function ____exports.getGoldenTrinketType(self, trinketType)
|
|
34
43
|
return trinketType + GOLDEN_TRINKET_ADJUSTMENT
|
|
35
44
|
end
|
|
45
|
+
--- Helper function to get an array that represents every modded trinket type.
|
|
46
|
+
--
|
|
47
|
+
-- Returns an empty array if there are no modded trinket types.
|
|
36
48
|
function ____exports.getModdedTrinketTypes(self)
|
|
37
49
|
if LAST_VANILLA_TRINKET_TYPE == LAST_TRINKET_TYPE then
|
|
38
50
|
return {}
|
|
39
51
|
end
|
|
40
52
|
return irange(nil, FIRST_MODDED_TRINKET_TYPE, LAST_TRINKET_TYPE)
|
|
41
53
|
end
|
|
54
|
+
--- Returns the slot number corresponding to where a trinket can be safely inserted.
|
|
55
|
+
--
|
|
56
|
+
-- For example:
|
|
57
|
+
--
|
|
58
|
+
-- ```ts
|
|
59
|
+
-- const player = Isaac.GetPlayer();
|
|
60
|
+
-- const trinketSlot = getOpenTrinketSlotNum(player);
|
|
61
|
+
-- if (trinketSlot !== undefined) {
|
|
62
|
+
-- // They have one or more open trinket slots
|
|
63
|
+
-- player.AddTrinket(TrinketType.SWALLOWED_PENNY);
|
|
64
|
+
-- }
|
|
65
|
+
-- ```
|
|
42
66
|
function ____exports.getOpenTrinketSlot(self, player)
|
|
43
67
|
local maxTrinkets = player:GetMaxTrinkets()
|
|
44
68
|
local trinketType1 = player:GetTrinket(TrinketSlot.SLOT_1)
|
|
@@ -54,6 +78,8 @@ function ____exports.getOpenTrinketSlot(self, player)
|
|
|
54
78
|
end
|
|
55
79
|
return error("The player has an unknown number of trinket slots: " .. tostring(maxTrinkets))
|
|
56
80
|
end
|
|
81
|
+
--- Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
|
|
82
|
+
-- trinket type was not valid.
|
|
57
83
|
function ____exports.getTrinketDescription(self, trinketType)
|
|
58
84
|
local trinketDescription = TRINKET_DESCRIPTION_MAP:get(trinketType)
|
|
59
85
|
if trinketDescription ~= nil then
|
|
@@ -65,6 +91,15 @@ function ____exports.getTrinketDescription(self, trinketType)
|
|
|
65
91
|
end
|
|
66
92
|
return DEFAULT_TRINKET_DESCRIPTION
|
|
67
93
|
end
|
|
94
|
+
--- Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
|
|
95
|
+
-- not valid.
|
|
96
|
+
--
|
|
97
|
+
-- For example:
|
|
98
|
+
--
|
|
99
|
+
-- ```ts
|
|
100
|
+
-- const trinketType = TrinketType.SWALLOWED_PENNY;
|
|
101
|
+
-- const trinketName = getTrinketName(trinketType); // trinketName is "Swallowed Penny"
|
|
102
|
+
-- ```
|
|
68
103
|
function ____exports.getTrinketName(self, trinketType)
|
|
69
104
|
local trinketName = TRINKET_NAME_MAP:get(trinketType)
|
|
70
105
|
if trinketName ~= nil then
|
|
@@ -76,12 +111,19 @@ function ____exports.getTrinketName(self, trinketType)
|
|
|
76
111
|
end
|
|
77
112
|
return DEFAULT_TRINKET_NAME
|
|
78
113
|
end
|
|
114
|
+
--- Helper function to get an array that contains every trinket type.
|
|
79
115
|
function ____exports.getTrinketTypes(self)
|
|
80
116
|
return irange(nil, FIRST_TRINKET_TYPE, LAST_TRINKET_TYPE)
|
|
81
117
|
end
|
|
118
|
+
--- Helper function to get an array that represents every vanilla trinket type.
|
|
82
119
|
function ____exports.getVanillaTrinketTypes(self)
|
|
83
120
|
return irange(nil, FIRST_TRINKET_TYPE, LAST_VANILLA_TRINKET_TYPE)
|
|
84
121
|
end
|
|
122
|
+
--- Returns whether or not the player can hold an additional trinket, beyond what they are currently
|
|
123
|
+
-- carrying. This takes into account items that modify the max number of trinkets, like Mom's Purse.
|
|
124
|
+
--
|
|
125
|
+
-- If the player is the Tainted Soul, this always returns false, since that character cannot pick up
|
|
126
|
+
-- items. (Only Tainted Forgotten can pick up items.)
|
|
85
127
|
function ____exports.hasOpenTrinketSlot(self, player)
|
|
86
128
|
if isCharacter(nil, player, PlayerType.THE_SOUL_B) then
|
|
87
129
|
return false
|
|
@@ -92,6 +134,16 @@ end
|
|
|
92
134
|
function ____exports.isGoldenTrinket(self, trinketType)
|
|
93
135
|
return trinketType > GOLDEN_TRINKET_ADJUSTMENT
|
|
94
136
|
end
|
|
137
|
+
--- Helper function to change the sprite of a trinket entity.
|
|
138
|
+
--
|
|
139
|
+
-- For more information about removing the trinket sprite, see the documentation for the
|
|
140
|
+
-- "clearSprite" helper function.
|
|
141
|
+
--
|
|
142
|
+
-- @param trinket The trinket whose sprite you want to modify.
|
|
143
|
+
-- @param pngPath Equal to either the spritesheet path to load (e.g.
|
|
144
|
+
-- "gfx/items/trinkets/trinket_001_swallowedpenny.png") or undefined. If undefined,
|
|
145
|
+
-- the sprite will be removed, making it appear like the collectible has already been
|
|
146
|
+
-- taken by the player.
|
|
95
147
|
function ____exports.setTrinketSprite(self, trinket, pngPath)
|
|
96
148
|
if not isTrinket(nil, trinket) then
|
|
97
149
|
local entityID = getEntityID(nil, trinket)
|
package/functions/tstlClass.d.ts
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
|
+
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
|
+
import { DefaultMap } from "../classes/DefaultMap";
|
|
1
3
|
import { TSTLClass } from "../types/private/TSTLClass";
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to get the name of a TypeScriptToLua class. TSTL classes are Lua tables created
|
|
6
|
+
* with the `__TS__Class` Lua function from the TSTL lualib. Their name is contained within
|
|
7
|
+
* "constructor.name" metatable key.
|
|
8
|
+
*
|
|
9
|
+
* For example, a `Map` class is has a name of "Map".
|
|
10
|
+
*
|
|
11
|
+
* Returns undefined if the object is not a table or if the aforementioned metatable key does not
|
|
12
|
+
* exist.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTSTLClassName(object: unknown): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to determine if a given object is a TypeScriptToLua `Map`.
|
|
17
|
+
*
|
|
18
|
+
* It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
19
|
+
* their own copies of the entire lualib and thus their own instantiated version of a `Map`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isDefaultMap(object: unknown): object is DefaultMap<AnyNotNil, unknown>;
|
|
2
22
|
/**
|
|
3
23
|
* Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
|
|
4
24
|
* as a `DefaultMap`.
|
|
5
25
|
*/
|
|
6
26
|
export declare function isIsaacScriptCommonClass(object: unknown): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Helper function to determine if a given object is a TypeScriptToLua `Map`.
|
|
29
|
+
*
|
|
30
|
+
* It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
31
|
+
* their own copies of the entire lualib and thus their own instantiated version of a `Map`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isTSTLMap(object: unknown): object is Map<AnyNotNil, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to determine if a given object is a TypeScriptToLua `Set`.
|
|
36
|
+
*
|
|
37
|
+
* It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
38
|
+
* their own copies of the entire lualib and thus their own instantiated version of a `Set`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isTSTLSet(object: unknown): object is Set<AnyNotNil>;
|
|
7
41
|
/** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
|
|
8
42
|
export declare function isUserDefinedTSTLClass(object: unknown): object is TSTLClass;
|
|
9
43
|
/**
|