isaacscript-common 2.3.2 → 3.0.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.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/postSlotInitUpdate.lua +2 -0
- package/callbacks/postSlotRender.lua +2 -0
- 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.lua +6 -0
- package/callbacks/subscriptions/postDoorRender.lua +6 -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.lua +6 -0
- package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
- package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
- package/callbacks/subscriptions/postPitRender.lua +6 -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.lua +6 -0
- package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateRender.lua +6 -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.lua +6 -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.lua +6 -0
- package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
- package/callbacks/subscriptions/postTNTRender.lua +6 -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.lua +90 -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/main.lua +6 -0
- package/features/saveDataManager/maps.lua +3 -0
- package/features/saveDataManager/merge.lua +20 -0
- package/features/sirenHelpers.lua +13 -0
- package/features/taintedLazarusPlayers.lua +11 -0
- package/featuresInitialized.lua +6 -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.lua +4 -0
- package/functions/collectibleCacheFlag.lua +15 -0
- package/functions/collectibleSet.lua +3 -0
- package/functions/collectibleTag.lua +9 -0
- package/functions/collectibles.lua +131 -0
- package/functions/color.lua +18 -0
- package/functions/debug.lua +18 -0
- package/functions/deepCopy.lua +25 -0
- package/functions/doors.lua +53 -0
- package/functions/entity.lua +88 -0
- package/functions/entitySpecific.lua +182 -0
- package/functions/entityTypes.d.ts +1 -1
- package/functions/entityTypes.lua +1 -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 +6 -0
- package/functions/gridEntity.lua +105 -0
- package/functions/gridEntitySpecific.lua +8 -0
- package/functions/input.lua +11 -0
- package/functions/isaacAPIClass.lua +12 -0
- package/functions/jsonHelpers.lua +11 -0
- package/functions/jsonRoom.lua +5 -0
- package/functions/kColor.lua +9 -0
- package/functions/language.lua +5 -0
- package/functions/log.lua +28 -0
- 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.lua +67 -0
- package/functions/pills.lua +45 -0
- package/functions/player.lua +166 -0
- package/functions/playerDataStructures.lua +65 -0
- package/functions/playerHealth.lua +10 -0
- package/functions/playerIndex.lua +47 -0
- package/functions/pocketItems.lua +18 -0
- package/functions/positionVelocity.lua +46 -0
- package/functions/random.lua +32 -0
- package/functions/revive.lua +15 -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 +4 -0
- package/functions/set.lua +22 -0
- package/functions/spawnCollectible.lua +24 -0
- package/functions/sprite.lua +25 -0
- package/functions/stage.lua +16 -0
- package/functions/string.lua +6 -0
- package/functions/table.lua +19 -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.lua +9 -0
- package/functions/ui.lua +16 -0
- package/functions/utils.d.ts +1 -0
- package/functions/utils.lua +88 -0
- package/functions/vector.lua +9 -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/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/PickingUpItem.lua +7 -0
- package/upgradeMod.d.ts +4 -4
- package/upgradeMod.lua +18 -0
|
@@ -8,6 +8,12 @@ end
|
|
|
8
8
|
local function tryEncode(____table)
|
|
9
9
|
return json.encode(____table)
|
|
10
10
|
end
|
|
11
|
+
--- Converts a JSON string to a Lua table.
|
|
12
|
+
--
|
|
13
|
+
-- In most cases, this function will be used for reading data from a "save#.dat" file. If decoding
|
|
14
|
+
-- fails, it will return a blank Lua table instead of throwing an error. (This allows execution to
|
|
15
|
+
-- continue in cases where users have no current save data or have manually removed their existing
|
|
16
|
+
-- save data.)
|
|
11
17
|
function ____exports.jsonDecode(self, jsonString)
|
|
12
18
|
local ok, luaTableOrErrMsg = pcall(tryDecode, jsonString)
|
|
13
19
|
if not ok then
|
|
@@ -16,6 +22,11 @@ function ____exports.jsonDecode(self, jsonString)
|
|
|
16
22
|
end
|
|
17
23
|
return luaTableOrErrMsg
|
|
18
24
|
end
|
|
25
|
+
--- Converts a Lua table to a JSON string.
|
|
26
|
+
--
|
|
27
|
+
-- In most cases, this function will be used for writing data to a "save#.dat" file. If encoding
|
|
28
|
+
-- fails, it will throw an error to prevent writing a blank string or corrupted data to a user's
|
|
29
|
+
-- "save#.dat" file.
|
|
19
30
|
function ____exports.jsonEncode(self, ____table)
|
|
20
31
|
local ok, jsonStringOrErrMsg = pcall(tryEncode, ____table)
|
|
21
32
|
if not ok then
|
package/functions/jsonRoom.lua
CHANGED
|
@@ -66,6 +66,11 @@ function ____exports.getJSONRoomsOfSubType(self, jsonRooms, subType)
|
|
|
66
66
|
end
|
|
67
67
|
)
|
|
68
68
|
end
|
|
69
|
+
--- Helper function to get a random JSON room from an array of JSON rooms.
|
|
70
|
+
--
|
|
71
|
+
-- Note that this function does not simply choose a random element in the provided array; it will
|
|
72
|
+
-- properly account for each room weight using the algorithm from:
|
|
73
|
+
-- https://stackoverflow.com/questions/1761626/weighted-random-numbers
|
|
69
74
|
function ____exports.getRandomJSONRoom(self, jsonRooms, seedOrRNG, verbose)
|
|
70
75
|
if seedOrRNG == nil then
|
|
71
76
|
seedOrRNG = getRandomSeed(nil)
|
package/functions/kColor.lua
CHANGED
|
@@ -13,11 +13,17 @@ local getNumbersFromTable = ____table.getNumbersFromTable
|
|
|
13
13
|
local tableHasKeys = ____table.tableHasKeys
|
|
14
14
|
local ____utils = require("functions.utils")
|
|
15
15
|
local ensureAllCases = ____utils.ensureAllCases
|
|
16
|
+
--- Helper function to check if something is an instantiated KColor object.
|
|
16
17
|
function ____exports.isKColor(self, object)
|
|
17
18
|
return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
|
|
18
19
|
end
|
|
19
20
|
local KEYS = {"Red", "Green", "Blue", "Alpha"}
|
|
20
21
|
OBJECT_NAME = "KColor"
|
|
22
|
+
--- Helper function to copy a `KColor` object.
|
|
23
|
+
--
|
|
24
|
+
-- @param kColor The KColor object to copy. In the case of deserialization, this will actually be a
|
|
25
|
+
-- Lua table instead of an instantiated KColor class.
|
|
26
|
+
-- @param serializationType Default is `SerializationType.NONE`.
|
|
21
27
|
function ____exports.copyKColor(self, kColor, serializationType)
|
|
22
28
|
if serializationType == nil then
|
|
23
29
|
serializationType = SerializationType.NONE
|
|
@@ -80,9 +86,12 @@ function ____exports.copyKColor(self, kColor, serializationType)
|
|
|
80
86
|
end
|
|
81
87
|
until true
|
|
82
88
|
end
|
|
89
|
+
--- Returns `KColor(1, 1, 1, 1)`.
|
|
83
90
|
function ____exports.getDefaultKColor(self)
|
|
84
91
|
return KColor(1, 1, 1, 1)
|
|
85
92
|
end
|
|
93
|
+
--- Used to determine is the given table is a serialized `KColor` object created by the save data
|
|
94
|
+
-- manager and/or the `deepCopy` function.
|
|
86
95
|
function ____exports.isSerializedKColor(self, object)
|
|
87
96
|
local objectType = type(object)
|
|
88
97
|
if objectType ~= "table" then
|
package/functions/language.lua
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local ____languageNames = require("objects.languageNames")
|
|
3
3
|
local LANGUAGE_NAMES = ____languageNames.LANGUAGE_NAMES
|
|
4
|
+
--- Helper function to convert the language abbreviation from `Options.Language` to the "full"
|
|
5
|
+
-- language name.
|
|
6
|
+
--
|
|
7
|
+
-- For example, if the current language is set to Korean, `Options.Language` will be set to "kr",
|
|
8
|
+
-- and this function will return "Korean".
|
|
4
9
|
function ____exports.getLanguageName(self)
|
|
5
10
|
local languageAbbreviation = Options.Language
|
|
6
11
|
return LANGUAGE_NAMES[languageAbbreviation]
|
package/functions/log.lua
CHANGED
|
@@ -53,6 +53,7 @@ local ____utils = require("functions.utils")
|
|
|
53
53
|
local printConsole = ____utils.printConsole
|
|
54
54
|
local ____vector = require("functions.vector")
|
|
55
55
|
local vectorToString = ____vector.vectorToString
|
|
56
|
+
--- Helper function to prefix the name of the function and the line number before a debug message.
|
|
56
57
|
function ____exports.getDebugPrependString(self, msg, numParentFunctions)
|
|
57
58
|
if numParentFunctions == nil then
|
|
58
59
|
numParentFunctions = 3
|
|
@@ -68,10 +69,15 @@ function ____exports.getDebugPrependString(self, msg, numParentFunctions)
|
|
|
68
69
|
end
|
|
69
70
|
return msg
|
|
70
71
|
end
|
|
72
|
+
--- Helper function to avoid typing out `Isaac.DebugString()`.
|
|
73
|
+
--
|
|
74
|
+
-- If you have the "--luadebug" launch flag turned on or the Racing+ sandbox enabled, then this
|
|
75
|
+
-- function will also prepend the function name and the line number before the string.
|
|
71
76
|
function ____exports.log(msg)
|
|
72
77
|
local debugMsg = ____exports.getDebugPrependString(nil, msg)
|
|
73
78
|
Isaac.DebugString(debugMsg)
|
|
74
79
|
end
|
|
80
|
+
--- Helper function for printing out every flag that is turned on. Useful when debugging.
|
|
75
81
|
function ____exports.logFlags(flags, flagEnum, description)
|
|
76
82
|
if description == nil then
|
|
77
83
|
description = ""
|
|
@@ -111,6 +117,7 @@ end
|
|
|
111
117
|
function ____exports.logColor(color)
|
|
112
118
|
____exports.log((((((((((((("Color: R" .. tostring(color.R)) .. ", G") .. tostring(color.G)) .. ", B") .. tostring(color.B)) .. ", A") .. tostring(color.A)) .. ", RO") .. tostring(color.RO)) .. ", BO") .. tostring(color.BO)) .. ", GO") .. tostring(color.GO))
|
|
113
119
|
end
|
|
120
|
+
--- Helper function for printing out every damage flag that is turned on. Useful when debugging.
|
|
114
121
|
function ____exports.logDamageFlags(flags)
|
|
115
122
|
____exports.logFlags(flags, DamageFlag, "damage")
|
|
116
123
|
end
|
|
@@ -140,6 +147,7 @@ function ____exports.logEffects(player)
|
|
|
140
147
|
end
|
|
141
148
|
)
|
|
142
149
|
end
|
|
150
|
+
--- Helper function for printing out every entity (or filtered entity) in the current room.
|
|
143
151
|
function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
144
152
|
local msg = "Entities in the room"
|
|
145
153
|
if entityTypeFilter ~= nil then
|
|
@@ -225,17 +233,23 @@ function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
|
225
233
|
end
|
|
226
234
|
____exports.log(msg)
|
|
227
235
|
end
|
|
236
|
+
--- Helper function for printing out every entity flag that is turned on. Useful when debugging.
|
|
228
237
|
function ____exports.logEntityFlags(flags)
|
|
229
238
|
____exports.logFlags(flags, EntityFlag, "entity")
|
|
230
239
|
end
|
|
231
240
|
function ____exports.logEntityID(entity)
|
|
232
241
|
____exports.log((((("Entity: " .. tostring(entity.Type)) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType))
|
|
233
242
|
end
|
|
243
|
+
--- Helper function to log an error message and also print it to the console for better visibility.
|
|
244
|
+
--
|
|
245
|
+
-- This is useful in situations where using the `error` function would be dangerous (since it
|
|
246
|
+
-- prevents all of the subsequent code in the callback from running).
|
|
234
247
|
function ____exports.logError(msg)
|
|
235
248
|
local errorMsg = "Error: " .. msg
|
|
236
249
|
____exports.log(errorMsg)
|
|
237
250
|
printConsole(nil, errorMsg)
|
|
238
251
|
end
|
|
252
|
+
--- Helper function for printing out every game state flag that is turned on. Useful when debugging.
|
|
239
253
|
function ____exports.logGameStateFlags()
|
|
240
254
|
____exports.log("Logging game state flags:")
|
|
241
255
|
local gameStateFlagEntries = getEnumEntries(nil, GameStateFlag)
|
|
@@ -253,6 +267,7 @@ function ____exports.logGameStateFlags()
|
|
|
253
267
|
____exports.log(" n/a (no flags)")
|
|
254
268
|
end
|
|
255
269
|
end
|
|
270
|
+
--- Helper function for printing out every grid entity (or filtered grid entity) in the current room.
|
|
256
271
|
function ____exports.logGridEntities(includeWalls, gridEntityTypeFilter)
|
|
257
272
|
local msg = "Grid entities in the room"
|
|
258
273
|
if gridEntityTypeFilter ~= nil then
|
|
@@ -328,6 +343,7 @@ end
|
|
|
328
343
|
function ____exports.logKColor(kColor)
|
|
329
344
|
____exports.log((((((("Color: R" .. tostring(kColor.Red)) .. ", G") .. tostring(kColor.Green)) .. ", B") .. tostring(kColor.Blue)) .. ", A") .. tostring(kColor.Alpha))
|
|
330
345
|
end
|
|
346
|
+
--- Helper function for printing out every level state flag that is turned on. Useful when debugging.
|
|
331
347
|
function ____exports.logLevelStateFlags()
|
|
332
348
|
local level = game:GetLevel()
|
|
333
349
|
local levelStateFlagEntries = getEnumEntries(nil, LevelStateFlag)
|
|
@@ -372,9 +388,11 @@ function ____exports.logPlayerHealth(player)
|
|
|
372
388
|
____exports.log(" Blood charges: " .. tostring(playerHealth.bloodCharges))
|
|
373
389
|
____exports.log((" Soul heart types: [" .. table.concat(playerHealth.soulHeartTypes, ",")) .. "]")
|
|
374
390
|
end
|
|
391
|
+
--- Helper function for printing out every projectile flag that is turned on. Useful when debugging.
|
|
375
392
|
function ____exports.logProjectileFlags(flags)
|
|
376
393
|
____exports.logFlags(flags, ProjectileFlag, "projectile")
|
|
377
394
|
end
|
|
395
|
+
--- Helper function for logging information about the current room.
|
|
378
396
|
function ____exports.logRoom()
|
|
379
397
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
380
398
|
local roomListIndex = getRoomListIndex(nil)
|
|
@@ -389,6 +407,8 @@ function ____exports.logRoom()
|
|
|
389
407
|
____exports.log("Current room grid index: " .. tostring(roomGridIndex))
|
|
390
408
|
____exports.log("Current room list index: " .. tostring(roomListIndex))
|
|
391
409
|
end
|
|
410
|
+
--- Helper function for printing out every seed effect (i.e. Easter Egg) that is turned on for the
|
|
411
|
+
-- particular run.
|
|
392
412
|
function ____exports.logSeedEffects()
|
|
393
413
|
local seeds = game:GetSeeds()
|
|
394
414
|
local seedEffectEntries = getEnumEntries(nil, SeedEffect)
|
|
@@ -414,6 +434,7 @@ function ____exports.logSet(set)
|
|
|
414
434
|
end
|
|
415
435
|
____exports.log("The size of the set was: " .. tostring(set.size))
|
|
416
436
|
end
|
|
437
|
+
--- Helper function for logging every sound effect that is currently playing.
|
|
417
438
|
function ____exports.logSounds()
|
|
418
439
|
local soundEffects = getEnumEntries(nil, SoundEffect)
|
|
419
440
|
for ____, ____value in ipairs(soundEffects) do
|
|
@@ -455,12 +476,16 @@ function ____exports.logTable(____table, parentTables)
|
|
|
455
476
|
end
|
|
456
477
|
____exports.log("The size of the table was: " .. tostring(numKeys))
|
|
457
478
|
end
|
|
479
|
+
--- Helper function for printing out every tear flag that is turned on. Useful when debugging.
|
|
458
480
|
function ____exports.logTearFlags(flags)
|
|
459
481
|
____exports.logFlags(flags, TearFlag, "tear")
|
|
460
482
|
end
|
|
483
|
+
--- Helper function for printing out every use flag that is turned on. Useful when debugging.
|
|
461
484
|
function ____exports.logUseFlags(flags)
|
|
462
485
|
____exports.logFlags(flags, UseFlag, "use")
|
|
463
486
|
end
|
|
487
|
+
--- Helper function to enumerate all of the properties of a "userdata" object (i.e. an object from
|
|
488
|
+
-- the Isaac API).
|
|
464
489
|
function ____exports.logUserdata(userdata)
|
|
465
490
|
local userdataType = type(userdata)
|
|
466
491
|
if userdataType ~= "userdata" then
|
|
@@ -487,6 +512,9 @@ function ____exports.logVector(vector, round)
|
|
|
487
512
|
local vectorString = vectorToString(nil, vector, round)
|
|
488
513
|
____exports.log("Vector: " .. vectorString)
|
|
489
514
|
end
|
|
515
|
+
--- Converts every `isaacscript-common` function that begins with "log" to a global function.
|
|
516
|
+
--
|
|
517
|
+
-- This is useful when printing out variables from the in-game debug console.
|
|
490
518
|
function ____exports.setLogFunctionsGlobal(self)
|
|
491
519
|
local globals = _G
|
|
492
520
|
globals.log = ____exports.log
|
package/functions/map.lua
CHANGED
|
@@ -8,6 +8,7 @@ local __TS__StringReplaceAll = ____lualib.__TS__StringReplaceAll
|
|
|
8
8
|
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
|
|
9
9
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
10
10
|
local ____exports = {}
|
|
11
|
+
--- Helper function to copy a map. (You can also use a Map constructor to accomplish this task.)
|
|
11
12
|
function ____exports.copyMap(self, oldMap)
|
|
12
13
|
local newMap = __TS__New(Map)
|
|
13
14
|
for ____, ____value in __TS__Iterator(oldMap:entries()) do
|
|
@@ -17,6 +18,23 @@ function ____exports.copyMap(self, oldMap)
|
|
|
17
18
|
end
|
|
18
19
|
return newMap
|
|
19
20
|
end
|
|
21
|
+
--- Helper function to get the closest value from a map based on partial search text. For the
|
|
22
|
+
-- purposes of this function, both search text and map keys are converted to lowercase before
|
|
23
|
+
-- attempting to find a match.
|
|
24
|
+
--
|
|
25
|
+
-- For example:
|
|
26
|
+
--
|
|
27
|
+
-- ```ts
|
|
28
|
+
-- const map = new <string, number>Map([
|
|
29
|
+
-- ["foo", 123],
|
|
30
|
+
-- ["bar", 456],
|
|
31
|
+
-- ]);
|
|
32
|
+
-- const searchText = "f";
|
|
33
|
+
-- const match = getMapPartialMatch(map, searchText); // match is now equal to 123
|
|
34
|
+
--
|
|
35
|
+
-- @returns If a match was found, returns a tuple of the map key and value. If a match was not
|
|
36
|
+
-- found, returns undefined.
|
|
37
|
+
-- ```
|
|
20
38
|
function ____exports.getMapPartialMatch(self, searchText, map)
|
|
21
39
|
local keys = {__TS__Spread(map:keys())}
|
|
22
40
|
__TS__ArraySort(keys)
|
package/functions/math.lua
CHANGED
|
@@ -3,6 +3,10 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
|
|
|
3
3
|
local Direction = ____isaac_2Dtypescript_2Ddefinitions.Direction
|
|
4
4
|
local ____direction = require("functions.direction")
|
|
5
5
|
local directionToVector = ____direction.directionToVector
|
|
6
|
+
--- Helper function to normalize an integer.
|
|
7
|
+
--
|
|
8
|
+
-- - If `x` is less than `min`, then it will be clamped to `min`.
|
|
9
|
+
-- - If `x` is greater than `max`, then it will be clamped to `max`.
|
|
6
10
|
function ____exports.clamp(self, x, min, max)
|
|
7
11
|
return math.max(
|
|
8
12
|
min,
|
|
@@ -13,6 +17,16 @@ function ____exports.getAngleDifference(self, angle1, angle2)
|
|
|
13
17
|
local subtractedAngle = angle1 - angle2
|
|
14
18
|
return (subtractedAngle + 180) % 360 - 180
|
|
15
19
|
end
|
|
20
|
+
--- Helper function to get an array of equidistant points on the circumference around a circle.
|
|
21
|
+
-- Useful for equally distributing things in a circle pattern.
|
|
22
|
+
--
|
|
23
|
+
-- @param centerPos A position that represents the center of the center to get the points from.
|
|
24
|
+
-- @param radius The radius of the circle.
|
|
25
|
+
-- @param numPoints The number of points on the circumference of the circle to get.
|
|
26
|
+
-- @param xMultiplier An optional multiplier to get the points around an oval. Default is 1.
|
|
27
|
+
-- @param yMultiplier An optional multiplier to get the points around an oval. Default is 1.
|
|
28
|
+
-- @param initialDirection By default, the first point on the circle will be on the top center, but
|
|
29
|
+
-- this can be optionally changed by specifying this argument.
|
|
16
30
|
function ____exports.getCircleDiscretizedPoints(self, centerPos, radius, numPoints, xMultiplier, yMultiplier, initialDirection)
|
|
17
31
|
if xMultiplier == nil then
|
|
18
32
|
xMultiplier = 1
|
|
@@ -39,9 +53,14 @@ function ____exports.getCircleDiscretizedPoints(self, centerPos, radius, numPoin
|
|
|
39
53
|
end
|
|
40
54
|
return positions
|
|
41
55
|
end
|
|
56
|
+
--- Helper function to check if a given position is within a given rectangle.
|
|
57
|
+
--
|
|
58
|
+
-- This is an inclusive check, meaning that it will return true if the position is on the border of
|
|
59
|
+
-- the rectangle.
|
|
42
60
|
function ____exports.inRectangle(self, position, topLeft, bottomRight)
|
|
43
61
|
return position.X >= topLeft.X and position.X <= bottomRight.X and position.Y >= topLeft.Y and position.Y <= bottomRight.Y
|
|
44
62
|
end
|
|
63
|
+
--- From: https://www.geeksforgeeks.org/check-if-any-point-overlaps-the-given-circle-and-rectangle/
|
|
45
64
|
function ____exports.isCircleIntersectingRectangle(self, circleCenter, circleRadius, rectangleTopLeft, rectangleBottomRight)
|
|
46
65
|
local nearestX = math.max(
|
|
47
66
|
rectangleTopLeft.X,
|
|
@@ -67,6 +86,11 @@ end
|
|
|
67
86
|
function ____exports.lerpAngleDegrees(self, aStart, aEnd, percent)
|
|
68
87
|
return aStart + ____exports.getAngleDifference(nil, aStart, aEnd) * percent
|
|
69
88
|
end
|
|
89
|
+
--- If rounding fails, this function returns 0.
|
|
90
|
+
-- From: http://lua-users.org/wiki/SimpleRound
|
|
91
|
+
--
|
|
92
|
+
-- @param num The number to round.
|
|
93
|
+
-- @param numDecimalPlaces Default is 0.
|
|
70
94
|
function ____exports.round(self, num, numDecimalPlaces)
|
|
71
95
|
if numDecimalPlaces == nil then
|
|
72
96
|
numDecimalPlaces = 0
|
|
@@ -77,6 +101,8 @@ function ____exports.round(self, num, numDecimalPlaces)
|
|
|
77
101
|
))
|
|
78
102
|
return roundedNum == nil and 0 or roundedNum
|
|
79
103
|
end
|
|
104
|
+
---
|
|
105
|
+
-- @returns 1 if n is positive, -1 if n is negative, or 0 if n is 0.
|
|
80
106
|
function ____exports.sign(self, n)
|
|
81
107
|
if n > 0 then
|
|
82
108
|
return 1
|
package/functions/npc.lua
CHANGED
|
@@ -27,6 +27,8 @@ local getFilteredNewEntities = ____entity.getFilteredNewEntities
|
|
|
27
27
|
local ____entitySpecific = require("functions.entitySpecific")
|
|
28
28
|
local getNPCs = ____entitySpecific.getNPCs
|
|
29
29
|
local getProjectiles = ____entitySpecific.getProjectiles
|
|
30
|
+
--- Checks for specific NPCs that have "CanShutDoors" set to true naturally by the game, but should
|
|
31
|
+
-- not actually keep the doors closed (like Death's scythes).
|
|
30
32
|
function ____exports.isAliveExceptionNPC(self, npc)
|
|
31
33
|
local entityTypeVariant = (tostring(npc.Type) .. ".") .. tostring(npc.Variant)
|
|
32
34
|
if NON_ALIVE_NPCS_TYPE_VARIANT:has(entityTypeVariant) then
|
|
@@ -44,9 +46,16 @@ function ____exports.isAliveExceptionNPC(self, npc)
|
|
|
44
46
|
end
|
|
45
47
|
return false
|
|
46
48
|
end
|
|
49
|
+
--- Helper function to detect the custom death state of an Eggy. Eggies are never actually marked
|
|
50
|
+
-- dead by the game. Instead, when Eggies take fatal damage, they go into NpcState.STATE_SUICIDE and
|
|
51
|
+
-- spawn 14 Swarm Spiders while their StateFrame ticks upwards.
|
|
47
52
|
function ____exports.isDyingEggyWithNoSpidersLeft(self, npc)
|
|
48
53
|
return npc.State == NpcState.SUICIDE and npc.StateFrame >= EGGY_STATE_FRAME_OF_FINAL_SPIDER
|
|
49
54
|
end
|
|
55
|
+
--- Helper function to detect the custom death state of a Rag Man Ragling. When Rag Man Raglings die,
|
|
56
|
+
-- they turn into a patch on the ground and can be revived by Rag Man at a later time. This causes
|
|
57
|
+
-- them to show up as an "alive" enemy, so they should usually be filtered out of lists of alive
|
|
58
|
+
-- enemies.
|
|
50
59
|
function ____exports.isRaglingDeathPatch(self, npc)
|
|
51
60
|
return npc.Type == EntityType.RAGLING and npc.Variant == RaglingVariant.RAG_MANS_RAGLING and npc.State == NpcState.SPECIAL
|
|
52
61
|
end
|
|
@@ -73,6 +82,17 @@ NON_ALIVE_NPCS_TYPE_VARIANT_SUBTYPE = __TS__New(
|
|
|
73
82
|
(((tostring(EntityType.MOTHER) .. ".") .. tostring(MotherVariant.MOTHER_1)) .. ".") .. tostring(MotherSubType.PHASE_2)
|
|
74
83
|
}
|
|
75
84
|
)
|
|
85
|
+
--- Helper function to make an NPC fire a projectile. Returns the fired projectile. Use this function
|
|
86
|
+
-- instead of the `EntityNPC.FireProjectiles` method, since that returns void.
|
|
87
|
+
--
|
|
88
|
+
-- @param npc The NPC to fire the projectile from.
|
|
89
|
+
-- @param position The staring position of the projectile.
|
|
90
|
+
-- @param velocity The starting velocity of the projectile.
|
|
91
|
+
-- @param projectilesMode The mode of the projectile. Optional. Default is
|
|
92
|
+
-- `ProjectilesMode.ONE_PROJECTILE`.
|
|
93
|
+
-- @param projectileParams The parameters of the projectile. Optional. Default is
|
|
94
|
+
-- `ProjectileParams()`.
|
|
95
|
+
-- @returns The fired projectile.
|
|
76
96
|
function ____exports.fireProjectiles(self, npc, position, velocity, projectilesMode, projectileParams)
|
|
77
97
|
if projectilesMode == nil then
|
|
78
98
|
projectilesMode = ProjectilesMode.ONE_PROJECTILE
|
|
@@ -85,6 +105,10 @@ function ____exports.fireProjectiles(self, npc, position, velocity, projectilesM
|
|
|
85
105
|
local newProjectiles = getProjectiles(nil, projectileParams.Variant)
|
|
86
106
|
return getFilteredNewEntities(nil, oldProjectiles, newProjectiles)
|
|
87
107
|
end
|
|
108
|
+
--- Helper function to get all of the non-dead NPCs in the room.
|
|
109
|
+
--
|
|
110
|
+
-- This function will not include NPCs on an internal blacklist, such as Death's scythes or Big Horn
|
|
111
|
+
-- holes.
|
|
88
112
|
function ____exports.getAliveNPCs(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
|
|
89
113
|
if ignoreFriendly == nil then
|
|
90
114
|
ignoreFriendly = false
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
/** For PickupVariant.HEART (10) */
|
|
2
|
+
/** For `PickupVariant.HEART` (10) */
|
|
3
3
|
export declare function isHeart(pickup: EntityPickup): pickup is EntityPickupHeart;
|
|
4
|
-
/** For PickupVariant.COIN (20) */
|
|
4
|
+
/** For `PickupVariant.COIN` (20) */
|
|
5
5
|
export declare function isCoin(pickup: EntityPickup): pickup is EntityPickupCoin;
|
|
6
|
-
/** For PickupVariant.KEY (30) */
|
|
6
|
+
/** For `PickupVariant.KEY` (30) */
|
|
7
7
|
export declare function isKey(pickup: EntityPickup): pickup is EntityPickupKey;
|
|
8
|
-
/** For PickupVariant.BOMB (40) */
|
|
8
|
+
/** For `PickupVariant.BOMB` (40) */
|
|
9
9
|
export declare function isBomb(pickup: EntityPickup): pickup is EntityPickupBomb;
|
|
10
|
-
/** For PickupVariant.POOP (42) */
|
|
10
|
+
/** For `PickupVariant.POOP` (42) */
|
|
11
11
|
export declare function isPoop(pickup: EntityPickup): pickup is EntityPickupPoop;
|
|
12
|
-
/** For PickupVariant.
|
|
12
|
+
/** For `PickupVariant.SACK` (69) */
|
|
13
13
|
export declare function isSack(pickup: EntityPickup): pickup is EntityPickupSack;
|
|
14
|
-
/** For PickupVariant.PILL (70) */
|
|
14
|
+
/** For `PickupVariant.PILL` (70) */
|
|
15
15
|
export declare function isPill(pickup: EntityPickup): pickup is EntityPickupPill;
|
|
16
|
-
/** For PickupVariant.LIL_BATTERY (90) */
|
|
16
|
+
/** For `PickupVariant.LIL_BATTERY` (90) */
|
|
17
17
|
export declare function isBattery(pickup: EntityPickup): pickup is EntityPickupBattery;
|
|
18
|
-
/** For PickupVariant.COLLECTIBLE (100) */
|
|
18
|
+
/** For `PickupVariant.COLLECTIBLE` (100) */
|
|
19
19
|
export declare function isCollectible(pickup: EntityPickup): pickup is EntityPickupCollectible;
|
|
20
|
-
/** For PickupVariant.TAROT_CARD (300) */
|
|
20
|
+
/** For `PickupVariant.TAROT_CARD` (300) */
|
|
21
21
|
export declare function isCardPickup(pickup: EntityPickup): pickup is EntityPickupCard;
|
|
22
|
-
/** For PickupVariant.TRINKET (350) */
|
|
22
|
+
/** For `PickupVariant.TRINKET` (350) */
|
|
23
23
|
export declare function isTrinket(pickup: EntityPickup): pickup is EntityPickupTrinket;
|
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
3
3
|
local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
|
|
4
|
+
--- For `PickupVariant.HEART` (10)
|
|
4
5
|
function ____exports.isHeart(self, pickup)
|
|
5
6
|
return pickup.Variant == PickupVariant.HEART
|
|
6
7
|
end
|
|
8
|
+
--- For `PickupVariant.COIN` (20)
|
|
7
9
|
function ____exports.isCoin(self, pickup)
|
|
8
10
|
return pickup.Variant == PickupVariant.COIN
|
|
9
11
|
end
|
|
12
|
+
--- For `PickupVariant.KEY` (30)
|
|
10
13
|
function ____exports.isKey(self, pickup)
|
|
11
14
|
return pickup.Variant == PickupVariant.KEY
|
|
12
15
|
end
|
|
16
|
+
--- For `PickupVariant.BOMB` (40)
|
|
13
17
|
function ____exports.isBomb(self, pickup)
|
|
14
18
|
return pickup.Variant == PickupVariant.BOMB
|
|
15
19
|
end
|
|
20
|
+
--- For `PickupVariant.POOP` (42)
|
|
16
21
|
function ____exports.isPoop(self, pickup)
|
|
17
22
|
return pickup.Variant == PickupVariant.POOP
|
|
18
23
|
end
|
|
24
|
+
--- For `PickupVariant.SACK` (69)
|
|
19
25
|
function ____exports.isSack(self, pickup)
|
|
20
26
|
return pickup.Variant == PickupVariant.SACK
|
|
21
27
|
end
|
|
28
|
+
--- For `PickupVariant.PILL` (70)
|
|
22
29
|
function ____exports.isPill(self, pickup)
|
|
23
30
|
return pickup.Variant == PickupVariant.PILL
|
|
24
31
|
end
|
|
32
|
+
--- For `PickupVariant.LIL_BATTERY` (90)
|
|
25
33
|
function ____exports.isBattery(self, pickup)
|
|
26
34
|
return pickup.Variant == PickupVariant.LIL_BATTERY
|
|
27
35
|
end
|
|
36
|
+
--- For `PickupVariant.COLLECTIBLE` (100)
|
|
28
37
|
function ____exports.isCollectible(self, pickup)
|
|
29
38
|
return pickup.Variant == PickupVariant.COLLECTIBLE
|
|
30
39
|
end
|
|
40
|
+
--- For `PickupVariant.TAROT_CARD` (300)
|
|
31
41
|
function ____exports.isCardPickup(self, pickup)
|
|
32
42
|
return pickup.Variant == PickupVariant.TAROT_CARD
|
|
33
43
|
end
|
|
44
|
+
--- For `PickupVariant.TRINKET` (350)
|
|
34
45
|
function ____exports.isTrinket(self, pickup)
|
|
35
46
|
return pickup.Variant == PickupVariant.TRINKET
|
|
36
47
|
end
|
package/functions/pickups.lua
CHANGED
|
@@ -18,52 +18,62 @@ local removeAllPickups = ____entitySpecific.removeAllPickups
|
|
|
18
18
|
local spawnPickup = ____entitySpecific.spawnPickup
|
|
19
19
|
local ____pickupVariants = require("functions.pickupVariants")
|
|
20
20
|
local isHeart = ____pickupVariants.isHeart
|
|
21
|
+
--- Helper function to get all of the battery entities in the room.
|
|
21
22
|
function ____exports.getBatteries(self, matchingSubType)
|
|
22
23
|
if matchingSubType == nil then
|
|
23
24
|
matchingSubType = -1
|
|
24
25
|
end
|
|
25
26
|
return getPickups(nil, PickupVariant.LIL_BATTERY, matchingSubType)
|
|
26
27
|
end
|
|
28
|
+
--- Helper function to get all of the card entities in the room.
|
|
27
29
|
function ____exports.getCards(self, matchingSubType)
|
|
28
30
|
if matchingSubType == nil then
|
|
29
31
|
matchingSubType = -1
|
|
30
32
|
end
|
|
31
33
|
return getPickups(nil, PickupVariant.TAROT_CARD, matchingSubType)
|
|
32
34
|
end
|
|
35
|
+
--- Helper function to get the corresponding coin amount from a `CoinSubType`. Returns 1 for modded
|
|
36
|
+
-- sub-types.
|
|
33
37
|
function ____exports.getCoinValue(self, coinSubType)
|
|
34
38
|
local value = COIN_SUBTYPE_TO_VALUE[coinSubType]
|
|
35
39
|
return value == nil and DEFAULT_COIN_VALUE or value
|
|
36
40
|
end
|
|
41
|
+
--- Helper function to get all of the coin pickup entities in the room.
|
|
37
42
|
function ____exports.getCoins(self, matchingSubType)
|
|
38
43
|
if matchingSubType == nil then
|
|
39
44
|
matchingSubType = -1
|
|
40
45
|
end
|
|
41
46
|
return getPickups(nil, PickupVariant.COIN, matchingSubType)
|
|
42
47
|
end
|
|
48
|
+
--- Helper function to get all of the collectible entities in the room.
|
|
43
49
|
function ____exports.getCollectibles(self, matchingSubType)
|
|
44
50
|
if matchingSubType == nil then
|
|
45
51
|
matchingSubType = -1
|
|
46
52
|
end
|
|
47
53
|
return getPickups(nil, PickupVariant.COLLECTIBLE, matchingSubType)
|
|
48
54
|
end
|
|
55
|
+
--- Helper function to get all of the heart pickup entities in the room.
|
|
49
56
|
function ____exports.getHearts(self, matchingSubType)
|
|
50
57
|
if matchingSubType == nil then
|
|
51
58
|
matchingSubType = -1
|
|
52
59
|
end
|
|
53
60
|
return getPickups(nil, PickupVariant.HEART, matchingSubType)
|
|
54
61
|
end
|
|
62
|
+
--- Helper function to get all of the key pickup entities in the room.
|
|
55
63
|
function ____exports.getKeys(self, matchingSubType)
|
|
56
64
|
if matchingSubType == nil then
|
|
57
65
|
matchingSubType = -1
|
|
58
66
|
end
|
|
59
67
|
return getPickups(nil, PickupVariant.KEY, matchingSubType)
|
|
60
68
|
end
|
|
69
|
+
--- Helper function to get all of the pill entities in the room.
|
|
61
70
|
function ____exports.getPills(self, matchingSubType)
|
|
62
71
|
if matchingSubType == nil then
|
|
63
72
|
matchingSubType = -1
|
|
64
73
|
end
|
|
65
74
|
return getPickups(nil, PickupVariant.PILL, matchingSubType)
|
|
66
75
|
end
|
|
76
|
+
--- Helper function to get all of the red heart pickup entities in the room.
|
|
67
77
|
function ____exports.getRedHearts(self)
|
|
68
78
|
local hearts = ____exports.getHearts(nil)
|
|
69
79
|
return __TS__ArrayFilter(
|
|
@@ -71,12 +81,14 @@ function ____exports.getRedHearts(self)
|
|
|
71
81
|
function(____, heart) return RED_HEART_SUB_TYPES_SET:has(heart.SubType) end
|
|
72
82
|
)
|
|
73
83
|
end
|
|
84
|
+
--- Helper function to get all of the sack (i.e. grab bag) entities in the room.
|
|
74
85
|
function ____exports.getSacks(self, matchingSubType)
|
|
75
86
|
if matchingSubType == nil then
|
|
76
87
|
matchingSubType = -1
|
|
77
88
|
end
|
|
78
89
|
return getPickups(nil, PickupVariant.SACK, matchingSubType)
|
|
79
90
|
end
|
|
91
|
+
--- Helper function to get all of the trinket entities in the room.
|
|
80
92
|
function ____exports.getTrinkets(self, matchingSubType)
|
|
81
93
|
if matchingSubType == nil then
|
|
82
94
|
matchingSubType = -1
|
|
@@ -89,33 +101,81 @@ end
|
|
|
89
101
|
function ____exports.isRedHeart(self, pickup)
|
|
90
102
|
return isHeart(nil, pickup) and RED_HEART_SUB_TYPES_SET:has(pickup.SubType)
|
|
91
103
|
end
|
|
104
|
+
--- Helper function to remove all of the batteries in the room.
|
|
105
|
+
--
|
|
106
|
+
-- @param batterySubType Optional. If specified, will only remove cards that match this sub-type.
|
|
107
|
+
-- @param cap Optional. If specified, will only remove the given amount of cards.
|
|
108
|
+
-- @returns True if one or more cards were removed, false otherwise.
|
|
92
109
|
function ____exports.removeAllBatteries(self, batterySubType, cap)
|
|
93
110
|
return removeAllPickups(nil, PickupVariant.LIL_BATTERY, batterySubType, cap)
|
|
94
111
|
end
|
|
112
|
+
--- Helper function to remove all of the cards in the room.
|
|
113
|
+
--
|
|
114
|
+
-- @param card Optional. If specified, will only remove cards that match this sub-type.
|
|
115
|
+
-- @param cap Optional. If specified, will only remove the given amount of cards.
|
|
116
|
+
-- @returns True if one or more cards were removed, false otherwise.
|
|
95
117
|
function ____exports.removeAllCards(self, card, cap)
|
|
96
118
|
return removeAllPickups(nil, PickupVariant.TAROT_CARD, card, cap)
|
|
97
119
|
end
|
|
120
|
+
--- Helper function to remove all of the coins in the room.
|
|
121
|
+
--
|
|
122
|
+
-- @param coinSubType Optional. If specified, will only remove coins that match this sub-type.
|
|
123
|
+
-- @param cap Optional. If specified, will only remove the given amount of coins.
|
|
124
|
+
-- @returns True if one or more coins were removed, false otherwise.
|
|
98
125
|
function ____exports.removeAllCoins(self, coinSubType, cap)
|
|
99
126
|
return removeAllPickups(nil, PickupVariant.COIN, coinSubType, cap)
|
|
100
127
|
end
|
|
128
|
+
--- Helper function to remove all of the collectibles in the room.
|
|
129
|
+
--
|
|
130
|
+
-- @param collectibleType Optional. If specified, will only remove collectibles that match this
|
|
131
|
+
-- collectible type.
|
|
132
|
+
-- @param cap Optional. If specified, will only remove the given amount of collectibles.
|
|
133
|
+
-- @returns True if one or more collectibles were removed, false otherwise.
|
|
101
134
|
function ____exports.removeAllCollectibles(self, collectibleType, cap)
|
|
102
135
|
return removeAllPickups(nil, PickupVariant.COLLECTIBLE, collectibleType, cap)
|
|
103
136
|
end
|
|
137
|
+
--- Helper function to remove all of the hearts in the room.
|
|
138
|
+
--
|
|
139
|
+
-- @param heartSubType Optional. If specified, will only remove hearts that match this sub-type.
|
|
140
|
+
-- @param cap Optional. If specified, will only remove the given amount of hearts.
|
|
141
|
+
-- @returns True if one or more hearts were removed, false otherwise.
|
|
104
142
|
function ____exports.removeAllHearts(self, heartSubType, cap)
|
|
105
143
|
return removeAllPickups(nil, PickupVariant.HEART, heartSubType, cap)
|
|
106
144
|
end
|
|
145
|
+
--- Helper function to remove all of the keys in the room.
|
|
146
|
+
--
|
|
147
|
+
-- @param keySubType Optional. If specified, will only remove keys that match this sub-type.
|
|
148
|
+
-- @param cap Optional. If specified, will only remove the given amount of keys.
|
|
149
|
+
-- @returns True if one or more keys were removed, false otherwise.
|
|
107
150
|
function ____exports.removeAllKeys(self, keySubType, cap)
|
|
108
151
|
return removeAllPickups(nil, PickupVariant.KEY, keySubType, cap)
|
|
109
152
|
end
|
|
153
|
+
--- Helper function to remove all of the pills in the room.
|
|
154
|
+
--
|
|
155
|
+
-- @param pillColor Optional. If specified, will only remove pills that match this color.
|
|
156
|
+
-- @param cap Optional. If specified, will only remove the given amount of pills.
|
|
157
|
+
-- @returns True if one or more pills were removed, false otherwise.
|
|
110
158
|
function ____exports.removeAllPills(self, pillColor, cap)
|
|
111
159
|
return removeAllPickups(nil, PickupVariant.PILL, pillColor, cap)
|
|
112
160
|
end
|
|
161
|
+
--- Helper function to remove all of the sacks (i.e. grab bags) in the room.
|
|
162
|
+
--
|
|
163
|
+
-- @param sackSubType Optional. If specified, will only remove sacks that match this sub-type.
|
|
164
|
+
-- @param cap Optional. If specified, will only remove the given amount of trinkets.
|
|
165
|
+
-- @returns True if one or more trinkets were removed, false otherwise.
|
|
113
166
|
function ____exports.removeAllSacks(self, sackSubType, cap)
|
|
114
167
|
return removeAllPickups(nil, PickupVariant.TRINKET, sackSubType, cap)
|
|
115
168
|
end
|
|
169
|
+
--- Helper function to remove all of the trinkets in the room.
|
|
170
|
+
--
|
|
171
|
+
-- @param trinketType Optional. If specified, will only remove trinkets that match this trinket
|
|
172
|
+
-- type.
|
|
173
|
+
-- @param cap Optional. If specified, will only remove the given amount of trinkets.
|
|
174
|
+
-- @returns True if one or more trinkets were removed, false otherwise.
|
|
116
175
|
function ____exports.removeAllTrinkets(self, trinketType, cap)
|
|
117
176
|
return removeAllPickups(nil, PickupVariant.TRINKET, trinketType, cap)
|
|
118
177
|
end
|
|
178
|
+
--- Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.LIL_BATTERY` (90).
|
|
119
179
|
function ____exports.spawnBattery(self, subType, position, velocity, spawner, seed)
|
|
120
180
|
if velocity == nil then
|
|
121
181
|
velocity = VectorZero
|
|
@@ -152,6 +212,7 @@ function ____exports.spawnBatteryWithSeed(self, subType, position, seed, velocit
|
|
|
152
212
|
seed
|
|
153
213
|
)
|
|
154
214
|
end
|
|
215
|
+
--- Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TAROT_CARD` (300).
|
|
155
216
|
function ____exports.spawnCard(self, subType, position, velocity, spawner, seed)
|
|
156
217
|
if velocity == nil then
|
|
157
218
|
velocity = VectorZero
|
|
@@ -188,6 +249,7 @@ function ____exports.spawnCardWithSeed(self, subType, position, seed, velocity,
|
|
|
188
249
|
seed
|
|
189
250
|
)
|
|
190
251
|
end
|
|
252
|
+
--- Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.COIN` (20).
|
|
191
253
|
function ____exports.spawnCoin(self, subType, position, velocity, spawner, seed)
|
|
192
254
|
if velocity == nil then
|
|
193
255
|
velocity = VectorZero
|
|
@@ -224,6 +286,7 @@ function ____exports.spawnCoinWithSeed(self, subType, position, seed, velocity,
|
|
|
224
286
|
seed
|
|
225
287
|
)
|
|
226
288
|
end
|
|
289
|
+
--- Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.HEART` (10).
|
|
227
290
|
function ____exports.spawnHeart(self, subType, position, velocity, spawner, seed)
|
|
228
291
|
if velocity == nil then
|
|
229
292
|
velocity = VectorZero
|
|
@@ -260,6 +323,7 @@ function ____exports.spawnHeartWithSeed(self, subType, position, seed, velocity,
|
|
|
260
323
|
seed
|
|
261
324
|
)
|
|
262
325
|
end
|
|
326
|
+
--- Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.KEY` (30).
|
|
263
327
|
function ____exports.spawnKey(self, subType, position, velocity, spawner, seed)
|
|
264
328
|
if velocity == nil then
|
|
265
329
|
velocity = VectorZero
|
|
@@ -296,6 +360,7 @@ function ____exports.spawnKeyWithSeed(self, subType, position, seed, velocity, s
|
|
|
296
360
|
seed
|
|
297
361
|
)
|
|
298
362
|
end
|
|
363
|
+
--- Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.PILL` (70).
|
|
299
364
|
function ____exports.spawnPill(self, pillColor, position, velocity, spawner, seed)
|
|
300
365
|
if velocity == nil then
|
|
301
366
|
velocity = VectorZero
|
|
@@ -332,6 +397,7 @@ function ____exports.spawnPillWithSeed(self, subType, position, seed, velocity,
|
|
|
332
397
|
seed
|
|
333
398
|
)
|
|
334
399
|
end
|
|
400
|
+
--- Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.SACK` (69).
|
|
335
401
|
function ____exports.spawnSack(self, subType, position, velocity, spawner, seed)
|
|
336
402
|
if velocity == nil then
|
|
337
403
|
velocity = VectorZero
|
|
@@ -368,6 +434,7 @@ function ____exports.spawnSackWithSeed(self, subType, position, seed, velocity,
|
|
|
368
434
|
seed
|
|
369
435
|
)
|
|
370
436
|
end
|
|
437
|
+
--- Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TRINKET` (350).
|
|
371
438
|
function ____exports.spawnTrinket(self, subType, position, velocity, spawner, seed)
|
|
372
439
|
if velocity == nil then
|
|
373
440
|
velocity = VectorZero
|