isaacscript-common 80.2.2 → 80.2.3

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.
Files changed (65) hide show
  1. package/dist/classes/ModUpgraded.d.ts.map +1 -1
  2. package/dist/classes/ModUpgraded.lua +18 -8
  3. package/dist/classes/features/other/DeployJSONRoom.lua +11 -10
  4. package/dist/classes/features/other/extraConsoleCommands/commands.d.ts +1 -1
  5. package/dist/classes/features/other/extraConsoleCommands/commands.d.ts.map +1 -1
  6. package/dist/classes/features/other/extraConsoleCommands/commands.lua +104 -102
  7. package/dist/classes/features/other/extraConsoleCommands/subroutines.d.ts.map +1 -1
  8. package/dist/classes/features/other/extraConsoleCommands/subroutines.lua +6 -4
  9. package/dist/core/constantsFirstLast.d.ts +4 -26
  10. package/dist/core/constantsFirstLast.d.ts.map +1 -1
  11. package/dist/core/constantsFirstLast.lua +0 -18
  12. package/dist/functions/cards.d.ts +1 -0
  13. package/dist/functions/cards.d.ts.map +1 -1
  14. package/dist/functions/cards.lua +7 -0
  15. package/dist/functions/collectibles.d.ts +1 -1
  16. package/dist/functions/collectibles.d.ts.map +1 -1
  17. package/dist/functions/collectibles.lua +3 -1
  18. package/dist/functions/doors.d.ts.map +1 -1
  19. package/dist/functions/doors.lua +14 -4
  20. package/dist/functions/entities.d.ts.map +1 -1
  21. package/dist/functions/entities.lua +19 -30
  22. package/dist/functions/gridEntities.d.ts.map +1 -1
  23. package/dist/functions/gridEntities.lua +8 -13
  24. package/dist/functions/jsonRoom.d.ts.map +1 -1
  25. package/dist/functions/jsonRoom.lua +13 -5
  26. package/dist/functions/pills.d.ts +1 -0
  27. package/dist/functions/pills.d.ts.map +1 -1
  28. package/dist/functions/pills.lua +6 -0
  29. package/dist/functions/run.d.ts +1 -2
  30. package/dist/functions/run.d.ts.map +1 -1
  31. package/dist/functions/run.lua +2 -3
  32. package/dist/functions/string.d.ts.map +1 -1
  33. package/dist/functions/string.lua +5 -3
  34. package/dist/functions/table.d.ts +3 -2
  35. package/dist/functions/table.d.ts.map +1 -1
  36. package/dist/functions/table.lua +3 -2
  37. package/dist/functions/trinkets.d.ts +1 -0
  38. package/dist/functions/trinkets.d.ts.map +1 -1
  39. package/dist/functions/trinkets.lua +6 -0
  40. package/dist/functions/types.d.ts +9 -0
  41. package/dist/functions/types.d.ts.map +1 -1
  42. package/dist/functions/types.lua +17 -0
  43. package/dist/index.rollup.d.ts +23 -32
  44. package/dist/isaacscript-common.lua +252 -207
  45. package/dist/lualib_bundle.lua +5 -0
  46. package/dist/objects/itemPoolTypeToCollectibleTypesSet.lua +4 -3
  47. package/package.json +2 -2
  48. package/src/classes/ModUpgraded.ts +18 -4
  49. package/src/classes/features/other/DeployJSONRoom.ts +11 -11
  50. package/src/classes/features/other/extraConsoleCommands/commands.ts +124 -118
  51. package/src/classes/features/other/extraConsoleCommands/subroutines.ts +5 -4
  52. package/src/core/constantsFirstLast.ts +3 -37
  53. package/src/functions/cards.ts +7 -0
  54. package/src/functions/collectibles.ts +5 -4
  55. package/src/functions/doors.ts +8 -3
  56. package/src/functions/entities.ts +40 -19
  57. package/src/functions/gridEntities.ts +15 -5
  58. package/src/functions/jsonRoom.ts +18 -5
  59. package/src/functions/pills.ts +7 -1
  60. package/src/functions/run.ts +6 -4
  61. package/src/functions/string.ts +4 -3
  62. package/src/functions/table.ts +3 -2
  63. package/src/functions/trinkets.ts +9 -1
  64. package/src/functions/types.ts +25 -0
  65. package/src/objects/itemPoolTypeToCollectibleTypesSet.ts +4 -4
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 80.2.1
3
+ isaacscript-common 80.2.2
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -1518,6 +1518,10 @@ local function __TS__NumberIsFinite(value)
1518
1518
  return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
1519
1519
  end
1520
1520
 
1521
+ local function __TS__NumberIsInteger(value)
1522
+ return __TS__NumberIsFinite(value) and math.floor(value) == value
1523
+ end
1524
+
1521
1525
  local function __TS__NumberIsNaN(value)
1522
1526
  return value ~= value
1523
1527
  end
@@ -2619,6 +2623,7 @@ return {
2619
2623
  __TS__New = __TS__New,
2620
2624
  __TS__Number = __TS__Number,
2621
2625
  __TS__NumberIsFinite = __TS__NumberIsFinite,
2626
+ __TS__NumberIsInteger = __TS__NumberIsInteger,
2622
2627
  __TS__NumberIsNaN = __TS__NumberIsNaN,
2623
2628
  __TS__ParseInt = __TS__ParseInt,
2624
2629
  __TS__ParseFloat = __TS__ParseFloat,
@@ -17147,6 +17152,23 @@ end
17147
17152
  function ____exports.isUserdata(self, variable)
17148
17153
  return type(variable) == "userdata"
17149
17154
  end
17155
+ --- Helper function to convert a string to an integer. Returns undefined if the string is not an
17156
+ -- integer.
17157
+ --
17158
+ -- Under the hood, this uses the built-in `tonumber` and `math.floor` functions.
17159
+ --
17160
+ -- This is named `parseIntSafe` in order to match the helper function in `isaacscript-common-ts`.
17161
+ function ____exports.parseIntSafe(self, ____string)
17162
+ if not ____exports.isString(nil, ____string) then
17163
+ return nil
17164
+ end
17165
+ local number = tonumber(____string)
17166
+ if number == nil then
17167
+ return nil
17168
+ end
17169
+ local flooredNumber = math.floor(number)
17170
+ return number == flooredNumber and flooredNumber or nil
17171
+ end
17150
17172
  return ____exports
17151
17173
  end,
17152
17174
  ["functions.sort"] = function(...)
@@ -17936,6 +17958,8 @@ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
17936
17958
  local __TS__StringSlice = ____lualib.__TS__StringSlice
17937
17959
  local __TS__StringEndsWith = ____lualib.__TS__StringEndsWith
17938
17960
  local ____exports = {}
17961
+ local ____types = require("functions.types")
17962
+ local parseIntSafe = ____types.parseIntSafe
17939
17963
  local ____utils = require("functions.utils")
17940
17964
  local assertDefined = ____utils.assertDefined
17941
17965
  --- Helper function to get the closest value from an array of strings based on partial search text.
@@ -18049,9 +18073,9 @@ function ____exports.parseSemanticVersion(self, versionString)
18049
18073
  if majorVersionString == nil or minorVersionString == nil or patchVersionString == nil then
18050
18074
  return nil
18051
18075
  end
18052
- local majorVersion = tonumber(majorVersionString)
18053
- local minorVersion = tonumber(minorVersionString)
18054
- local patchVersion = tonumber(patchVersionString)
18076
+ local majorVersion = parseIntSafe(nil, majorVersionString)
18077
+ local minorVersion = parseIntSafe(nil, minorVersionString)
18078
+ local patchVersion = parseIntSafe(nil, patchVersionString)
18055
18079
  if majorVersion == nil or minorVersion == nil or patchVersion == nil then
18056
18080
  return nil
18057
18081
  end
@@ -18292,8 +18316,9 @@ function ____exports.getBooleansFromTable(self, luaMap, objectName, ...)
18292
18316
  end
18293
18317
  return booleans
18294
18318
  end
18295
- --- Helper function to safely get number values from specific keys on a Lua table. Will throw an
18296
- -- error if the specific value does not exist on the table or if it cannot be converted to a number.
18319
+ --- Helper function to safely get number values from specific keys on a Lua table. If the values are
18320
+ -- strings, they will be converted to numbers. Will throw an error if the specific value does not
18321
+ -- exist on the table or if it cannot be converted to a number.
18297
18322
  --
18298
18323
  -- This function is variadic, meaning that you can specify N arguments to get N values.
18299
18324
  function ____exports.getNumbersFromTable(self, luaMap, objectName, ...)
@@ -20107,11 +20132,9 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescri
20107
20132
  local CardType = ____isaac_2Dtypescript_2Ddefinitions.CardType
20108
20133
  local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
20109
20134
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
20110
- local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
20111
20135
  local PillColor = ____isaac_2Dtypescript_2Ddefinitions.PillColor
20112
20136
  local PillEffect = ____isaac_2Dtypescript_2Ddefinitions.PillEffect
20113
20137
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
20114
- local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
20115
20138
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
20116
20139
  local ____enums = require("functions.enums")
20117
20140
  local getEnumLength = ____enums.getEnumLength
@@ -20139,20 +20162,12 @@ ____exports.NUM_VANILLA_TRINKET_TYPES = getEnumLength(nil, TrinketType) - 1
20139
20162
  --- Equal to `Card.FOOL`.
20140
20163
  ____exports.FIRST_CARD_TYPE = CardType.FOOL
20141
20164
  --- Calculated from the `CardType` enum.
20142
- --
20143
- -- Note that this could be calculated from the length of the enum, because card types are
20144
- -- contiguous. However, we instead get the highest enum value to be safer and to make the code more
20145
- -- consistent with collectibles and trinkets.
20146
20165
  ____exports.LAST_VANILLA_CARD_TYPE = getHighestEnumValue(nil, CardType)
20147
20166
  --- Calculated from the `Card` enum. `Card.NULL` is not included.
20148
20167
  ____exports.NUM_VANILLA_CARD_TYPES = getEnumLength(nil, CardType) - 1
20149
20168
  --- Equal to `PillEffect.BAD_GAS`.
20150
20169
  ____exports.FIRST_PILL_EFFECT = PillEffect.BAD_GAS
20151
20170
  --- Calculated from the `PillEffect` enum.
20152
- --
20153
- -- Note that this could be calculated from the length of the enum, because pill effects are
20154
- -- contiguous. However, we instead get the highest enum value to be safer and to make the code more
20155
- -- consistent with collectibles and trinkets.
20156
20171
  ____exports.LAST_VANILLA_PILL_EFFECT = getHighestEnumValue(nil, PillEffect)
20157
20172
  --- Calculated from the `PillEffect` enum. (There is no `PillEffect.NULL` in the custom enum, so we
20158
20173
  -- do not have to subtract one here.)
@@ -20175,15 +20190,7 @@ ____exports.NUM_NORMAL_PILL_COLORS = #iRange(nil, ____exports.FIRST_PILL_COLOR,
20175
20190
  --- Equal to `PlayerType.ISAAC`.
20176
20191
  ____exports.FIRST_CHARACTER = PlayerType.ISAAC
20177
20192
  --- Calculated from the `PlayerType` enum.
20178
- --
20179
- -- Note that this could be calculated from the length of the enum, because characters are
20180
- -- contiguous. However, we instead get the highest enum value to be safer and to make the code more
20181
- -- consistent with collectibles and trinkets.
20182
20193
  ____exports.LAST_VANILLA_CHARACTER = getHighestEnumValue(nil, PlayerType)
20183
- ____exports.FIRST_ROOM_TYPE = RoomType.DEFAULT
20184
- ____exports.LAST_ROOM_TYPE = getHighestEnumValue(nil, RoomType)
20185
- ____exports.FIRST_STAGE = LevelStage.BASEMENT_1
20186
- ____exports.LAST_STAGE = getHighestEnumValue(nil, LevelStage)
20187
20194
  --- Calculated from the `Challenge` enum. `Challenge.NULL` is not included.
20188
20195
  ____exports.NUM_VANILLA_CHALLENGES = getEnumLength(nil, Challenge) - 1
20189
20196
  return ____exports
@@ -23574,10 +23581,14 @@ local ____bitwise = require("functions.bitwise")
23574
23581
  local arrayToBitFlags = ____bitwise.arrayToBitFlags
23575
23582
  local ____direction = require("functions.direction")
23576
23583
  local directionToVector = ____direction.directionToVector
23584
+ local ____enums = require("functions.enums")
23585
+ local isEnumValue = ____enums.isEnumValue
23577
23586
  local ____flag = require("functions.flag")
23578
23587
  local hasFlag = ____flag.hasFlag
23579
23588
  local ____tstlClass = require("functions.tstlClass")
23580
23589
  local isTSTLSet = ____tstlClass.isTSTLSet
23590
+ local ____types = require("functions.types")
23591
+ local parseIntSafe = ____types.parseIntSafe
23581
23592
  function ____exports.doorSlotToDirection(self, doorSlot)
23582
23593
  return DOOR_SLOT_TO_DIRECTION[doorSlot]
23583
23594
  end
@@ -23836,11 +23847,17 @@ function ____exports.getRoomShapeDoorSlot(self, roomShape, x, y)
23836
23847
  for ____, ____value in ipairs(__TS__ObjectEntries(doorSlotCoordinates)) do
23837
23848
  local doorSlotString = ____value[1]
23838
23849
  local coordinates = ____value[2]
23839
- local doorSlot = tonumber(doorSlotString)
23840
- local doorX, doorY = table.unpack(coordinates)
23841
- if x == doorX and y == doorY then
23842
- return doorSlot
23850
+ do
23851
+ local doorSlot = parseIntSafe(nil, doorSlotString)
23852
+ if doorSlot == nil or not isEnumValue(nil, doorSlot, DoorSlot) then
23853
+ goto __continue40
23854
+ end
23855
+ local doorX, doorY = table.unpack(coordinates)
23856
+ if x == doorX and y == doorY then
23857
+ return doorSlot
23858
+ end
23843
23859
  end
23860
+ ::__continue40::
23844
23861
  end
23845
23862
  return nil
23846
23863
  end
@@ -26788,6 +26805,7 @@ local isTSTLSet = ____tstlClass.isTSTLSet
26788
26805
  local ____types = require("functions.types")
26789
26806
  local asNPCState = ____types.asNPCState
26790
26807
  local isPrimitive = ____types.isPrimitive
26808
+ local parseIntSafe = ____types.parseIntSafe
26791
26809
  local ____utils = require("functions.utils")
26792
26810
  local assertDefined = ____utils.assertDefined
26793
26811
  local ____vector = require("functions.vector")
@@ -26967,24 +26985,15 @@ function ____exports.getConstituentsFromEntityID(self, entityID)
26967
26985
  error("Failed to get the constituents from entity ID: " .. entityID)
26968
26986
  end
26969
26987
  local entityTypeString, variantString, subTypeString = table.unpack(parts)
26970
- local entityType = tonumber(entityTypeString)
26971
- assertDefined(
26972
- nil,
26973
- entityType,
26974
- "Failed to convert the entity type to a number: " .. tostring(entityTypeString)
26975
- )
26976
- local variant = tonumber(variantString)
26977
- assertDefined(
26978
- nil,
26979
- variant,
26980
- "Failed to convert the entity variant to a number: " .. tostring(variantString)
26981
- )
26982
- local subType = tonumber(subTypeString)
26983
- assertDefined(
26984
- nil,
26985
- subType,
26986
- "Failed to convert the entity sub-type to a number: " .. tostring(subTypeString)
26987
- )
26988
+ assertDefined(nil, entityTypeString, "Failed to get the first constituent from an entity ID: " .. entityID)
26989
+ assertDefined(nil, variantString, "Failed to get the second constituent from an entity ID: " .. entityID)
26990
+ assertDefined(nil, subTypeString, "Failed to get the third constituent from an entity ID: " .. entityID)
26991
+ local entityType = parseIntSafe(nil, entityTypeString)
26992
+ assertDefined(nil, entityType, "Failed to convert the entity type to an integer: " .. entityTypeString)
26993
+ local variant = parseIntSafe(nil, variantString)
26994
+ assertDefined(nil, variant, "Failed to convert the entity variant to an integer: " .. variantString)
26995
+ local subType = parseIntSafe(nil, subTypeString)
26996
+ assertDefined(nil, subType, "Failed to convert the entity sub-type to an integer: " .. subTypeString)
26988
26997
  return {entityType, variant, subType}
26989
26998
  end
26990
26999
  --- Helper function to get all of the entities in the room or all of the entities that match a
@@ -27193,16 +27202,13 @@ function ____exports.parseEntityID(self, entityID)
27193
27202
  return nil
27194
27203
  end
27195
27204
  local entityTypeString, variantString, subTypeString = table.unpack(entityIDArray)
27196
- local entityType = tonumber(entityTypeString)
27197
- if entityType == nil then
27198
- return nil
27199
- end
27200
- local variant = tonumber(variantString)
27201
- if variant == nil then
27205
+ if entityTypeString == nil or variantString == nil or subTypeString == nil then
27202
27206
  return nil
27203
27207
  end
27204
- local subType = tonumber(subTypeString)
27205
- if subType == nil then
27208
+ local entityType = parseIntSafe(nil, entityTypeString)
27209
+ local variant = parseIntSafe(nil, variantString)
27210
+ local subType = parseIntSafe(nil, subTypeString)
27211
+ if entityType == nil or variant == nil or subType == nil then
27206
27212
  return nil
27207
27213
  end
27208
27214
  return {entityType, variant, subType}
@@ -27219,12 +27225,12 @@ function ____exports.parseEntityTypeVariantString(self, entityTypeVariantString)
27219
27225
  return nil
27220
27226
  end
27221
27227
  local entityTypeString, variantString = table.unpack(entityTypeVariantArray)
27222
- local entityType = tonumber(entityTypeString)
27223
- if entityType == nil then
27228
+ if entityTypeString == nil or variantString == nil then
27224
27229
  return nil
27225
27230
  end
27226
- local variant = tonumber(variantString)
27227
- if variant == nil then
27231
+ local entityType = parseIntSafe(nil, entityTypeString)
27232
+ local variant = parseIntSafe(nil, variantString)
27233
+ if entityType == nil or variant == nil then
27228
27234
  return nil
27229
27235
  end
27230
27236
  return {entityType, variant}
@@ -27481,6 +27487,7 @@ local ____sprites = require("functions.sprites")
27481
27487
  local clearSprite = ____sprites.clearSprite
27482
27488
  local spriteEquals = ____sprites.spriteEquals
27483
27489
  local ____types = require("functions.types")
27490
+ local asCollectibleType = ____types.asCollectibleType
27484
27491
  local isInteger = ____types.isInteger
27485
27492
  local ____utils = require("functions.utils")
27486
27493
  local assertDefined = ____utils.assertDefined
@@ -27858,7 +27865,8 @@ function ____exports.isSingleUseCollectible(self, collectibleType)
27858
27865
  return SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES_SET:has(collectibleType)
27859
27866
  end
27860
27867
  function ____exports.isValidCollectibleType(self, collectibleType)
27861
- local itemConfigItem = itemConfig:GetCollectible(collectibleType)
27868
+ local potentialCollectibleType = asCollectibleType(nil, collectibleType)
27869
+ local itemConfigItem = itemConfig:GetCollectible(potentialCollectibleType)
27862
27870
  return itemConfigItem ~= nil
27863
27871
  end
27864
27872
  --- Helper function to generate a new sprite based on a collectible. If the provided collectible type
@@ -33166,6 +33174,7 @@ local ____rooms = require("functions.rooms")
33166
33174
  local roomUpdateSafe = ____rooms.roomUpdateSafe
33167
33175
  local ____types = require("functions.types")
33168
33176
  local isInteger = ____types.isInteger
33177
+ local parseIntSafe = ____types.parseIntSafe
33169
33178
  local ____utils = require("functions.utils")
33170
33179
  local assertDefined = ____utils.assertDefined
33171
33180
  local eRange = ____utils.eRange
@@ -33668,21 +33677,15 @@ end
33668
33677
  function ____exports.getConstituentsFromGridEntityID(self, gridEntityID)
33669
33678
  local parts = __TS__StringSplit(gridEntityID, ".")
33670
33679
  if #parts ~= 2 then
33671
- error("Failed to get the constituents from grid entity ID: " .. gridEntityID)
33680
+ error("Failed to get the constituents from a grid entity ID: " .. gridEntityID)
33672
33681
  end
33673
33682
  local gridEntityTypeString, variantString = table.unpack(parts)
33674
- local gridEntityType = tonumber(gridEntityTypeString)
33675
- assertDefined(
33676
- nil,
33677
- gridEntityType,
33678
- "Failed to convert the grid entity type to a number: " .. tostring(gridEntityTypeString)
33679
- )
33680
- local variant = tonumber(variantString)
33681
- assertDefined(
33682
- nil,
33683
- variant,
33684
- "Failed to convert the grid entity variant to a number: " .. tostring(variantString)
33685
- )
33683
+ assertDefined(nil, gridEntityTypeString, "Failed to get the first constituent from a grid entity ID: " .. gridEntityID)
33684
+ assertDefined(nil, variantString, "Failed to get the second constituent from a grid entity ID: " .. gridEntityID)
33685
+ local gridEntityType = parseIntSafe(nil, gridEntityTypeString)
33686
+ assertDefined(nil, gridEntityType, "Failed to convert the grid entity type to a number: " .. gridEntityTypeString)
33687
+ local variant = parseIntSafe(nil, variantString)
33688
+ assertDefined(nil, variant, "Failed to convert the grid entity variant to an integer: " .. variantString)
33686
33689
  return {gridEntityType, variant}
33687
33690
  end
33688
33691
  --- Helper function to get every grid entity in the current room.
@@ -36561,6 +36564,7 @@ local ____sprites = require("functions.sprites")
36561
36564
  local clearSprite = ____sprites.clearSprite
36562
36565
  local ____types = require("functions.types")
36563
36566
  local asNumber = ____types.asNumber
36567
+ local asTrinketType = ____types.asTrinketType
36564
36568
  function ____exports.isGoldenTrinketType(self, trinketType)
36565
36569
  return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
36566
36570
  end
@@ -36663,6 +36667,11 @@ end
36663
36667
  function ____exports.isModdedTrinketType(self, trinketType)
36664
36668
  return not ____exports.isVanillaTrinketType(nil, trinketType)
36665
36669
  end
36670
+ function ____exports.isValidTrinketType(self, trinketType)
36671
+ local potentialTrinketType = asTrinketType(nil, trinketType)
36672
+ local itemConfigItem = itemConfig:GetTrinket(potentialTrinketType)
36673
+ return itemConfigItem ~= nil
36674
+ end
36666
36675
  --- Helper function to generate a new sprite based on a collectible. If the provided collectible type
36667
36676
  -- is invalid, a sprite with a Curse of the Blind question mark will be returned.
36668
36677
  function ____exports.newTrinketSprite(self, trinketType)
@@ -38591,6 +38600,7 @@ local PILL_EFFECT_TYPES = ____pillEffectTypes.PILL_EFFECT_TYPES
38591
38600
  local ____types = require("functions.types")
38592
38601
  local asNumber = ____types.asNumber
38593
38602
  local asPillColor = ____types.asPillColor
38603
+ local asPillEffect = ____types.asPillEffect
38594
38604
  local ____utils = require("functions.utils")
38595
38605
  local iRange = ____utils.iRange
38596
38606
  --- Helper function to see if the given pill color is a horse pill.
@@ -38713,6 +38723,11 @@ end
38713
38723
  function ____exports.isModdedPillEffect(self, pillEffect)
38714
38724
  return not ____exports.isVanillaPillEffect(nil, pillEffect)
38715
38725
  end
38726
+ function ____exports.isValidPillEffect(self, pillEffect)
38727
+ local potentialPillEffect = asPillEffect(nil, pillEffect)
38728
+ local itemConfigPillEffect = itemConfig:GetPillEffect(potentialPillEffect)
38729
+ return itemConfigPillEffect ~= nil
38730
+ end
38716
38731
  return ____exports
38717
38732
  end,
38718
38733
  ["interfaces.PocketItemDescription"] = function(...)
@@ -40244,13 +40259,12 @@ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
40244
40259
  local ____exports = {}
40245
40260
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.index")
40246
40261
  local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
40262
+ local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
40247
40263
  local SeedEffect = ____isaac_2Dtypescript_2Ddefinitions.SeedEffect
40248
40264
  local ____cachedEnumValues = require("arrays.cachedEnumValues")
40249
40265
  local SEED_EFFECTS = ____cachedEnumValues.SEED_EFFECTS
40250
40266
  local ____cachedClasses = require("core.cachedClasses")
40251
40267
  local game = ____cachedClasses.game
40252
- local ____constantsFirstLast = require("core.constantsFirstLast")
40253
- local FIRST_CHARACTER = ____constantsFirstLast.FIRST_CHARACTER
40254
40268
  local ____characters = require("functions.characters")
40255
40269
  local getCharacterName = ____characters.getCharacterName
40256
40270
  local ____log = require("functions.log")
@@ -40314,7 +40328,7 @@ function ____exports.restart(self, character)
40314
40328
  Isaac.ExecuteCommand(command)
40315
40329
  return
40316
40330
  end
40317
- if character < FIRST_CHARACTER then
40331
+ if character < PlayerType.ISAAC then
40318
40332
  error(("Restarting as a character of " .. tostring(character)) .. " would crash the game.")
40319
40333
  end
40320
40334
  local command = "restart " .. tostring(character)
@@ -44095,6 +44109,8 @@ local ____itemConfigCardTypesForCards = require("sets.itemConfigCardTypesForCard
44095
44109
  local ITEM_CONFIG_CARD_TYPES_FOR_CARDS = ____itemConfigCardTypesForCards.ITEM_CONFIG_CARD_TYPES_FOR_CARDS
44096
44110
  local ____flag = require("functions.flag")
44097
44111
  local addFlag = ____flag.addFlag
44112
+ local ____types = require("functions.types")
44113
+ local asCardType = ____types.asCardType
44098
44114
  function ____exports.isVanillaCardType(self, cardType)
44099
44115
  return cardType <= LAST_VANILLA_CARD_TYPE
44100
44116
  end
@@ -44204,6 +44220,11 @@ end
44204
44220
  function ____exports.isTarotCard(self, cardType)
44205
44221
  return ____exports.isCardType(nil, cardType, ItemConfigCardType.TAROT)
44206
44222
  end
44223
+ function ____exports.isValidCardType(self, cardType)
44224
+ local potentialCardType = asCardType(nil, cardType)
44225
+ local itemConfigCard = itemConfig:GetCard(potentialCardType)
44226
+ return itemConfigCard ~= nil
44227
+ end
44207
44228
  --- Helper function to use a card without showing an animation and without the announcer voice
44208
44229
  -- playing.
44209
44230
  function ____exports.useCardTemp(self, player, cardType)
@@ -53967,6 +53988,8 @@ local ____log = require("functions.log")
53967
53988
  local log = ____log.log
53968
53989
  local ____random = require("functions.random")
53969
53990
  local getRandomFloat = ____random.getRandomFloat
53991
+ local ____types = require("functions.types")
53992
+ local parseIntSafe = ____types.parseIntSafe
53970
53993
  local ____utils = require("functions.utils")
53971
53994
  local assertDefined = ____utils.assertDefined
53972
53995
  function getTotalWeightOfJSONObject(self, jsonOjectArray)
@@ -54008,7 +54031,7 @@ end
54008
54031
  -- (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
54009
54032
  function ____exports.getJSONRoomDoorSlotFlags(self, jsonRoom)
54010
54033
  local roomShapeString = jsonRoom["$"].shape
54011
- local roomShape = tonumber(roomShapeString)
54034
+ local roomShape = parseIntSafe(nil, roomShapeString)
54012
54035
  assertDefined(nil, roomShape, "Failed to parse the \"shape\" field of a JSON room: " .. roomShapeString)
54013
54036
  if not isEnumValue(nil, roomShape, RoomShape) then
54014
54037
  error("Failed to parse the \"shape\" field of a JSON room since it was an invalid number: " .. tostring(roomShape))
@@ -54024,10 +54047,10 @@ function ____exports.getJSONRoomDoorSlotFlags(self, jsonRoom)
54024
54047
  goto __continue4
54025
54048
  end
54026
54049
  local xString = door["$"].x
54027
- local x = tonumber(xString)
54050
+ local x = parseIntSafe(nil, xString)
54028
54051
  assertDefined(nil, x, "Failed to parse the \"x\" field of a JSON room door: " .. xString)
54029
54052
  local yString = door["$"].y
54030
- local y = tonumber(yString)
54053
+ local y = parseIntSafe(nil, yString)
54031
54054
  assertDefined(nil, y, "Failed to parse the \"y\" field of a JSON room door: " .. yString)
54032
54055
  local doorSlot = getRoomShapeDoorSlot(nil, roomShape, x, y)
54033
54056
  assertDefined(
@@ -54054,7 +54077,10 @@ function ____exports.getJSONRoomOfVariant(self, jsonRooms, variant)
54054
54077
  jsonRooms,
54055
54078
  function(____, jsonRoom)
54056
54079
  local roomVariantString = jsonRoom["$"].variant
54057
- local roomVariant = tonumber(roomVariantString)
54080
+ local roomVariant = parseIntSafe(nil, roomVariantString)
54081
+ if roomVariant == nil then
54082
+ error("Failed to convert a JSON room variant to an integer: " .. roomVariantString)
54083
+ end
54058
54084
  return roomVariant == variant
54059
54085
  end
54060
54086
  )
@@ -54077,7 +54103,10 @@ function ____exports.getJSONRoomsOfSubType(self, jsonRooms, subType)
54077
54103
  jsonRooms,
54078
54104
  function(____, jsonRoom)
54079
54105
  local roomSubTypeString = jsonRoom["$"].subtype
54080
- local roomSubType = tonumber(roomSubTypeString)
54106
+ local roomSubType = parseIntSafe(nil, roomSubTypeString)
54107
+ if roomSubType == nil then
54108
+ error("Failed to convert a JSON room sub-type to an integer: " .. roomSubTypeString)
54109
+ end
54081
54110
  return roomSubType == subType
54082
54111
  end
54083
54112
  )
@@ -54603,6 +54632,7 @@ local ____spawnCollectible = require("functions.spawnCollectible")
54603
54632
  local spawnCollectible = ____spawnCollectible.spawnCollectible
54604
54633
  local ____types = require("functions.types")
54605
54634
  local asCollectibleType = ____types.asCollectibleType
54635
+ local parseIntSafe = ____types.parseIntSafe
54606
54636
  local ____utils = require("functions.utils")
54607
54637
  local assertDefined = ____utils.assertDefined
54608
54638
  local ____ReadonlySet = require("types.ReadonlySet")
@@ -54756,28 +54786,28 @@ function DeployJSONRoom.prototype.spawnAllEntities(self, jsonRoom, rng, verbose)
54756
54786
  local shouldUnclearRoom = false
54757
54787
  for ____, jsonSpawn in ipairs(jsonRoom.spawn) do
54758
54788
  local xString = jsonSpawn["$"].x
54759
- local x = tonumber(xString)
54760
- assertDefined(nil, x, "Failed to convert the following x coordinate to a number (for a spawn): " .. xString)
54789
+ local x = parseIntSafe(nil, xString)
54790
+ assertDefined(nil, x, "Failed to convert the following x coordinate to an integer (for a spawn): " .. xString)
54761
54791
  local yString = jsonSpawn["$"].y
54762
- local y = tonumber(yString)
54763
- assertDefined(nil, y, "Failed to convert the following y coordinate to a number (for a spawn): " .. yString)
54792
+ local y = parseIntSafe(nil, yString)
54793
+ assertDefined(nil, y, "Failed to convert the following y coordinate to an integer (for a spawn): " .. yString)
54764
54794
  local jsonEntity = getRandomJSONEntity(nil, jsonSpawn.entity, rng)
54765
54795
  local entityTypeString = jsonEntity["$"].type
54766
- local entityTypeNumber = tonumber(entityTypeString)
54767
- assertDefined(nil, entityTypeNumber, "Failed to convert the entity type to a number: " .. entityTypeString)
54796
+ local entityTypeNumber = parseIntSafe(nil, entityTypeString)
54797
+ assertDefined(nil, entityTypeNumber, "Failed to convert the entity type to an integer: " .. entityTypeString)
54768
54798
  local variantString = jsonEntity["$"].variant
54769
- local variant = tonumber(variantString)
54799
+ local variant = parseIntSafe(nil, variantString)
54770
54800
  assertDefined(
54771
54801
  nil,
54772
54802
  variant,
54773
- "Failed to convert the entity variant to a number: " .. tostring(variant)
54803
+ "Failed to convert the entity variant to an integer: " .. tostring(variant)
54774
54804
  )
54775
54805
  local subTypeString = jsonEntity["$"].subtype
54776
- local subType = tonumber(subTypeString)
54806
+ local subType = parseIntSafe(nil, subTypeString)
54777
54807
  assertDefined(
54778
54808
  nil,
54779
54809
  subType,
54780
- "Failed to convert the entity sub-type to a number: " .. tostring(subType)
54810
+ "Failed to convert the entity sub-type to an integer: " .. tostring(subType)
54781
54811
  )
54782
54812
  local isGridEntity = GRID_ENTITY_XML_TYPE_SET:has(entityTypeNumber)
54783
54813
  if isGridEntity then
@@ -57982,6 +58012,7 @@ local ITEM_POOL_TYPE_VALUES = ____cachedEnumValues.ITEM_POOL_TYPE_VALUES
57982
58012
  local itemPoolsJSON = require("data.itempools")
57983
58013
  local ____types = require("functions.types")
57984
58014
  local asCollectibleType = ____types.asCollectibleType
58015
+ local parseIntSafe = ____types.parseIntSafe
57985
58016
  local ____itemPoolTypeToItemPoolName = require("maps.itemPoolTypeToItemPoolName")
57986
58017
  local ITEM_POOL_TYPE_TO_ITEM_POOL_NAME = ____itemPoolTypeToItemPoolName.ITEM_POOL_TYPE_TO_ITEM_POOL_NAME
57987
58018
  function getItemPoolJSON(self, itemPoolType)
@@ -58001,11 +58032,11 @@ ____exports.ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET = (function()
58001
58032
  else
58002
58033
  local collectibleTypesSet = __TS__New(Set)
58003
58034
  for ____, itemPoolJSONElement in ipairs(itemPoolJSON.Item) do
58004
- local collectibleTypeNumber = tonumber(itemPoolJSONElement["$"].Id)
58005
- if collectibleTypeNumber == nil then
58035
+ local collectibleTypeInt = parseIntSafe(nil, itemPoolJSONElement["$"].Id)
58036
+ if collectibleTypeInt == nil then
58006
58037
  error("Failed to parse a collectible type in the \"itempools.json\" file: " .. itemPoolJSONElement["$"].Id)
58007
58038
  end
58008
- local collectibleType = asCollectibleType(nil, collectibleTypeNumber)
58039
+ local collectibleType = asCollectibleType(nil, collectibleTypeInt)
58009
58040
  collectibleTypesSet:add(collectibleType)
58010
58041
  end
58011
58042
  itemPoolTypeToCollectibleTypes[itemPoolType] = collectibleTypesSet
@@ -59857,13 +59888,15 @@ local getRoomData = ____roomData.getRoomData
59857
59888
  local getRoomDescriptor = ____roomData.getRoomDescriptor
59858
59889
  local ____rooms = require("functions.rooms")
59859
59890
  local changeRoom = ____rooms.changeRoom
59891
+ local ____types = require("functions.types")
59892
+ local parseIntSafe = ____types.parseIntSafe
59860
59893
  local ____roomTypeNames = require("objects.roomTypeNames")
59861
59894
  local ROOM_TYPE_NAMES = ____roomTypeNames.ROOM_TYPE_NAMES
59862
59895
  local DEFAULT_MOVE_UNITS = 0.5
59863
59896
  function ____exports.addHeart(self, params, healthType)
59864
59897
  local numHearts = healthType == HealthType.MAX_HEARTS and 2 or 1
59865
59898
  if params ~= "" then
59866
- local num = tonumber(params)
59899
+ local num = parseIntSafe(nil, params)
59867
59900
  if num == nil then
59868
59901
  print("That is an invalid amount of hearts to add.")
59869
59902
  return
@@ -59894,7 +59927,7 @@ end
59894
59927
  function ____exports.listEntities(self, params, includeBackgroundEffects)
59895
59928
  local entityTypeFilter
59896
59929
  if params ~= "" then
59897
- entityTypeFilter = tonumber(params)
59930
+ entityTypeFilter = parseIntSafe(nil, params)
59898
59931
  if entityTypeFilter == nil then
59899
59932
  print("That is an invalid entity type to filter by.")
59900
59933
  return
@@ -59906,7 +59939,7 @@ end
59906
59939
  function ____exports.listGridEntities(self, params, includeWalls)
59907
59940
  local gridEntityTypeFilter
59908
59941
  if params ~= "" then
59909
- gridEntityTypeFilter = tonumber(params)
59942
+ gridEntityTypeFilter = parseIntSafe(nil, params)
59910
59943
  if gridEntityTypeFilter == nil then
59911
59944
  print("That is an invalid grid entity type to filter by.")
59912
59945
  return
@@ -59918,7 +59951,7 @@ end
59918
59951
  function ____exports.movePlayer(self, params, direction)
59919
59952
  local amount = DEFAULT_MOVE_UNITS
59920
59953
  if params ~= "" then
59921
- local num = tonumber(params)
59954
+ local num = parseIntSafe(nil, params)
59922
59955
  if num == nil then
59923
59956
  print("That is an invalid amount of units to move.")
59924
59957
  return
@@ -59999,7 +60032,6 @@ return ____exports
59999
60032
  local ____lualib = require("lualib_bundle")
60000
60033
  local __TS__StringSplit = ____lualib.__TS__StringSplit
60001
60034
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
60002
- local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
60003
60035
  local ____exports = {}
60004
60036
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.index")
60005
60037
  local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
@@ -60014,10 +60046,11 @@ local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
60014
60046
  local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
60015
60047
  local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
60016
60048
  local PillColor = ____isaac_2Dtypescript_2Ddefinitions.PillColor
60049
+ local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
60017
60050
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
60051
+ local SoundEffect = ____isaac_2Dtypescript_2Ddefinitions.SoundEffect
60018
60052
  local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
60019
60053
  local ____cachedEnumValues = require("arrays.cachedEnumValues")
60020
- local ACTIVE_SLOT_VALUES = ____cachedEnumValues.ACTIVE_SLOT_VALUES
60021
60054
  local GRID_ENTITY_TYPE_VALUES = ____cachedEnumValues.GRID_ENTITY_TYPE_VALUES
60022
60055
  local ____cachedClasses = require("core.cachedClasses")
60023
60056
  local game = ____cachedClasses.game
@@ -60028,21 +60061,14 @@ local MAX_LEVEL_GRID_INDEX = ____constants.MAX_LEVEL_GRID_INDEX
60028
60061
  local MAX_NUM_FAMILIARS = ____constants.MAX_NUM_FAMILIARS
60029
60062
  local ____constantsFirstLast = require("core.constantsFirstLast")
60030
60063
  local FIRST_CARD_TYPE = ____constantsFirstLast.FIRST_CARD_TYPE
60031
- local FIRST_CHARACTER = ____constantsFirstLast.FIRST_CHARACTER
60032
60064
  local FIRST_HORSE_PILL_COLOR = ____constantsFirstLast.FIRST_HORSE_PILL_COLOR
60033
60065
  local FIRST_PILL_COLOR = ____constantsFirstLast.FIRST_PILL_COLOR
60034
- local FIRST_PILL_EFFECT = ____constantsFirstLast.FIRST_PILL_EFFECT
60035
- local FIRST_ROOM_TYPE = ____constantsFirstLast.FIRST_ROOM_TYPE
60036
- local FIRST_STAGE = ____constantsFirstLast.FIRST_STAGE
60037
- local LAST_ROOM_TYPE = ____constantsFirstLast.LAST_ROOM_TYPE
60038
- local LAST_STAGE = ____constantsFirstLast.LAST_STAGE
60039
60066
  local LAST_VANILLA_CARD_TYPE = ____constantsFirstLast.LAST_VANILLA_CARD_TYPE
60040
- local LAST_VANILLA_CHARACTER = ____constantsFirstLast.LAST_VANILLA_CHARACTER
60041
- local LAST_VANILLA_PILL_EFFECT = ____constantsFirstLast.LAST_VANILLA_PILL_EFFECT
60042
60067
  local ____HealthType = require("enums.HealthType")
60043
60068
  local HealthType = ____HealthType.HealthType
60044
60069
  local ____cards = require("functions.cards")
60045
60070
  local getCardName = ____cards.getCardName
60071
+ local isValidCardType = ____cards.isValidCardType
60046
60072
  local ____characters = require("functions.characters")
60047
60073
  local getCharacterName = ____characters.getCharacterName
60048
60074
  local ____charge = require("functions.charge")
@@ -60056,6 +60082,8 @@ local ____deepCopyTests = require("functions.deepCopyTests")
60056
60082
  local runDeepCopyTests = ____deepCopyTests.runDeepCopyTests
60057
60083
  local ____entitiesSpecific = require("functions.entitiesSpecific")
60058
60084
  local getNPCs = ____entitiesSpecific.getNPCs
60085
+ local ____enums = require("functions.enums")
60086
+ local isEnumValue = ____enums.isEnumValue
60059
60087
  local ____flag = require("functions.flag")
60060
60088
  local addFlag = ____flag.addFlag
60061
60089
  local ____gridEntities = require("functions.gridEntities")
@@ -60076,6 +60104,7 @@ local spawnPill = ____pickupsSpecific.spawnPill
60076
60104
  local spawnTrinketFunction = ____pickupsSpecific.spawnTrinket
60077
60105
  local ____pills = require("functions.pills")
60078
60106
  local getPillEffectName = ____pills.getPillEffectName
60107
+ local isValidPillEffect = ____pills.isValidPillEffect
60079
60108
  local ____playerCollectibles = require("functions.playerCollectibles")
60080
60109
  local addCollectibleCostume = ____playerCollectibles.addCollectibleCostume
60081
60110
  local removeCollectibleCostume = ____playerCollectibles.removeCollectibleCostume
@@ -60105,9 +60134,9 @@ local ____string = require("functions.string")
60105
60134
  local getMapPartialMatch = ____string.getMapPartialMatch
60106
60135
  local ____trinkets = require("functions.trinkets")
60107
60136
  local getGoldenTrinketType = ____trinkets.getGoldenTrinketType
60137
+ local isValidTrinketType = ____trinkets.isValidTrinketType
60108
60138
  local ____types = require("functions.types")
60109
- local asCollectibleType = ____types.asCollectibleType
60110
- local asTrinketType = ____types.asTrinketType
60139
+ local parseIntSafe = ____types.parseIntSafe
60111
60140
  local ____utils = require("functions.utils")
60112
60141
  local iRange = ____utils.iRange
60113
60142
  local ____cardNameToTypeMap = require("maps.cardNameToTypeMap")
@@ -60203,9 +60232,9 @@ end
60203
60232
  function ____exports.poopMana(self, params)
60204
60233
  local charges = 1
60205
60234
  if params ~= "" then
60206
- local num = tonumber(params)
60235
+ local num = parseIntSafe(nil, params)
60207
60236
  if num == nil then
60208
- print("That is an invalid amount of mana to add.")
60237
+ print("Invalid mana amount: " .. tostring(num))
60209
60238
  return
60210
60239
  end
60211
60240
  charges = num
@@ -60218,9 +60247,9 @@ end
60218
60247
  -- For example:
60219
60248
  -- - sound 1 - Plays the 1-Up sound effect.
60220
60249
  function ____exports.sound(self, params)
60221
- local soundEffect = tonumber(params)
60222
- if soundEffect == nil then
60223
- print("That is an invalid sound effect ID.")
60250
+ local soundEffect = parseIntSafe(nil, params)
60251
+ if soundEffect == nil or not isEnumValue(nil, soundEffect, SoundEffect) then
60252
+ print(("Invalid sound effect ID: " .. tostring(soundEffect)) .. ".")
60224
60253
  return
60225
60254
  end
60226
60255
  sfxManager:Play(soundEffect)
@@ -60241,9 +60270,9 @@ function ____exports.spawnCollectible(self, params)
60241
60270
  print("You must specify the collectible name or the number corresponding to the collectible type.")
60242
60271
  return
60243
60272
  end
60244
- local collectibleTypeNumber = tonumber(params)
60273
+ local num = parseIntSafe(nil, params)
60245
60274
  local collectibleType
60246
- if collectibleTypeNumber == nil then
60275
+ if num == nil then
60247
60276
  local match = getMapPartialMatch(nil, params, COLLECTIBLE_NAME_TO_TYPE_MAP)
60248
60277
  if match == nil then
60249
60278
  print("Unknown collectible: " .. params)
@@ -60251,7 +60280,10 @@ function ____exports.spawnCollectible(self, params)
60251
60280
  end
60252
60281
  collectibleType = match[2]
60253
60282
  else
60254
- collectibleType = asCollectibleType(nil, collectibleTypeNumber)
60283
+ if not isValidCollectibleType(nil, num) then
60284
+ print("Invalid collectible type: " .. tostring(num))
60285
+ end
60286
+ collectibleType = num
60255
60287
  end
60256
60288
  local roomClass = game:GetRoom()
60257
60289
  local centerPos = roomClass:GetCenterPos()
@@ -60283,9 +60315,9 @@ function ____exports.spawnTrinket(self, params, golden)
60283
60315
  print("You must specify the name or number corresponding to the trinket type.")
60284
60316
  return
60285
60317
  end
60286
- local trinketTypeNumber = tonumber(params)
60318
+ local num = parseIntSafe(nil, params)
60287
60319
  local trinketType
60288
- if trinketTypeNumber == nil then
60320
+ if num == nil then
60289
60321
  local match = getMapPartialMatch(nil, params, TRINKET_NAME_TO_TYPE_MAP)
60290
60322
  if match == nil then
60291
60323
  print("Unknown trinket: " .. params)
@@ -60293,7 +60325,11 @@ function ____exports.spawnTrinket(self, params, golden)
60293
60325
  end
60294
60326
  trinketType = match[2]
60295
60327
  else
60296
- trinketType = asTrinketType(nil, trinketTypeNumber)
60328
+ if not isValidTrinketType(nil, num) then
60329
+ print("Invalid trinket type: " .. tostring(num))
60330
+ return
60331
+ end
60332
+ trinketType = num
60297
60333
  end
60298
60334
  local roomClass = game:GetRoom()
60299
60335
  local centerPos = roomClass:GetCenterPos()
@@ -60325,17 +60361,20 @@ function ____exports.spawnTrinketAt(self, params, golden)
60325
60361
  print("You must specify the number corresponding to the trinket type and the number corresponding to the grid tile location.")
60326
60362
  return
60327
60363
  end
60328
- local trinketTypeNumber = tonumber(args[1])
60329
- if trinketTypeNumber == nil or trinketTypeNumber < 0 then
60330
- print("Failed to parse the trinket type of: " .. tostring(args[1]))
60364
+ local trinketTypeString, gridIndexString = table.unpack(args)
60365
+ if trinketTypeString == nil or gridIndexString == nil then
60366
+ return
60367
+ end
60368
+ local trinketType = parseIntSafe(nil, trinketTypeString)
60369
+ if trinketType == nil or not isValidTrinketType(nil, trinketType) then
60370
+ print("Invalid trinket type: " .. trinketTypeString)
60331
60371
  return
60332
60372
  end
60333
- local gridIndex = tonumber(args[2])
60373
+ local gridIndex = parseIntSafe(nil, gridIndexString)
60334
60374
  if gridIndex == nil or gridIndex < 0 then
60335
60375
  print("Failed to parse the grid index of: " .. tostring(args[2]))
60336
60376
  return
60337
60377
  end
60338
- local trinketType = asTrinketType(nil, trinketTypeNumber)
60339
60378
  local goldenTrinketType = getGoldenTrinketType(nil, trinketType)
60340
60379
  local trinketTypeToSpawn = golden and goldenTrinketType or trinketType
60341
60380
  spawnTrinketFunction(nil, trinketTypeToSpawn, gridIndex)
@@ -60356,24 +60395,23 @@ function ____exports.addCharges(self, params)
60356
60395
  end
60357
60396
  local args = __TS__StringSplit(params, " ")
60358
60397
  if #args ~= 1 and #args ~= 2 then
60359
- print("That is an invalid amount of arguments.")
60398
+ print("Invalid amount of arguments: " .. tostring(#args))
60360
60399
  return
60361
60400
  end
60362
60401
  local activeSlotString, numChargeString = table.unpack(args)
60363
- local activeSlot = tonumber(activeSlotString)
60364
- if activeSlot == nil then
60365
- print("The provided slot number is invalid: " .. tostring(activeSlotString))
60402
+ if activeSlotString == nil then
60366
60403
  return
60367
60404
  end
60368
- if activeSlot < ActiveSlot.PRIMARY or activeSlot > ActiveSlot.POCKET_SINGLE_USE then
60369
- print("The provided slot number is invalid: " .. tostring(activeSlot))
60405
+ local activeSlot = parseIntSafe(nil, activeSlotString)
60406
+ if activeSlot == nil or not isEnumValue(nil, activeSlot, ActiveSlot) then
60407
+ print("Invalid slot number: " .. tostring(activeSlot))
60370
60408
  return
60371
60409
  end
60372
60410
  local numCharges = 1
60373
60411
  if numChargeString ~= nil then
60374
- local numChargesAttempt = tonumber(numChargeString)
60412
+ local numChargesAttempt = parseIntSafe(nil, numChargeString)
60375
60413
  if numChargesAttempt == nil then
60376
- print("The provided charge amount is invalid: " .. numChargeString)
60414
+ print("Invalid charge amount: " .. numChargeString)
60377
60415
  return
60378
60416
  end
60379
60417
  numCharges = numChargesAttempt
@@ -60425,9 +60463,9 @@ end
60425
60463
  function ____exports.bloodCharges(self, params)
60426
60464
  local charges = 1
60427
60465
  if params ~= "" then
60428
- local num = tonumber(params)
60466
+ local num = parseIntSafe(nil, params)
60429
60467
  if num == nil then
60430
- print("That is an invalid amount of charges to add.")
60468
+ print("Invalid charge amount: " .. tostring(num))
60431
60469
  return
60432
60470
  end
60433
60471
  charges = num
@@ -60444,9 +60482,9 @@ end
60444
60482
  function ____exports.bomb(self, params)
60445
60483
  local numBombs = 1
60446
60484
  if params ~= "" then
60447
- local num = tonumber(params)
60485
+ local num = parseIntSafe(nil, params)
60448
60486
  if num == nil then
60449
- print("That is an invalid amount of bombs to add.")
60487
+ print("Invalid bomb amount: " .. tostring(num))
60450
60488
  return
60451
60489
  end
60452
60490
  numBombs = num
@@ -60459,9 +60497,9 @@ end
60459
60497
  function ____exports.bombs(self, params)
60460
60498
  local numBombs = 99
60461
60499
  if params ~= "" then
60462
- local num = tonumber(params)
60500
+ local num = parseIntSafe(nil, params)
60463
60501
  if num == nil then
60464
- print("That is an invalid amount of bombs to add.")
60502
+ print("Invalid bomb amount: " .. tostring(num))
60465
60503
  return
60466
60504
  end
60467
60505
  numBombs = num
@@ -60491,7 +60529,7 @@ end
60491
60529
  function ____exports.brokenHearts(self, params)
60492
60530
  addHeart(nil, params, HealthType.BROKEN)
60493
60531
  end
60494
- --- Gives the specified card. Accepts either the card sub-type or the partial name of the card.
60532
+ --- Gives the specified card. Accepts either the card type or the partial name of the card.
60495
60533
  --
60496
60534
  -- For example:
60497
60535
  -- - card 5 - Gives The Emperor.
@@ -60502,7 +60540,7 @@ function ____exports.card(self, params)
60502
60540
  return
60503
60541
  end
60504
60542
  local cardType
60505
- local num = tonumber(params)
60543
+ local num = parseIntSafe(nil, params)
60506
60544
  if num == nil then
60507
60545
  local match = getMapPartialMatch(nil, params, CARD_NAME_TO_TYPE_MAP)
60508
60546
  if match == nil then
@@ -60511,8 +60549,8 @@ function ____exports.card(self, params)
60511
60549
  end
60512
60550
  cardType = match[2]
60513
60551
  else
60514
- if num < FIRST_CARD_TYPE or num > LAST_VANILLA_CARD_TYPE then
60515
- print("Invalid card sub-type: " .. tostring(num))
60552
+ if not isValidCardType(nil, num) then
60553
+ print("Invalid card type: " .. tostring(num))
60516
60554
  return
60517
60555
  end
60518
60556
  cardType = num
@@ -60559,7 +60597,7 @@ function ____exports.character(self, params)
60559
60597
  return
60560
60598
  end
60561
60599
  local playerType
60562
- local num = tonumber(params)
60600
+ local num = parseIntSafe(nil, params)
60563
60601
  if num == nil then
60564
60602
  local match = getMapPartialMatch(nil, params, CHARACTER_NAME_TO_TYPE_MAP)
60565
60603
  if match == nil then
@@ -60568,7 +60606,7 @@ function ____exports.character(self, params)
60568
60606
  end
60569
60607
  playerType = match[2]
60570
60608
  else
60571
- if num < FIRST_CHARACTER or num > LAST_VANILLA_CHARACTER then
60609
+ if not isEnumValue(nil, num, PlayerType) or num == PlayerType.POSSESSOR then
60572
60610
  print("Invalid character number: " .. tostring(num))
60573
60611
  return
60574
60612
  end
@@ -60591,9 +60629,9 @@ end
60591
60629
  function ____exports.coin(self, params)
60592
60630
  local numCoins = 1
60593
60631
  if params ~= "" then
60594
- local num = tonumber(params)
60632
+ local num = parseIntSafe(nil, params)
60595
60633
  if num == nil then
60596
- print("That is an invalid amount of coins to add.")
60634
+ print("Invalid coin amount: " .. tostring(num))
60597
60635
  return
60598
60636
  end
60599
60637
  numCoins = num
@@ -60606,9 +60644,9 @@ end
60606
60644
  function ____exports.coins(self, params)
60607
60645
  local numCoins = 999
60608
60646
  if params ~= "" then
60609
- local num = tonumber(params)
60647
+ local num = parseIntSafe(nil, params)
60610
60648
  if num == nil then
60611
- print("That is an invalid amount of coins to add.")
60649
+ print("Invalid coin amount: " .. tostring(num))
60612
60650
  return
60613
60651
  end
60614
60652
  numCoins = num
@@ -60651,7 +60689,7 @@ function ____exports.damage(self, params)
60651
60689
  if params ~= "" then
60652
60690
  local num = tonumber(params)
60653
60691
  if num == nil then
60654
- print("The provided damage amount is invalid: " .. params)
60692
+ print("Invalid damage amount: " .. params)
60655
60693
  return
60656
60694
  end
60657
60695
  v.persistent.damageAmount = num
@@ -60747,9 +60785,9 @@ end
60747
60785
  function ____exports.getCharge(self, params)
60748
60786
  local activeSlot = ActiveSlot.PRIMARY
60749
60787
  if params ~= "" then
60750
- local num = tonumber(params)
60751
- if num == nil then
60752
- print("The provided slot number is invalid: " .. params)
60788
+ local num = parseIntSafe(nil, params)
60789
+ if num == nil or not isEnumValue(nil, num, ActiveSlot) then
60790
+ print("Invalid slot number: " .. params)
60753
60791
  return
60754
60792
  end
60755
60793
  activeSlot = num
@@ -60775,9 +60813,9 @@ end
60775
60813
  function ____exports.gigaBomb(self, params)
60776
60814
  local numBombs = 1
60777
60815
  if params ~= "" then
60778
- local num = tonumber(params)
60816
+ local num = parseIntSafe(nil, params)
60779
60817
  if num == nil then
60780
- print("That is an invalid amount of Giga Bombs to add.")
60818
+ print("Invalid Giga Bomb amount: " .. tostring(num))
60781
60819
  return
60782
60820
  end
60783
60821
  numBombs = num
@@ -60856,9 +60894,9 @@ end
60856
60894
  function ____exports.key(self, params)
60857
60895
  local numKeys = 1
60858
60896
  if params ~= "" then
60859
- local num = tonumber(params)
60897
+ local num = parseIntSafe(nil, params)
60860
60898
  if num == nil then
60861
- print("That is an invalid amount of keys to add.")
60899
+ print("Invalid key amount: " .. tostring(num))
60862
60900
  return
60863
60901
  end
60864
60902
  numKeys = num
@@ -60871,9 +60909,9 @@ end
60871
60909
  function ____exports.keys(self, params)
60872
60910
  local numKeys = 99
60873
60911
  if params ~= "" then
60874
- local num = tonumber(params)
60912
+ local num = parseIntSafe(nil, params)
60875
60913
  if num == nil then
60876
- print("That is an invalid amount of keys to add.")
60914
+ print("Invalid key amount: " .. tostring(num))
60877
60915
  return
60878
60916
  end
60879
60917
  numKeys = num
@@ -60983,7 +61021,7 @@ function ____exports.pill(self, params)
60983
61021
  return
60984
61022
  end
60985
61023
  local pillEffect
60986
- local num = tonumber(params)
61024
+ local num = parseIntSafe(nil, params)
60987
61025
  if num == nil then
60988
61026
  local match = getMapPartialMatch(nil, params, PILL_NAME_TO_EFFECT_MAP)
60989
61027
  if match == nil then
@@ -60992,7 +61030,7 @@ function ____exports.pill(self, params)
60992
61030
  end
60993
61031
  pillEffect = match[2]
60994
61032
  else
60995
- if num < FIRST_PILL_EFFECT or num > LAST_VANILLA_PILL_EFFECT then
61033
+ if not isValidPillEffect(nil, num) then
60996
61034
  print("Invalid pill effect ID: " .. tostring(num))
60997
61035
  return
60998
61036
  end
@@ -61054,13 +61092,9 @@ function ____exports.pocket(self, params)
61054
61092
  print("You must supply a collectible type to put as the pocket item.")
61055
61093
  return
61056
61094
  end
61057
- local collectibleType = tonumber(params)
61058
- if collectibleType == nil then
61059
- print("That is an invalid collectible type.")
61060
- return
61061
- end
61062
- if not isValidCollectibleType(nil, collectibleType) then
61063
- print("That is an invalid collectible type.")
61095
+ local collectibleType = parseIntSafe(nil, params)
61096
+ if collectibleType == nil or not isValidCollectibleType(nil, collectibleType) then
61097
+ print("Invalid collectible type: " .. tostring(collectibleType))
61064
61098
  return
61065
61099
  end
61066
61100
  local player = Isaac.GetPlayer()
@@ -61128,13 +61162,9 @@ function ____exports.s(self, params)
61128
61162
  stageString = params
61129
61163
  stageTypeLetter = ""
61130
61164
  end
61131
- local stage = tonumber(stageString)
61132
- if stage == nil then
61133
- print("That is an invalid stage number: " .. tostring(stage))
61134
- return
61135
- end
61136
- if stage < FIRST_STAGE or stage > LAST_STAGE then
61137
- print(((("Invalid stage number; must be between " .. tostring(FIRST_STAGE)) .. " and ") .. tostring(LAST_STAGE)) .. ".")
61165
+ local stage = parseIntSafe(nil, stageString)
61166
+ if stage == nil or not isEnumValue(nil, stage, StageType) then
61167
+ print("Invalid stage number: " .. tostring(stage))
61138
61168
  return
61139
61169
  end
61140
61170
  Isaac.ExecuteCommand(("stage " .. tostring(stage)) .. stageTypeLetter)
@@ -61176,26 +61206,25 @@ function ____exports.setCharges(self, params)
61176
61206
  return
61177
61207
  end
61178
61208
  if #args ~= 2 then
61179
- print("That is an invalid amount of arguments.")
61209
+ print("Invalid amount of arguments: " .. tostring(#args))
61180
61210
  return
61181
61211
  end
61182
61212
  local activeSlotString, chargeString = table.unpack(args)
61183
- local activeSlot = tonumber(activeSlotString)
61184
- if activeSlot == nil then
61185
- print("The provided slot number is invalid: " .. tostring(activeSlotString))
61213
+ if activeSlotString == nil or chargeString == nil then
61186
61214
  return
61187
61215
  end
61188
- if not __TS__ArrayIncludes(ACTIVE_SLOT_VALUES, activeSlot) then
61189
- print("The provided slot number is invalid: " .. tostring(activeSlot))
61216
+ local activeSlot = parseIntSafe(nil, activeSlotString)
61217
+ if activeSlot == nil or not isEnumValue(nil, activeSlot, ActiveSlot) then
61218
+ print("Invalid slot number: " .. activeSlotString)
61190
61219
  return
61191
61220
  end
61192
- local chargeNum = tonumber(chargeString)
61221
+ local chargeNum = parseIntSafe(nil, chargeString)
61193
61222
  if chargeNum == nil then
61194
- print("The provided charge amount is invalid: " .. tostring(chargeString))
61223
+ print("Invalid charge amount: " .. chargeString)
61195
61224
  return
61196
61225
  end
61197
61226
  if chargeNum < 0 then
61198
- print("The provided charge amount is invalid: " .. tostring(chargeNum))
61227
+ print("Invalid charge amount: " .. tostring(chargeNum))
61199
61228
  return
61200
61229
  end
61201
61230
  local player = Isaac.GetPlayer()
@@ -61216,14 +61245,17 @@ function ____exports.setPosition(self, params)
61216
61245
  return
61217
61246
  end
61218
61247
  local xString, yString = table.unpack(args)
61219
- local x = tonumber(xString)
61248
+ if xString == nil or yString == nil then
61249
+ return
61250
+ end
61251
+ local x = parseIntSafe(nil, xString)
61220
61252
  if x == nil then
61221
- print("That is an invalid x value: " .. tostring(xString))
61253
+ print("Invalid x value: " .. xString)
61222
61254
  return
61223
61255
  end
61224
- local y = tonumber(yString)
61256
+ local y = parseIntSafe(nil, yString)
61225
61257
  if y == nil then
61226
- print("That is an invalid y value: " .. tostring(yString))
61258
+ print("Invalid y value: " .. yString)
61227
61259
  return
61228
61260
  end
61229
61261
  local player = Isaac.GetPlayer()
@@ -61244,9 +61276,9 @@ end
61244
61276
  function ____exports.soulCharges(self, params)
61245
61277
  local charges = 1
61246
61278
  if params ~= "" then
61247
- local num = tonumber(params)
61279
+ local num = parseIntSafe(nil, params)
61248
61280
  if num == nil then
61249
- print("That is an invalid amount of charges to add.")
61281
+ print("Invalid charges amount: " .. tostring(num))
61250
61282
  return
61251
61283
  end
61252
61284
  charges = num
@@ -61291,17 +61323,20 @@ function ____exports.spawnCollectibleAt(self, params)
61291
61323
  print("You must specify the number corresponding to the collectible type and the number corresponding to the grid tile location.")
61292
61324
  return
61293
61325
  end
61294
- local collectibleTypeNumber = tonumber(args[1])
61295
- if collectibleTypeNumber == nil or collectibleTypeNumber < 0 then
61296
- print("Failed to parse the collectible type of: " .. tostring(args[1]))
61326
+ local collectibleTypeString, gridIndexString = table.unpack(args)
61327
+ if collectibleTypeString == nil or gridIndexString == nil then
61297
61328
  return
61298
61329
  end
61299
- local gridIndex = tonumber(args[2])
61330
+ local collectibleType = parseIntSafe(nil, collectibleTypeString)
61331
+ if collectibleType == nil or not isValidCollectibleType(nil, collectibleType) then
61332
+ print("Invalid collectible type: " .. tostring(args[1]))
61333
+ return
61334
+ end
61335
+ local gridIndex = parseIntSafe(nil, gridIndexString)
61300
61336
  if gridIndex == nil or gridIndex < 0 then
61301
61337
  print("Failed to parse the grid index of: " .. tostring(args[2]))
61302
61338
  return
61303
61339
  end
61304
- local collectibleType = asCollectibleType(nil, collectibleTypeNumber)
61305
61340
  spawnCollectibleFunc(nil, collectibleType, gridIndex, nil)
61306
61341
  end
61307
61342
  --- Alias for the `spawnGoldenTrinket` command.
@@ -61321,7 +61356,7 @@ function ____exports.speed(self, params)
61321
61356
  if params ~= "" then
61322
61357
  local num = tonumber(params)
61323
61358
  if num == nil then
61324
- print("The provided speed amount is invalid: " .. params)
61359
+ print("Invalid speed amount: " .. params)
61325
61360
  return
61326
61361
  end
61327
61362
  v.persistent.damageAmount = num
@@ -61355,7 +61390,7 @@ function ____exports.tears(self, params)
61355
61390
  if params ~= "" then
61356
61391
  local num = tonumber(params)
61357
61392
  if num == nil then
61358
- print("The provided tear delay amount is invalid: " .. params)
61393
+ print("Invalid tear delay amount: " .. params)
61359
61394
  return
61360
61395
  end
61361
61396
  v.persistent.tearsAmount = num
@@ -61416,7 +61451,7 @@ function ____exports.warp(self, params)
61416
61451
  return
61417
61452
  end
61418
61453
  local roomType
61419
- local num = tonumber(params)
61454
+ local num = parseIntSafe(nil, params)
61420
61455
  if num == nil then
61421
61456
  local match = getMapPartialMatch(nil, params, ROOM_NAME_TO_TYPE_MAP)
61422
61457
  if match == nil then
@@ -61425,7 +61460,7 @@ function ____exports.warp(self, params)
61425
61460
  end
61426
61461
  roomType = match[2]
61427
61462
  else
61428
- if num < FIRST_ROOM_TYPE or num > LAST_ROOM_TYPE then
61463
+ if not isEnumValue(nil, num, RoomType) then
61429
61464
  print("Invalid room type: " .. tostring(num))
61430
61465
  return
61431
61466
  end
@@ -63406,12 +63441,16 @@ local getFeatures = ____features.getFeatures
63406
63441
  local ____debugFunctions = require("functions.debugFunctions")
63407
63442
  local getElapsedTimeSince = ____debugFunctions.getElapsedTimeSince
63408
63443
  local getTime = ____debugFunctions.getTime
63444
+ local ____enums = require("functions.enums")
63445
+ local isEnumValue = ____enums.isEnumValue
63409
63446
  local ____log = require("functions.log")
63410
63447
  local getParentFunctionDescription = ____log.getParentFunctionDescription
63411
63448
  local log = ____log.log
63412
63449
  local ____tstlClass = require("functions.tstlClass")
63413
63450
  local getTSTLClassConstructor = ____tstlClass.getTSTLClassConstructor
63414
63451
  local getTSTLClassName = ____tstlClass.getTSTLClassName
63452
+ local ____types = require("functions.types")
63453
+ local parseIntSafe = ____types.parseIntSafe
63415
63454
  local ____utils = require("functions.utils")
63416
63455
  local assertDefined = ____utils.assertDefined
63417
63456
  function getExportedMethodsFromFeature(self, featureClass)
@@ -63530,9 +63569,12 @@ function ModUpgraded.prototype.logUsedFeatures(self)
63530
63569
  if callbackClass.numConsumers == 0 then
63531
63570
  goto __continue19
63532
63571
  end
63533
- local modCallbackCustom = tonumber(modCallbackCustomString)
63534
- assertDefined(nil, modCallbackCustom, "Failed to convert an index on the callbacks object to a number.")
63535
- log(((("- ModCallbackCustom." .. tostring(ModCallbackCustom[modCallbackCustom])) .. " (") .. tostring(modCallbackCustom)) .. ")")
63572
+ local modCallbackCustom = parseIntSafe(nil, modCallbackCustomString)
63573
+ assertDefined(nil, modCallbackCustom, ("Failed to convert the string \"" .. modCallbackCustomString) .. "\" representing a \"ModCallbackCustom\" value to a number.")
63574
+ if not isEnumValue(nil, modCallbackCustom, ModCallbackCustom) then
63575
+ error(("Failed to convert the number " .. tostring(modCallbackCustom)) .. " to a \"ModCallbackCustom\" value.")
63576
+ end
63577
+ log(((("- ModCallbackCustom." .. ModCallbackCustom[modCallbackCustom]) .. " (") .. tostring(modCallbackCustom)) .. ")")
63536
63578
  end
63537
63579
  ::__continue19::
63538
63580
  end
@@ -63541,13 +63583,16 @@ function ModUpgraded.prototype.logUsedFeatures(self)
63541
63583
  local featureClass = ____value[2]
63542
63584
  do
63543
63585
  if featureClass.numConsumers == 0 then
63544
- goto __continue22
63586
+ goto __continue23
63587
+ end
63588
+ local iscFeature = parseIntSafe(nil, iscFeatureString)
63589
+ assertDefined(nil, iscFeature, ("Failed to convert the string \"" .. iscFeatureString) .. "\" representing a \"ISCFeature\" value to a number.")
63590
+ if not isEnumValue(nil, iscFeature, ISCFeature) then
63591
+ error(("Failed to convert the number " .. tostring(iscFeature)) .. " to a \"ISCFeature\" value.")
63545
63592
  end
63546
- local iscFeature = tonumber(iscFeatureString)
63547
- assertDefined(nil, iscFeature, "Failed to convert an index on the features object to a number.")
63548
- log(((("- ISCFeature." .. tostring(ISCFeature[iscFeature])) .. " (") .. tostring(iscFeature)) .. ")")
63593
+ log(((("- ISCFeature." .. ISCFeature[iscFeature]) .. " (") .. tostring(iscFeature)) .. ")")
63549
63594
  end
63550
- ::__continue22::
63595
+ ::__continue23::
63551
63596
  end
63552
63597
  end
63553
63598
  function ModUpgraded.prototype.initFeature(self, feature)