isaacscript-common 2.3.1 → 3.1.0
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/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/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 +1 -1
- package/enums/ModCallbackCustom.lua +6 -0
- 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/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 +6 -1
- package/functions/collectibles.lua +146 -2
- 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 +1 -0
- package/functions/direction.lua +22 -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.lua +166 -0
- package/functions/playerDataStructures.lua +65 -0
- package/functions/playerHealth.d.ts +1 -0
- package/functions/playerHealth.lua +10 -0
- 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/initCustomCallbacks.lua +3 -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/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
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
|
/**
|
package/functions/tstlClass.lua
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
-
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
|
-
local Map = ____lualib.Map
|
|
6
|
-
local WeakMap = ____lualib.WeakMap
|
|
7
|
-
local WeakSet = ____lualib.WeakSet
|
|
8
4
|
local ____exports = {}
|
|
9
|
-
local newTSTLClassFromMetatable
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
local newTSTLClassFromMetatable, VANILLA_TSTL_CLASSES
|
|
6
|
+
--- Helper function to get the name of a TypeScriptToLua class. TSTL classes are Lua tables created
|
|
7
|
+
-- with the `__TS__Class` Lua function from the TSTL lualib. Their name is contained within
|
|
8
|
+
-- "constructor.name" metatable key.
|
|
9
|
+
--
|
|
10
|
+
-- For example, a `Map` class is has a name of "Map".
|
|
11
|
+
--
|
|
12
|
+
-- Returns undefined if the object is not a table or if the aforementioned metatable key does not
|
|
13
|
+
-- exist.
|
|
14
|
+
function ____exports.getTSTLClassName(self, object)
|
|
15
|
+
if type(object) ~= "table" then
|
|
16
|
+
return nil
|
|
17
|
+
end
|
|
18
|
+
local metatable = getmetatable(object)
|
|
19
|
+
if metatable == nil then
|
|
20
|
+
return nil
|
|
21
|
+
end
|
|
22
|
+
local constructor = metatable.constructor
|
|
23
|
+
if constructor == nil then
|
|
24
|
+
return nil
|
|
25
|
+
end
|
|
26
|
+
return constructor.name
|
|
27
|
+
end
|
|
28
|
+
--- Returns whether or not this is a class that is provided as part of the TypeScriptToLua
|
|
29
|
+
-- transpiler, such as a `Map` or a `Set`.
|
|
12
30
|
function ____exports.isVanillaTSTLClass(self, object)
|
|
13
|
-
|
|
31
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
32
|
+
if className == nil then
|
|
33
|
+
return false
|
|
34
|
+
end
|
|
35
|
+
return VANILLA_TSTL_CLASSES:has(className)
|
|
14
36
|
end
|
|
15
37
|
function newTSTLClassFromMetatable(self, metatable)
|
|
16
38
|
local newClass = {}
|
|
@@ -18,10 +40,38 @@ function newTSTLClassFromMetatable(self, metatable)
|
|
|
18
40
|
newClassMetatable:____constructor()
|
|
19
41
|
return newClass
|
|
20
42
|
end
|
|
43
|
+
VANILLA_TSTL_CLASSES = __TS__New(Set, {"Map", "Set", "WeakMap", "WeakSet"})
|
|
21
44
|
local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
|
|
45
|
+
--- Helper function to determine if a given object is a TypeScriptToLua `Map`.
|
|
46
|
+
--
|
|
47
|
+
-- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
48
|
+
-- their own copies of the entire lualib and thus their own instantiated version of a `Map`.
|
|
49
|
+
function ____exports.isDefaultMap(self, object)
|
|
50
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
51
|
+
return className == "DefaultMap"
|
|
52
|
+
end
|
|
53
|
+
--- Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
|
|
54
|
+
-- as a `DefaultMap`.
|
|
22
55
|
function ____exports.isIsaacScriptCommonClass(self, object)
|
|
23
|
-
return
|
|
56
|
+
return ____exports.isDefaultMap(nil, object)
|
|
57
|
+
end
|
|
58
|
+
--- Helper function to determine if a given object is a TypeScriptToLua `Map`.
|
|
59
|
+
--
|
|
60
|
+
-- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
61
|
+
-- their own copies of the entire lualib and thus their own instantiated version of a `Map`.
|
|
62
|
+
function ____exports.isTSTLMap(self, object)
|
|
63
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
64
|
+
return className == "Map"
|
|
65
|
+
end
|
|
66
|
+
--- Helper function to determine if a given object is a TypeScriptToLua `Set`.
|
|
67
|
+
--
|
|
68
|
+
-- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
69
|
+
-- their own copies of the entire lualib and thus their own instantiated version of a `Set`.
|
|
70
|
+
function ____exports.isTSTLSet(self, object)
|
|
71
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
72
|
+
return className == "Set"
|
|
24
73
|
end
|
|
74
|
+
--- TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys.
|
|
25
75
|
function ____exports.isUserDefinedTSTLClass(self, object)
|
|
26
76
|
if ____exports.isVanillaTSTLClass(nil, object) or ____exports.isIsaacScriptCommonClass(nil, object) then
|
|
27
77
|
return false
|
|
@@ -46,6 +96,10 @@ function ____exports.isUserDefinedTSTLClass(self, object)
|
|
|
46
96
|
end
|
|
47
97
|
return numKeys == TSTL_CLASS_METATABLE_KEYS.size
|
|
48
98
|
end
|
|
99
|
+
--- Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
|
|
100
|
+
-- it is. This function requires that you provide an instantiated class of the same type, as it will
|
|
101
|
+
-- use the class constructor that is present on the other object's metatable to initialize the new
|
|
102
|
+
-- class.
|
|
49
103
|
function ____exports.newTSTLClass(self, oldClass)
|
|
50
104
|
local metatable = getmetatable(oldClass)
|
|
51
105
|
if metatable == nil then
|
package/functions/ui.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
4
|
/**
|
|
3
5
|
* In the options menu, players have the ability to set a HUD offset. However, mods do not have
|
|
4
6
|
* access to this value. To get around this, Mod Config Menu provides a separate HUD offset setting
|
package/functions/ui.lua
CHANGED
|
@@ -14,6 +14,14 @@ function ____exports.getScreenBottomRightPos(self)
|
|
|
14
14
|
local screenHeight = Isaac.GetScreenHeight()
|
|
15
15
|
return Vector(screenWidth, screenHeight)
|
|
16
16
|
end
|
|
17
|
+
--- In the options menu, players have the ability to set a HUD offset. However, mods do not have
|
|
18
|
+
-- access to this value. To get around this, Mod Config Menu provides a separate HUD offset setting
|
|
19
|
+
-- on the first page of the menu. This is intended to be set by end-users to match their vanilla HUD
|
|
20
|
+
-- offset setting so that mods can render UI elements to the screen in the correct position.
|
|
21
|
+
--
|
|
22
|
+
-- @returns If the user does not have Mod Config Menu enabled, or does not have this option set,
|
|
23
|
+
-- then this function will return `Vector.Zero.` Otherwise, it will return a Vector that
|
|
24
|
+
-- represents a HUD offset that should be added to the position of a UI element.
|
|
17
25
|
function ____exports.getHUDOffsetVector(self)
|
|
18
26
|
local defaultVector = copyVector(nil, VectorZero)
|
|
19
27
|
local hudOffset = math.floor(Options.HUDOffset * 10)
|
|
@@ -30,6 +38,8 @@ function ____exports.getHUDOffsetVector(self)
|
|
|
30
38
|
end
|
|
31
39
|
return Vector(x, y)
|
|
32
40
|
end
|
|
41
|
+
--- Returns how many hearts are in the heart UI row. If the player has more than 6 hearts, this
|
|
42
|
+
-- function will return 6.
|
|
33
43
|
function ____exports.getHeartRowLength(self, player)
|
|
34
44
|
local maxHearts = player:GetMaxHearts()
|
|
35
45
|
local soulHearts = player:GetSoulHearts()
|
|
@@ -38,6 +48,9 @@ function ____exports.getHeartRowLength(self, player)
|
|
|
38
48
|
local heartRowLength = combinedHearts / 2
|
|
39
49
|
return math.min(heartRowLength, 6)
|
|
40
50
|
end
|
|
51
|
+
--- Helper function to get the width of the first player's hearts on the UI. This is useful for
|
|
52
|
+
-- drawing UI elements to the right of where the player's hearts are. Make sure to use this in
|
|
53
|
+
-- combination with the the `getHUDOffsetVector` helper function.
|
|
41
54
|
function ____exports.getHeartsUIWidth(self)
|
|
42
55
|
local level = game:GetLevel()
|
|
43
56
|
local curses = level:GetCurses()
|
|
@@ -81,6 +94,9 @@ function ____exports.getScreenTopRightPos(self)
|
|
|
81
94
|
local bottomRight = ____exports.getScreenBottomRightPos(nil)
|
|
82
95
|
return Vector(bottomRight.X, 0)
|
|
83
96
|
end
|
|
97
|
+
--- Get how many hearts are currently being shown on the hearts UI.
|
|
98
|
+
--
|
|
99
|
+
-- This function is originally from piber20 Helper.
|
|
84
100
|
function ____exports.getVisibleHearts(self, player)
|
|
85
101
|
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
86
102
|
local soulHearts = player:GetSoulHearts()
|
package/functions/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
3
|
/**
|
|
3
4
|
* Helper function to get type safety on a switch statement.
|
|
4
5
|
*
|
|
@@ -65,6 +66,7 @@ export declare function hexToKColor(hexString: string, alpha: float): KColor;
|
|
|
65
66
|
* If only one argument is specified, then it will assume that the start is 0.
|
|
66
67
|
*/
|
|
67
68
|
export declare function irange(start: int, end?: int): int[];
|
|
69
|
+
export declare function isPrimitive(variable: unknown): boolean;
|
|
68
70
|
/**
|
|
69
71
|
* Since this is a UI element, we do not want to draw it in water reflections. `renderOffset` will
|
|
70
72
|
* be a non-zero value in reflections.
|
|
@@ -110,3 +112,17 @@ export declare function repeat(n: int, func: (i: int) => void): void;
|
|
|
110
112
|
* This function does not actually do anything. (It is an "empty" function.)
|
|
111
113
|
*/
|
|
112
114
|
export declare function todo(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Helper function to sort a two-dimensional array by the first element.
|
|
117
|
+
*
|
|
118
|
+
* For example:
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
122
|
+
* myArray.sort(twoDimensionalSort);
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* From:
|
|
126
|
+
* https://stackoverflow.com/questions/16096872/how-to-sort-2-dimensional-array-by-column-value
|
|
127
|
+
*/
|
|
128
|
+
export declare function twoDimensionalSort<T>(a: T[], b: T[]): -1 | 0 | 1;
|