isaacscript-common 80.2.1 → 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 +254 -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.0
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,
@@ -6972,6 +6977,8 @@ local ____exports = {}
6972
6977
  --
6973
6978
  -- This is the sub-type of a player.
6974
6979
  --
6980
+ -- This enum is contiguous. (Every value is satisfied between -1 and 40, inclusive.)
6981
+ --
6975
6982
  -- Conventionally, variables that have this type are represented as "character" instead of
6976
6983
  -- "playerType", since the former is more descriptive of what this value actually represents.
6977
6984
  ____exports.PlayerType = {}
@@ -17145,6 +17152,23 @@ end
17145
17152
  function ____exports.isUserdata(self, variable)
17146
17153
  return type(variable) == "userdata"
17147
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
17148
17172
  return ____exports
17149
17173
  end,
17150
17174
  ["functions.sort"] = function(...)
@@ -17934,6 +17958,8 @@ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
17934
17958
  local __TS__StringSlice = ____lualib.__TS__StringSlice
17935
17959
  local __TS__StringEndsWith = ____lualib.__TS__StringEndsWith
17936
17960
  local ____exports = {}
17961
+ local ____types = require("functions.types")
17962
+ local parseIntSafe = ____types.parseIntSafe
17937
17963
  local ____utils = require("functions.utils")
17938
17964
  local assertDefined = ____utils.assertDefined
17939
17965
  --- Helper function to get the closest value from an array of strings based on partial search text.
@@ -18047,9 +18073,9 @@ function ____exports.parseSemanticVersion(self, versionString)
18047
18073
  if majorVersionString == nil or minorVersionString == nil or patchVersionString == nil then
18048
18074
  return nil
18049
18075
  end
18050
- local majorVersion = tonumber(majorVersionString)
18051
- local minorVersion = tonumber(minorVersionString)
18052
- local patchVersion = tonumber(patchVersionString)
18076
+ local majorVersion = parseIntSafe(nil, majorVersionString)
18077
+ local minorVersion = parseIntSafe(nil, minorVersionString)
18078
+ local patchVersion = parseIntSafe(nil, patchVersionString)
18053
18079
  if majorVersion == nil or minorVersion == nil or patchVersion == nil then
18054
18080
  return nil
18055
18081
  end
@@ -18290,8 +18316,9 @@ function ____exports.getBooleansFromTable(self, luaMap, objectName, ...)
18290
18316
  end
18291
18317
  return booleans
18292
18318
  end
18293
- --- Helper function to safely get number values from specific keys on a Lua table. Will throw an
18294
- -- 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.
18295
18322
  --
18296
18323
  -- This function is variadic, meaning that you can specify N arguments to get N values.
18297
18324
  function ____exports.getNumbersFromTable(self, luaMap, objectName, ...)
@@ -20105,11 +20132,9 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescri
20105
20132
  local CardType = ____isaac_2Dtypescript_2Ddefinitions.CardType
20106
20133
  local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
20107
20134
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
20108
- local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
20109
20135
  local PillColor = ____isaac_2Dtypescript_2Ddefinitions.PillColor
20110
20136
  local PillEffect = ____isaac_2Dtypescript_2Ddefinitions.PillEffect
20111
20137
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
20112
- local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
20113
20138
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
20114
20139
  local ____enums = require("functions.enums")
20115
20140
  local getEnumLength = ____enums.getEnumLength
@@ -20137,20 +20162,12 @@ ____exports.NUM_VANILLA_TRINKET_TYPES = getEnumLength(nil, TrinketType) - 1
20137
20162
  --- Equal to `Card.FOOL`.
20138
20163
  ____exports.FIRST_CARD_TYPE = CardType.FOOL
20139
20164
  --- Calculated from the `CardType` enum.
20140
- --
20141
- -- Note that this could be calculated from the length of the enum, because card types are
20142
- -- contiguous. However, we instead get the highest enum value to be safer and to make the code more
20143
- -- consistent with collectibles and trinkets.
20144
20165
  ____exports.LAST_VANILLA_CARD_TYPE = getHighestEnumValue(nil, CardType)
20145
20166
  --- Calculated from the `Card` enum. `Card.NULL` is not included.
20146
20167
  ____exports.NUM_VANILLA_CARD_TYPES = getEnumLength(nil, CardType) - 1
20147
20168
  --- Equal to `PillEffect.BAD_GAS`.
20148
20169
  ____exports.FIRST_PILL_EFFECT = PillEffect.BAD_GAS
20149
20170
  --- Calculated from the `PillEffect` enum.
20150
- --
20151
- -- Note that this could be calculated from the length of the enum, because pill effects are
20152
- -- contiguous. However, we instead get the highest enum value to be safer and to make the code more
20153
- -- consistent with collectibles and trinkets.
20154
20171
  ____exports.LAST_VANILLA_PILL_EFFECT = getHighestEnumValue(nil, PillEffect)
20155
20172
  --- Calculated from the `PillEffect` enum. (There is no `PillEffect.NULL` in the custom enum, so we
20156
20173
  -- do not have to subtract one here.)
@@ -20173,15 +20190,7 @@ ____exports.NUM_NORMAL_PILL_COLORS = #iRange(nil, ____exports.FIRST_PILL_COLOR,
20173
20190
  --- Equal to `PlayerType.ISAAC`.
20174
20191
  ____exports.FIRST_CHARACTER = PlayerType.ISAAC
20175
20192
  --- Calculated from the `PlayerType` enum.
20176
- --
20177
- -- Note that this could be calculated from the length of the enum, because characters are
20178
- -- contiguous. However, we instead get the highest enum value to be safer and to make the code more
20179
- -- consistent with collectibles and trinkets.
20180
20193
  ____exports.LAST_VANILLA_CHARACTER = getHighestEnumValue(nil, PlayerType)
20181
- ____exports.FIRST_ROOM_TYPE = RoomType.DEFAULT
20182
- ____exports.LAST_ROOM_TYPE = getHighestEnumValue(nil, RoomType)
20183
- ____exports.FIRST_STAGE = LevelStage.BASEMENT_1
20184
- ____exports.LAST_STAGE = getHighestEnumValue(nil, LevelStage)
20185
20194
  --- Calculated from the `Challenge` enum. `Challenge.NULL` is not included.
20186
20195
  ____exports.NUM_VANILLA_CHALLENGES = getEnumLength(nil, Challenge) - 1
20187
20196
  return ____exports
@@ -23572,10 +23581,14 @@ local ____bitwise = require("functions.bitwise")
23572
23581
  local arrayToBitFlags = ____bitwise.arrayToBitFlags
23573
23582
  local ____direction = require("functions.direction")
23574
23583
  local directionToVector = ____direction.directionToVector
23584
+ local ____enums = require("functions.enums")
23585
+ local isEnumValue = ____enums.isEnumValue
23575
23586
  local ____flag = require("functions.flag")
23576
23587
  local hasFlag = ____flag.hasFlag
23577
23588
  local ____tstlClass = require("functions.tstlClass")
23578
23589
  local isTSTLSet = ____tstlClass.isTSTLSet
23590
+ local ____types = require("functions.types")
23591
+ local parseIntSafe = ____types.parseIntSafe
23579
23592
  function ____exports.doorSlotToDirection(self, doorSlot)
23580
23593
  return DOOR_SLOT_TO_DIRECTION[doorSlot]
23581
23594
  end
@@ -23834,11 +23847,17 @@ function ____exports.getRoomShapeDoorSlot(self, roomShape, x, y)
23834
23847
  for ____, ____value in ipairs(__TS__ObjectEntries(doorSlotCoordinates)) do
23835
23848
  local doorSlotString = ____value[1]
23836
23849
  local coordinates = ____value[2]
23837
- local doorSlot = tonumber(doorSlotString)
23838
- local doorX, doorY = table.unpack(coordinates)
23839
- if x == doorX and y == doorY then
23840
- 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
23841
23859
  end
23860
+ ::__continue40::
23842
23861
  end
23843
23862
  return nil
23844
23863
  end
@@ -26786,6 +26805,7 @@ local isTSTLSet = ____tstlClass.isTSTLSet
26786
26805
  local ____types = require("functions.types")
26787
26806
  local asNPCState = ____types.asNPCState
26788
26807
  local isPrimitive = ____types.isPrimitive
26808
+ local parseIntSafe = ____types.parseIntSafe
26789
26809
  local ____utils = require("functions.utils")
26790
26810
  local assertDefined = ____utils.assertDefined
26791
26811
  local ____vector = require("functions.vector")
@@ -26965,24 +26985,15 @@ function ____exports.getConstituentsFromEntityID(self, entityID)
26965
26985
  error("Failed to get the constituents from entity ID: " .. entityID)
26966
26986
  end
26967
26987
  local entityTypeString, variantString, subTypeString = table.unpack(parts)
26968
- local entityType = tonumber(entityTypeString)
26969
- assertDefined(
26970
- nil,
26971
- entityType,
26972
- "Failed to convert the entity type to a number: " .. tostring(entityTypeString)
26973
- )
26974
- local variant = tonumber(variantString)
26975
- assertDefined(
26976
- nil,
26977
- variant,
26978
- "Failed to convert the entity variant to a number: " .. tostring(variantString)
26979
- )
26980
- local subType = tonumber(subTypeString)
26981
- assertDefined(
26982
- nil,
26983
- subType,
26984
- "Failed to convert the entity sub-type to a number: " .. tostring(subTypeString)
26985
- )
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)
26986
26997
  return {entityType, variant, subType}
26987
26998
  end
26988
26999
  --- Helper function to get all of the entities in the room or all of the entities that match a
@@ -27191,16 +27202,13 @@ function ____exports.parseEntityID(self, entityID)
27191
27202
  return nil
27192
27203
  end
27193
27204
  local entityTypeString, variantString, subTypeString = table.unpack(entityIDArray)
27194
- local entityType = tonumber(entityTypeString)
27195
- if entityType == nil then
27196
- return nil
27197
- end
27198
- local variant = tonumber(variantString)
27199
- if variant == nil then
27205
+ if entityTypeString == nil or variantString == nil or subTypeString == nil then
27200
27206
  return nil
27201
27207
  end
27202
- local subType = tonumber(subTypeString)
27203
- 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
27204
27212
  return nil
27205
27213
  end
27206
27214
  return {entityType, variant, subType}
@@ -27217,12 +27225,12 @@ function ____exports.parseEntityTypeVariantString(self, entityTypeVariantString)
27217
27225
  return nil
27218
27226
  end
27219
27227
  local entityTypeString, variantString = table.unpack(entityTypeVariantArray)
27220
- local entityType = tonumber(entityTypeString)
27221
- if entityType == nil then
27228
+ if entityTypeString == nil or variantString == nil then
27222
27229
  return nil
27223
27230
  end
27224
- local variant = tonumber(variantString)
27225
- if variant == nil then
27231
+ local entityType = parseIntSafe(nil, entityTypeString)
27232
+ local variant = parseIntSafe(nil, variantString)
27233
+ if entityType == nil or variant == nil then
27226
27234
  return nil
27227
27235
  end
27228
27236
  return {entityType, variant}
@@ -27479,6 +27487,7 @@ local ____sprites = require("functions.sprites")
27479
27487
  local clearSprite = ____sprites.clearSprite
27480
27488
  local spriteEquals = ____sprites.spriteEquals
27481
27489
  local ____types = require("functions.types")
27490
+ local asCollectibleType = ____types.asCollectibleType
27482
27491
  local isInteger = ____types.isInteger
27483
27492
  local ____utils = require("functions.utils")
27484
27493
  local assertDefined = ____utils.assertDefined
@@ -27856,7 +27865,8 @@ function ____exports.isSingleUseCollectible(self, collectibleType)
27856
27865
  return SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES_SET:has(collectibleType)
27857
27866
  end
27858
27867
  function ____exports.isValidCollectibleType(self, collectibleType)
27859
- local itemConfigItem = itemConfig:GetCollectible(collectibleType)
27868
+ local potentialCollectibleType = asCollectibleType(nil, collectibleType)
27869
+ local itemConfigItem = itemConfig:GetCollectible(potentialCollectibleType)
27860
27870
  return itemConfigItem ~= nil
27861
27871
  end
27862
27872
  --- Helper function to generate a new sprite based on a collectible. If the provided collectible type
@@ -33164,6 +33174,7 @@ local ____rooms = require("functions.rooms")
33164
33174
  local roomUpdateSafe = ____rooms.roomUpdateSafe
33165
33175
  local ____types = require("functions.types")
33166
33176
  local isInteger = ____types.isInteger
33177
+ local parseIntSafe = ____types.parseIntSafe
33167
33178
  local ____utils = require("functions.utils")
33168
33179
  local assertDefined = ____utils.assertDefined
33169
33180
  local eRange = ____utils.eRange
@@ -33666,21 +33677,15 @@ end
33666
33677
  function ____exports.getConstituentsFromGridEntityID(self, gridEntityID)
33667
33678
  local parts = __TS__StringSplit(gridEntityID, ".")
33668
33679
  if #parts ~= 2 then
33669
- error("Failed to get the constituents from grid entity ID: " .. gridEntityID)
33680
+ error("Failed to get the constituents from a grid entity ID: " .. gridEntityID)
33670
33681
  end
33671
33682
  local gridEntityTypeString, variantString = table.unpack(parts)
33672
- local gridEntityType = tonumber(gridEntityTypeString)
33673
- assertDefined(
33674
- nil,
33675
- gridEntityType,
33676
- "Failed to convert the grid entity type to a number: " .. tostring(gridEntityTypeString)
33677
- )
33678
- local variant = tonumber(variantString)
33679
- assertDefined(
33680
- nil,
33681
- variant,
33682
- "Failed to convert the grid entity variant to a number: " .. tostring(variantString)
33683
- )
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)
33684
33689
  return {gridEntityType, variant}
33685
33690
  end
33686
33691
  --- Helper function to get every grid entity in the current room.
@@ -36559,6 +36564,7 @@ local ____sprites = require("functions.sprites")
36559
36564
  local clearSprite = ____sprites.clearSprite
36560
36565
  local ____types = require("functions.types")
36561
36566
  local asNumber = ____types.asNumber
36567
+ local asTrinketType = ____types.asTrinketType
36562
36568
  function ____exports.isGoldenTrinketType(self, trinketType)
36563
36569
  return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
36564
36570
  end
@@ -36661,6 +36667,11 @@ end
36661
36667
  function ____exports.isModdedTrinketType(self, trinketType)
36662
36668
  return not ____exports.isVanillaTrinketType(nil, trinketType)
36663
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
36664
36675
  --- Helper function to generate a new sprite based on a collectible. If the provided collectible type
36665
36676
  -- is invalid, a sprite with a Curse of the Blind question mark will be returned.
36666
36677
  function ____exports.newTrinketSprite(self, trinketType)
@@ -38589,6 +38600,7 @@ local PILL_EFFECT_TYPES = ____pillEffectTypes.PILL_EFFECT_TYPES
38589
38600
  local ____types = require("functions.types")
38590
38601
  local asNumber = ____types.asNumber
38591
38602
  local asPillColor = ____types.asPillColor
38603
+ local asPillEffect = ____types.asPillEffect
38592
38604
  local ____utils = require("functions.utils")
38593
38605
  local iRange = ____utils.iRange
38594
38606
  --- Helper function to see if the given pill color is a horse pill.
@@ -38711,6 +38723,11 @@ end
38711
38723
  function ____exports.isModdedPillEffect(self, pillEffect)
38712
38724
  return not ____exports.isVanillaPillEffect(nil, pillEffect)
38713
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
38714
38731
  return ____exports
38715
38732
  end,
38716
38733
  ["interfaces.PocketItemDescription"] = function(...)
@@ -40242,13 +40259,12 @@ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
40242
40259
  local ____exports = {}
40243
40260
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.index")
40244
40261
  local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
40262
+ local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
40245
40263
  local SeedEffect = ____isaac_2Dtypescript_2Ddefinitions.SeedEffect
40246
40264
  local ____cachedEnumValues = require("arrays.cachedEnumValues")
40247
40265
  local SEED_EFFECTS = ____cachedEnumValues.SEED_EFFECTS
40248
40266
  local ____cachedClasses = require("core.cachedClasses")
40249
40267
  local game = ____cachedClasses.game
40250
- local ____constantsFirstLast = require("core.constantsFirstLast")
40251
- local FIRST_CHARACTER = ____constantsFirstLast.FIRST_CHARACTER
40252
40268
  local ____characters = require("functions.characters")
40253
40269
  local getCharacterName = ____characters.getCharacterName
40254
40270
  local ____log = require("functions.log")
@@ -40312,7 +40328,7 @@ function ____exports.restart(self, character)
40312
40328
  Isaac.ExecuteCommand(command)
40313
40329
  return
40314
40330
  end
40315
- if character < FIRST_CHARACTER then
40331
+ if character < PlayerType.ISAAC then
40316
40332
  error(("Restarting as a character of " .. tostring(character)) .. " would crash the game.")
40317
40333
  end
40318
40334
  local command = "restart " .. tostring(character)
@@ -44093,6 +44109,8 @@ local ____itemConfigCardTypesForCards = require("sets.itemConfigCardTypesForCard
44093
44109
  local ITEM_CONFIG_CARD_TYPES_FOR_CARDS = ____itemConfigCardTypesForCards.ITEM_CONFIG_CARD_TYPES_FOR_CARDS
44094
44110
  local ____flag = require("functions.flag")
44095
44111
  local addFlag = ____flag.addFlag
44112
+ local ____types = require("functions.types")
44113
+ local asCardType = ____types.asCardType
44096
44114
  function ____exports.isVanillaCardType(self, cardType)
44097
44115
  return cardType <= LAST_VANILLA_CARD_TYPE
44098
44116
  end
@@ -44202,6 +44220,11 @@ end
44202
44220
  function ____exports.isTarotCard(self, cardType)
44203
44221
  return ____exports.isCardType(nil, cardType, ItemConfigCardType.TAROT)
44204
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
44205
44228
  --- Helper function to use a card without showing an animation and without the announcer voice
44206
44229
  -- playing.
44207
44230
  function ____exports.useCardTemp(self, player, cardType)
@@ -53965,6 +53988,8 @@ local ____log = require("functions.log")
53965
53988
  local log = ____log.log
53966
53989
  local ____random = require("functions.random")
53967
53990
  local getRandomFloat = ____random.getRandomFloat
53991
+ local ____types = require("functions.types")
53992
+ local parseIntSafe = ____types.parseIntSafe
53968
53993
  local ____utils = require("functions.utils")
53969
53994
  local assertDefined = ____utils.assertDefined
53970
53995
  function getTotalWeightOfJSONObject(self, jsonOjectArray)
@@ -54006,7 +54031,7 @@ end
54006
54031
  -- (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
54007
54032
  function ____exports.getJSONRoomDoorSlotFlags(self, jsonRoom)
54008
54033
  local roomShapeString = jsonRoom["$"].shape
54009
- local roomShape = tonumber(roomShapeString)
54034
+ local roomShape = parseIntSafe(nil, roomShapeString)
54010
54035
  assertDefined(nil, roomShape, "Failed to parse the \"shape\" field of a JSON room: " .. roomShapeString)
54011
54036
  if not isEnumValue(nil, roomShape, RoomShape) then
54012
54037
  error("Failed to parse the \"shape\" field of a JSON room since it was an invalid number: " .. tostring(roomShape))
@@ -54022,10 +54047,10 @@ function ____exports.getJSONRoomDoorSlotFlags(self, jsonRoom)
54022
54047
  goto __continue4
54023
54048
  end
54024
54049
  local xString = door["$"].x
54025
- local x = tonumber(xString)
54050
+ local x = parseIntSafe(nil, xString)
54026
54051
  assertDefined(nil, x, "Failed to parse the \"x\" field of a JSON room door: " .. xString)
54027
54052
  local yString = door["$"].y
54028
- local y = tonumber(yString)
54053
+ local y = parseIntSafe(nil, yString)
54029
54054
  assertDefined(nil, y, "Failed to parse the \"y\" field of a JSON room door: " .. yString)
54030
54055
  local doorSlot = getRoomShapeDoorSlot(nil, roomShape, x, y)
54031
54056
  assertDefined(
@@ -54052,7 +54077,10 @@ function ____exports.getJSONRoomOfVariant(self, jsonRooms, variant)
54052
54077
  jsonRooms,
54053
54078
  function(____, jsonRoom)
54054
54079
  local roomVariantString = jsonRoom["$"].variant
54055
- 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
54056
54084
  return roomVariant == variant
54057
54085
  end
54058
54086
  )
@@ -54075,7 +54103,10 @@ function ____exports.getJSONRoomsOfSubType(self, jsonRooms, subType)
54075
54103
  jsonRooms,
54076
54104
  function(____, jsonRoom)
54077
54105
  local roomSubTypeString = jsonRoom["$"].subtype
54078
- 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
54079
54110
  return roomSubType == subType
54080
54111
  end
54081
54112
  )
@@ -54601,6 +54632,7 @@ local ____spawnCollectible = require("functions.spawnCollectible")
54601
54632
  local spawnCollectible = ____spawnCollectible.spawnCollectible
54602
54633
  local ____types = require("functions.types")
54603
54634
  local asCollectibleType = ____types.asCollectibleType
54635
+ local parseIntSafe = ____types.parseIntSafe
54604
54636
  local ____utils = require("functions.utils")
54605
54637
  local assertDefined = ____utils.assertDefined
54606
54638
  local ____ReadonlySet = require("types.ReadonlySet")
@@ -54754,28 +54786,28 @@ function DeployJSONRoom.prototype.spawnAllEntities(self, jsonRoom, rng, verbose)
54754
54786
  local shouldUnclearRoom = false
54755
54787
  for ____, jsonSpawn in ipairs(jsonRoom.spawn) do
54756
54788
  local xString = jsonSpawn["$"].x
54757
- local x = tonumber(xString)
54758
- 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)
54759
54791
  local yString = jsonSpawn["$"].y
54760
- local y = tonumber(yString)
54761
- 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)
54762
54794
  local jsonEntity = getRandomJSONEntity(nil, jsonSpawn.entity, rng)
54763
54795
  local entityTypeString = jsonEntity["$"].type
54764
- local entityTypeNumber = tonumber(entityTypeString)
54765
- 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)
54766
54798
  local variantString = jsonEntity["$"].variant
54767
- local variant = tonumber(variantString)
54799
+ local variant = parseIntSafe(nil, variantString)
54768
54800
  assertDefined(
54769
54801
  nil,
54770
54802
  variant,
54771
- "Failed to convert the entity variant to a number: " .. tostring(variant)
54803
+ "Failed to convert the entity variant to an integer: " .. tostring(variant)
54772
54804
  )
54773
54805
  local subTypeString = jsonEntity["$"].subtype
54774
- local subType = tonumber(subTypeString)
54806
+ local subType = parseIntSafe(nil, subTypeString)
54775
54807
  assertDefined(
54776
54808
  nil,
54777
54809
  subType,
54778
- "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)
54779
54811
  )
54780
54812
  local isGridEntity = GRID_ENTITY_XML_TYPE_SET:has(entityTypeNumber)
54781
54813
  if isGridEntity then
@@ -57980,6 +58012,7 @@ local ITEM_POOL_TYPE_VALUES = ____cachedEnumValues.ITEM_POOL_TYPE_VALUES
57980
58012
  local itemPoolsJSON = require("data.itempools")
57981
58013
  local ____types = require("functions.types")
57982
58014
  local asCollectibleType = ____types.asCollectibleType
58015
+ local parseIntSafe = ____types.parseIntSafe
57983
58016
  local ____itemPoolTypeToItemPoolName = require("maps.itemPoolTypeToItemPoolName")
57984
58017
  local ITEM_POOL_TYPE_TO_ITEM_POOL_NAME = ____itemPoolTypeToItemPoolName.ITEM_POOL_TYPE_TO_ITEM_POOL_NAME
57985
58018
  function getItemPoolJSON(self, itemPoolType)
@@ -57999,11 +58032,11 @@ ____exports.ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET = (function()
57999
58032
  else
58000
58033
  local collectibleTypesSet = __TS__New(Set)
58001
58034
  for ____, itemPoolJSONElement in ipairs(itemPoolJSON.Item) do
58002
- local collectibleTypeNumber = tonumber(itemPoolJSONElement["$"].Id)
58003
- if collectibleTypeNumber == nil then
58035
+ local collectibleTypeInt = parseIntSafe(nil, itemPoolJSONElement["$"].Id)
58036
+ if collectibleTypeInt == nil then
58004
58037
  error("Failed to parse a collectible type in the \"itempools.json\" file: " .. itemPoolJSONElement["$"].Id)
58005
58038
  end
58006
- local collectibleType = asCollectibleType(nil, collectibleTypeNumber)
58039
+ local collectibleType = asCollectibleType(nil, collectibleTypeInt)
58007
58040
  collectibleTypesSet:add(collectibleType)
58008
58041
  end
58009
58042
  itemPoolTypeToCollectibleTypes[itemPoolType] = collectibleTypesSet
@@ -59855,13 +59888,15 @@ local getRoomData = ____roomData.getRoomData
59855
59888
  local getRoomDescriptor = ____roomData.getRoomDescriptor
59856
59889
  local ____rooms = require("functions.rooms")
59857
59890
  local changeRoom = ____rooms.changeRoom
59891
+ local ____types = require("functions.types")
59892
+ local parseIntSafe = ____types.parseIntSafe
59858
59893
  local ____roomTypeNames = require("objects.roomTypeNames")
59859
59894
  local ROOM_TYPE_NAMES = ____roomTypeNames.ROOM_TYPE_NAMES
59860
59895
  local DEFAULT_MOVE_UNITS = 0.5
59861
59896
  function ____exports.addHeart(self, params, healthType)
59862
59897
  local numHearts = healthType == HealthType.MAX_HEARTS and 2 or 1
59863
59898
  if params ~= "" then
59864
- local num = tonumber(params)
59899
+ local num = parseIntSafe(nil, params)
59865
59900
  if num == nil then
59866
59901
  print("That is an invalid amount of hearts to add.")
59867
59902
  return
@@ -59892,7 +59927,7 @@ end
59892
59927
  function ____exports.listEntities(self, params, includeBackgroundEffects)
59893
59928
  local entityTypeFilter
59894
59929
  if params ~= "" then
59895
- entityTypeFilter = tonumber(params)
59930
+ entityTypeFilter = parseIntSafe(nil, params)
59896
59931
  if entityTypeFilter == nil then
59897
59932
  print("That is an invalid entity type to filter by.")
59898
59933
  return
@@ -59904,7 +59939,7 @@ end
59904
59939
  function ____exports.listGridEntities(self, params, includeWalls)
59905
59940
  local gridEntityTypeFilter
59906
59941
  if params ~= "" then
59907
- gridEntityTypeFilter = tonumber(params)
59942
+ gridEntityTypeFilter = parseIntSafe(nil, params)
59908
59943
  if gridEntityTypeFilter == nil then
59909
59944
  print("That is an invalid grid entity type to filter by.")
59910
59945
  return
@@ -59916,7 +59951,7 @@ end
59916
59951
  function ____exports.movePlayer(self, params, direction)
59917
59952
  local amount = DEFAULT_MOVE_UNITS
59918
59953
  if params ~= "" then
59919
- local num = tonumber(params)
59954
+ local num = parseIntSafe(nil, params)
59920
59955
  if num == nil then
59921
59956
  print("That is an invalid amount of units to move.")
59922
59957
  return
@@ -59997,7 +60032,6 @@ return ____exports
59997
60032
  local ____lualib = require("lualib_bundle")
59998
60033
  local __TS__StringSplit = ____lualib.__TS__StringSplit
59999
60034
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
60000
- local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
60001
60035
  local ____exports = {}
60002
60036
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.index")
60003
60037
  local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
@@ -60012,10 +60046,11 @@ local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
60012
60046
  local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
60013
60047
  local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
60014
60048
  local PillColor = ____isaac_2Dtypescript_2Ddefinitions.PillColor
60049
+ local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
60015
60050
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
60051
+ local SoundEffect = ____isaac_2Dtypescript_2Ddefinitions.SoundEffect
60016
60052
  local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
60017
60053
  local ____cachedEnumValues = require("arrays.cachedEnumValues")
60018
- local ACTIVE_SLOT_VALUES = ____cachedEnumValues.ACTIVE_SLOT_VALUES
60019
60054
  local GRID_ENTITY_TYPE_VALUES = ____cachedEnumValues.GRID_ENTITY_TYPE_VALUES
60020
60055
  local ____cachedClasses = require("core.cachedClasses")
60021
60056
  local game = ____cachedClasses.game
@@ -60026,21 +60061,14 @@ local MAX_LEVEL_GRID_INDEX = ____constants.MAX_LEVEL_GRID_INDEX
60026
60061
  local MAX_NUM_FAMILIARS = ____constants.MAX_NUM_FAMILIARS
60027
60062
  local ____constantsFirstLast = require("core.constantsFirstLast")
60028
60063
  local FIRST_CARD_TYPE = ____constantsFirstLast.FIRST_CARD_TYPE
60029
- local FIRST_CHARACTER = ____constantsFirstLast.FIRST_CHARACTER
60030
60064
  local FIRST_HORSE_PILL_COLOR = ____constantsFirstLast.FIRST_HORSE_PILL_COLOR
60031
60065
  local FIRST_PILL_COLOR = ____constantsFirstLast.FIRST_PILL_COLOR
60032
- local FIRST_PILL_EFFECT = ____constantsFirstLast.FIRST_PILL_EFFECT
60033
- local FIRST_ROOM_TYPE = ____constantsFirstLast.FIRST_ROOM_TYPE
60034
- local FIRST_STAGE = ____constantsFirstLast.FIRST_STAGE
60035
- local LAST_ROOM_TYPE = ____constantsFirstLast.LAST_ROOM_TYPE
60036
- local LAST_STAGE = ____constantsFirstLast.LAST_STAGE
60037
60066
  local LAST_VANILLA_CARD_TYPE = ____constantsFirstLast.LAST_VANILLA_CARD_TYPE
60038
- local LAST_VANILLA_CHARACTER = ____constantsFirstLast.LAST_VANILLA_CHARACTER
60039
- local LAST_VANILLA_PILL_EFFECT = ____constantsFirstLast.LAST_VANILLA_PILL_EFFECT
60040
60067
  local ____HealthType = require("enums.HealthType")
60041
60068
  local HealthType = ____HealthType.HealthType
60042
60069
  local ____cards = require("functions.cards")
60043
60070
  local getCardName = ____cards.getCardName
60071
+ local isValidCardType = ____cards.isValidCardType
60044
60072
  local ____characters = require("functions.characters")
60045
60073
  local getCharacterName = ____characters.getCharacterName
60046
60074
  local ____charge = require("functions.charge")
@@ -60054,6 +60082,8 @@ local ____deepCopyTests = require("functions.deepCopyTests")
60054
60082
  local runDeepCopyTests = ____deepCopyTests.runDeepCopyTests
60055
60083
  local ____entitiesSpecific = require("functions.entitiesSpecific")
60056
60084
  local getNPCs = ____entitiesSpecific.getNPCs
60085
+ local ____enums = require("functions.enums")
60086
+ local isEnumValue = ____enums.isEnumValue
60057
60087
  local ____flag = require("functions.flag")
60058
60088
  local addFlag = ____flag.addFlag
60059
60089
  local ____gridEntities = require("functions.gridEntities")
@@ -60074,6 +60104,7 @@ local spawnPill = ____pickupsSpecific.spawnPill
60074
60104
  local spawnTrinketFunction = ____pickupsSpecific.spawnTrinket
60075
60105
  local ____pills = require("functions.pills")
60076
60106
  local getPillEffectName = ____pills.getPillEffectName
60107
+ local isValidPillEffect = ____pills.isValidPillEffect
60077
60108
  local ____playerCollectibles = require("functions.playerCollectibles")
60078
60109
  local addCollectibleCostume = ____playerCollectibles.addCollectibleCostume
60079
60110
  local removeCollectibleCostume = ____playerCollectibles.removeCollectibleCostume
@@ -60103,9 +60134,9 @@ local ____string = require("functions.string")
60103
60134
  local getMapPartialMatch = ____string.getMapPartialMatch
60104
60135
  local ____trinkets = require("functions.trinkets")
60105
60136
  local getGoldenTrinketType = ____trinkets.getGoldenTrinketType
60137
+ local isValidTrinketType = ____trinkets.isValidTrinketType
60106
60138
  local ____types = require("functions.types")
60107
- local asCollectibleType = ____types.asCollectibleType
60108
- local asTrinketType = ____types.asTrinketType
60139
+ local parseIntSafe = ____types.parseIntSafe
60109
60140
  local ____utils = require("functions.utils")
60110
60141
  local iRange = ____utils.iRange
60111
60142
  local ____cardNameToTypeMap = require("maps.cardNameToTypeMap")
@@ -60201,9 +60232,9 @@ end
60201
60232
  function ____exports.poopMana(self, params)
60202
60233
  local charges = 1
60203
60234
  if params ~= "" then
60204
- local num = tonumber(params)
60235
+ local num = parseIntSafe(nil, params)
60205
60236
  if num == nil then
60206
- print("That is an invalid amount of mana to add.")
60237
+ print("Invalid mana amount: " .. tostring(num))
60207
60238
  return
60208
60239
  end
60209
60240
  charges = num
@@ -60216,9 +60247,9 @@ end
60216
60247
  -- For example:
60217
60248
  -- - sound 1 - Plays the 1-Up sound effect.
60218
60249
  function ____exports.sound(self, params)
60219
- local soundEffect = tonumber(params)
60220
- if soundEffect == nil then
60221
- 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)) .. ".")
60222
60253
  return
60223
60254
  end
60224
60255
  sfxManager:Play(soundEffect)
@@ -60239,9 +60270,9 @@ function ____exports.spawnCollectible(self, params)
60239
60270
  print("You must specify the collectible name or the number corresponding to the collectible type.")
60240
60271
  return
60241
60272
  end
60242
- local collectibleTypeNumber = tonumber(params)
60273
+ local num = parseIntSafe(nil, params)
60243
60274
  local collectibleType
60244
- if collectibleTypeNumber == nil then
60275
+ if num == nil then
60245
60276
  local match = getMapPartialMatch(nil, params, COLLECTIBLE_NAME_TO_TYPE_MAP)
60246
60277
  if match == nil then
60247
60278
  print("Unknown collectible: " .. params)
@@ -60249,7 +60280,10 @@ function ____exports.spawnCollectible(self, params)
60249
60280
  end
60250
60281
  collectibleType = match[2]
60251
60282
  else
60252
- collectibleType = asCollectibleType(nil, collectibleTypeNumber)
60283
+ if not isValidCollectibleType(nil, num) then
60284
+ print("Invalid collectible type: " .. tostring(num))
60285
+ end
60286
+ collectibleType = num
60253
60287
  end
60254
60288
  local roomClass = game:GetRoom()
60255
60289
  local centerPos = roomClass:GetCenterPos()
@@ -60281,9 +60315,9 @@ function ____exports.spawnTrinket(self, params, golden)
60281
60315
  print("You must specify the name or number corresponding to the trinket type.")
60282
60316
  return
60283
60317
  end
60284
- local trinketTypeNumber = tonumber(params)
60318
+ local num = parseIntSafe(nil, params)
60285
60319
  local trinketType
60286
- if trinketTypeNumber == nil then
60320
+ if num == nil then
60287
60321
  local match = getMapPartialMatch(nil, params, TRINKET_NAME_TO_TYPE_MAP)
60288
60322
  if match == nil then
60289
60323
  print("Unknown trinket: " .. params)
@@ -60291,7 +60325,11 @@ function ____exports.spawnTrinket(self, params, golden)
60291
60325
  end
60292
60326
  trinketType = match[2]
60293
60327
  else
60294
- 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
60295
60333
  end
60296
60334
  local roomClass = game:GetRoom()
60297
60335
  local centerPos = roomClass:GetCenterPos()
@@ -60323,17 +60361,20 @@ function ____exports.spawnTrinketAt(self, params, golden)
60323
60361
  print("You must specify the number corresponding to the trinket type and the number corresponding to the grid tile location.")
60324
60362
  return
60325
60363
  end
60326
- local trinketTypeNumber = tonumber(args[1])
60327
- if trinketTypeNumber == nil or trinketTypeNumber < 0 then
60328
- 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)
60329
60371
  return
60330
60372
  end
60331
- local gridIndex = tonumber(args[2])
60373
+ local gridIndex = parseIntSafe(nil, gridIndexString)
60332
60374
  if gridIndex == nil or gridIndex < 0 then
60333
60375
  print("Failed to parse the grid index of: " .. tostring(args[2]))
60334
60376
  return
60335
60377
  end
60336
- local trinketType = asTrinketType(nil, trinketTypeNumber)
60337
60378
  local goldenTrinketType = getGoldenTrinketType(nil, trinketType)
60338
60379
  local trinketTypeToSpawn = golden and goldenTrinketType or trinketType
60339
60380
  spawnTrinketFunction(nil, trinketTypeToSpawn, gridIndex)
@@ -60354,24 +60395,23 @@ function ____exports.addCharges(self, params)
60354
60395
  end
60355
60396
  local args = __TS__StringSplit(params, " ")
60356
60397
  if #args ~= 1 and #args ~= 2 then
60357
- print("That is an invalid amount of arguments.")
60398
+ print("Invalid amount of arguments: " .. tostring(#args))
60358
60399
  return
60359
60400
  end
60360
60401
  local activeSlotString, numChargeString = table.unpack(args)
60361
- local activeSlot = tonumber(activeSlotString)
60362
- if activeSlot == nil then
60363
- print("The provided slot number is invalid: " .. tostring(activeSlotString))
60402
+ if activeSlotString == nil then
60364
60403
  return
60365
60404
  end
60366
- if activeSlot < ActiveSlot.PRIMARY or activeSlot > ActiveSlot.POCKET_SINGLE_USE then
60367
- 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))
60368
60408
  return
60369
60409
  end
60370
60410
  local numCharges = 1
60371
60411
  if numChargeString ~= nil then
60372
- local numChargesAttempt = tonumber(numChargeString)
60412
+ local numChargesAttempt = parseIntSafe(nil, numChargeString)
60373
60413
  if numChargesAttempt == nil then
60374
- print("The provided charge amount is invalid: " .. numChargeString)
60414
+ print("Invalid charge amount: " .. numChargeString)
60375
60415
  return
60376
60416
  end
60377
60417
  numCharges = numChargesAttempt
@@ -60423,9 +60463,9 @@ end
60423
60463
  function ____exports.bloodCharges(self, params)
60424
60464
  local charges = 1
60425
60465
  if params ~= "" then
60426
- local num = tonumber(params)
60466
+ local num = parseIntSafe(nil, params)
60427
60467
  if num == nil then
60428
- print("That is an invalid amount of charges to add.")
60468
+ print("Invalid charge amount: " .. tostring(num))
60429
60469
  return
60430
60470
  end
60431
60471
  charges = num
@@ -60442,9 +60482,9 @@ end
60442
60482
  function ____exports.bomb(self, params)
60443
60483
  local numBombs = 1
60444
60484
  if params ~= "" then
60445
- local num = tonumber(params)
60485
+ local num = parseIntSafe(nil, params)
60446
60486
  if num == nil then
60447
- print("That is an invalid amount of bombs to add.")
60487
+ print("Invalid bomb amount: " .. tostring(num))
60448
60488
  return
60449
60489
  end
60450
60490
  numBombs = num
@@ -60457,9 +60497,9 @@ end
60457
60497
  function ____exports.bombs(self, params)
60458
60498
  local numBombs = 99
60459
60499
  if params ~= "" then
60460
- local num = tonumber(params)
60500
+ local num = parseIntSafe(nil, params)
60461
60501
  if num == nil then
60462
- print("That is an invalid amount of bombs to add.")
60502
+ print("Invalid bomb amount: " .. tostring(num))
60463
60503
  return
60464
60504
  end
60465
60505
  numBombs = num
@@ -60489,7 +60529,7 @@ end
60489
60529
  function ____exports.brokenHearts(self, params)
60490
60530
  addHeart(nil, params, HealthType.BROKEN)
60491
60531
  end
60492
- --- 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.
60493
60533
  --
60494
60534
  -- For example:
60495
60535
  -- - card 5 - Gives The Emperor.
@@ -60500,7 +60540,7 @@ function ____exports.card(self, params)
60500
60540
  return
60501
60541
  end
60502
60542
  local cardType
60503
- local num = tonumber(params)
60543
+ local num = parseIntSafe(nil, params)
60504
60544
  if num == nil then
60505
60545
  local match = getMapPartialMatch(nil, params, CARD_NAME_TO_TYPE_MAP)
60506
60546
  if match == nil then
@@ -60509,8 +60549,8 @@ function ____exports.card(self, params)
60509
60549
  end
60510
60550
  cardType = match[2]
60511
60551
  else
60512
- if num < FIRST_CARD_TYPE or num > LAST_VANILLA_CARD_TYPE then
60513
- print("Invalid card sub-type: " .. tostring(num))
60552
+ if not isValidCardType(nil, num) then
60553
+ print("Invalid card type: " .. tostring(num))
60514
60554
  return
60515
60555
  end
60516
60556
  cardType = num
@@ -60557,7 +60597,7 @@ function ____exports.character(self, params)
60557
60597
  return
60558
60598
  end
60559
60599
  local playerType
60560
- local num = tonumber(params)
60600
+ local num = parseIntSafe(nil, params)
60561
60601
  if num == nil then
60562
60602
  local match = getMapPartialMatch(nil, params, CHARACTER_NAME_TO_TYPE_MAP)
60563
60603
  if match == nil then
@@ -60566,7 +60606,7 @@ function ____exports.character(self, params)
60566
60606
  end
60567
60607
  playerType = match[2]
60568
60608
  else
60569
- if num < FIRST_CHARACTER or num > LAST_VANILLA_CHARACTER then
60609
+ if not isEnumValue(nil, num, PlayerType) or num == PlayerType.POSSESSOR then
60570
60610
  print("Invalid character number: " .. tostring(num))
60571
60611
  return
60572
60612
  end
@@ -60589,9 +60629,9 @@ end
60589
60629
  function ____exports.coin(self, params)
60590
60630
  local numCoins = 1
60591
60631
  if params ~= "" then
60592
- local num = tonumber(params)
60632
+ local num = parseIntSafe(nil, params)
60593
60633
  if num == nil then
60594
- print("That is an invalid amount of coins to add.")
60634
+ print("Invalid coin amount: " .. tostring(num))
60595
60635
  return
60596
60636
  end
60597
60637
  numCoins = num
@@ -60604,9 +60644,9 @@ end
60604
60644
  function ____exports.coins(self, params)
60605
60645
  local numCoins = 999
60606
60646
  if params ~= "" then
60607
- local num = tonumber(params)
60647
+ local num = parseIntSafe(nil, params)
60608
60648
  if num == nil then
60609
- print("That is an invalid amount of coins to add.")
60649
+ print("Invalid coin amount: " .. tostring(num))
60610
60650
  return
60611
60651
  end
60612
60652
  numCoins = num
@@ -60649,7 +60689,7 @@ function ____exports.damage(self, params)
60649
60689
  if params ~= "" then
60650
60690
  local num = tonumber(params)
60651
60691
  if num == nil then
60652
- print("The provided damage amount is invalid: " .. params)
60692
+ print("Invalid damage amount: " .. params)
60653
60693
  return
60654
60694
  end
60655
60695
  v.persistent.damageAmount = num
@@ -60745,9 +60785,9 @@ end
60745
60785
  function ____exports.getCharge(self, params)
60746
60786
  local activeSlot = ActiveSlot.PRIMARY
60747
60787
  if params ~= "" then
60748
- local num = tonumber(params)
60749
- if num == nil then
60750
- 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)
60751
60791
  return
60752
60792
  end
60753
60793
  activeSlot = num
@@ -60773,9 +60813,9 @@ end
60773
60813
  function ____exports.gigaBomb(self, params)
60774
60814
  local numBombs = 1
60775
60815
  if params ~= "" then
60776
- local num = tonumber(params)
60816
+ local num = parseIntSafe(nil, params)
60777
60817
  if num == nil then
60778
- print("That is an invalid amount of Giga Bombs to add.")
60818
+ print("Invalid Giga Bomb amount: " .. tostring(num))
60779
60819
  return
60780
60820
  end
60781
60821
  numBombs = num
@@ -60854,9 +60894,9 @@ end
60854
60894
  function ____exports.key(self, params)
60855
60895
  local numKeys = 1
60856
60896
  if params ~= "" then
60857
- local num = tonumber(params)
60897
+ local num = parseIntSafe(nil, params)
60858
60898
  if num == nil then
60859
- print("That is an invalid amount of keys to add.")
60899
+ print("Invalid key amount: " .. tostring(num))
60860
60900
  return
60861
60901
  end
60862
60902
  numKeys = num
@@ -60869,9 +60909,9 @@ end
60869
60909
  function ____exports.keys(self, params)
60870
60910
  local numKeys = 99
60871
60911
  if params ~= "" then
60872
- local num = tonumber(params)
60912
+ local num = parseIntSafe(nil, params)
60873
60913
  if num == nil then
60874
- print("That is an invalid amount of keys to add.")
60914
+ print("Invalid key amount: " .. tostring(num))
60875
60915
  return
60876
60916
  end
60877
60917
  numKeys = num
@@ -60981,7 +61021,7 @@ function ____exports.pill(self, params)
60981
61021
  return
60982
61022
  end
60983
61023
  local pillEffect
60984
- local num = tonumber(params)
61024
+ local num = parseIntSafe(nil, params)
60985
61025
  if num == nil then
60986
61026
  local match = getMapPartialMatch(nil, params, PILL_NAME_TO_EFFECT_MAP)
60987
61027
  if match == nil then
@@ -60990,7 +61030,7 @@ function ____exports.pill(self, params)
60990
61030
  end
60991
61031
  pillEffect = match[2]
60992
61032
  else
60993
- if num < FIRST_PILL_EFFECT or num > LAST_VANILLA_PILL_EFFECT then
61033
+ if not isValidPillEffect(nil, num) then
60994
61034
  print("Invalid pill effect ID: " .. tostring(num))
60995
61035
  return
60996
61036
  end
@@ -61052,13 +61092,9 @@ function ____exports.pocket(self, params)
61052
61092
  print("You must supply a collectible type to put as the pocket item.")
61053
61093
  return
61054
61094
  end
61055
- local collectibleType = tonumber(params)
61056
- if collectibleType == nil then
61057
- print("That is an invalid collectible type.")
61058
- return
61059
- end
61060
- if not isValidCollectibleType(nil, collectibleType) then
61061
- 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))
61062
61098
  return
61063
61099
  end
61064
61100
  local player = Isaac.GetPlayer()
@@ -61126,13 +61162,9 @@ function ____exports.s(self, params)
61126
61162
  stageString = params
61127
61163
  stageTypeLetter = ""
61128
61164
  end
61129
- local stage = tonumber(stageString)
61130
- if stage == nil then
61131
- print("That is an invalid stage number: " .. tostring(stage))
61132
- return
61133
- end
61134
- if stage < FIRST_STAGE or stage > LAST_STAGE then
61135
- 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))
61136
61168
  return
61137
61169
  end
61138
61170
  Isaac.ExecuteCommand(("stage " .. tostring(stage)) .. stageTypeLetter)
@@ -61174,26 +61206,25 @@ function ____exports.setCharges(self, params)
61174
61206
  return
61175
61207
  end
61176
61208
  if #args ~= 2 then
61177
- print("That is an invalid amount of arguments.")
61209
+ print("Invalid amount of arguments: " .. tostring(#args))
61178
61210
  return
61179
61211
  end
61180
61212
  local activeSlotString, chargeString = table.unpack(args)
61181
- local activeSlot = tonumber(activeSlotString)
61182
- if activeSlot == nil then
61183
- print("The provided slot number is invalid: " .. tostring(activeSlotString))
61213
+ if activeSlotString == nil or chargeString == nil then
61184
61214
  return
61185
61215
  end
61186
- if not __TS__ArrayIncludes(ACTIVE_SLOT_VALUES, activeSlot) then
61187
- 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)
61188
61219
  return
61189
61220
  end
61190
- local chargeNum = tonumber(chargeString)
61221
+ local chargeNum = parseIntSafe(nil, chargeString)
61191
61222
  if chargeNum == nil then
61192
- print("The provided charge amount is invalid: " .. tostring(chargeString))
61223
+ print("Invalid charge amount: " .. chargeString)
61193
61224
  return
61194
61225
  end
61195
61226
  if chargeNum < 0 then
61196
- print("The provided charge amount is invalid: " .. tostring(chargeNum))
61227
+ print("Invalid charge amount: " .. tostring(chargeNum))
61197
61228
  return
61198
61229
  end
61199
61230
  local player = Isaac.GetPlayer()
@@ -61214,14 +61245,17 @@ function ____exports.setPosition(self, params)
61214
61245
  return
61215
61246
  end
61216
61247
  local xString, yString = table.unpack(args)
61217
- local x = tonumber(xString)
61248
+ if xString == nil or yString == nil then
61249
+ return
61250
+ end
61251
+ local x = parseIntSafe(nil, xString)
61218
61252
  if x == nil then
61219
- print("That is an invalid x value: " .. tostring(xString))
61253
+ print("Invalid x value: " .. xString)
61220
61254
  return
61221
61255
  end
61222
- local y = tonumber(yString)
61256
+ local y = parseIntSafe(nil, yString)
61223
61257
  if y == nil then
61224
- print("That is an invalid y value: " .. tostring(yString))
61258
+ print("Invalid y value: " .. yString)
61225
61259
  return
61226
61260
  end
61227
61261
  local player = Isaac.GetPlayer()
@@ -61242,9 +61276,9 @@ end
61242
61276
  function ____exports.soulCharges(self, params)
61243
61277
  local charges = 1
61244
61278
  if params ~= "" then
61245
- local num = tonumber(params)
61279
+ local num = parseIntSafe(nil, params)
61246
61280
  if num == nil then
61247
- print("That is an invalid amount of charges to add.")
61281
+ print("Invalid charges amount: " .. tostring(num))
61248
61282
  return
61249
61283
  end
61250
61284
  charges = num
@@ -61289,17 +61323,20 @@ function ____exports.spawnCollectibleAt(self, params)
61289
61323
  print("You must specify the number corresponding to the collectible type and the number corresponding to the grid tile location.")
61290
61324
  return
61291
61325
  end
61292
- local collectibleTypeNumber = tonumber(args[1])
61293
- if collectibleTypeNumber == nil or collectibleTypeNumber < 0 then
61294
- 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
61295
61328
  return
61296
61329
  end
61297
- 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)
61298
61336
  if gridIndex == nil or gridIndex < 0 then
61299
61337
  print("Failed to parse the grid index of: " .. tostring(args[2]))
61300
61338
  return
61301
61339
  end
61302
- local collectibleType = asCollectibleType(nil, collectibleTypeNumber)
61303
61340
  spawnCollectibleFunc(nil, collectibleType, gridIndex, nil)
61304
61341
  end
61305
61342
  --- Alias for the `spawnGoldenTrinket` command.
@@ -61319,7 +61356,7 @@ function ____exports.speed(self, params)
61319
61356
  if params ~= "" then
61320
61357
  local num = tonumber(params)
61321
61358
  if num == nil then
61322
- print("The provided speed amount is invalid: " .. params)
61359
+ print("Invalid speed amount: " .. params)
61323
61360
  return
61324
61361
  end
61325
61362
  v.persistent.damageAmount = num
@@ -61353,7 +61390,7 @@ function ____exports.tears(self, params)
61353
61390
  if params ~= "" then
61354
61391
  local num = tonumber(params)
61355
61392
  if num == nil then
61356
- print("The provided tear delay amount is invalid: " .. params)
61393
+ print("Invalid tear delay amount: " .. params)
61357
61394
  return
61358
61395
  end
61359
61396
  v.persistent.tearsAmount = num
@@ -61414,7 +61451,7 @@ function ____exports.warp(self, params)
61414
61451
  return
61415
61452
  end
61416
61453
  local roomType
61417
- local num = tonumber(params)
61454
+ local num = parseIntSafe(nil, params)
61418
61455
  if num == nil then
61419
61456
  local match = getMapPartialMatch(nil, params, ROOM_NAME_TO_TYPE_MAP)
61420
61457
  if match == nil then
@@ -61423,7 +61460,7 @@ function ____exports.warp(self, params)
61423
61460
  end
61424
61461
  roomType = match[2]
61425
61462
  else
61426
- if num < FIRST_ROOM_TYPE or num > LAST_ROOM_TYPE then
61463
+ if not isEnumValue(nil, num, RoomType) then
61427
61464
  print("Invalid room type: " .. tostring(num))
61428
61465
  return
61429
61466
  end
@@ -63404,12 +63441,16 @@ local getFeatures = ____features.getFeatures
63404
63441
  local ____debugFunctions = require("functions.debugFunctions")
63405
63442
  local getElapsedTimeSince = ____debugFunctions.getElapsedTimeSince
63406
63443
  local getTime = ____debugFunctions.getTime
63444
+ local ____enums = require("functions.enums")
63445
+ local isEnumValue = ____enums.isEnumValue
63407
63446
  local ____log = require("functions.log")
63408
63447
  local getParentFunctionDescription = ____log.getParentFunctionDescription
63409
63448
  local log = ____log.log
63410
63449
  local ____tstlClass = require("functions.tstlClass")
63411
63450
  local getTSTLClassConstructor = ____tstlClass.getTSTLClassConstructor
63412
63451
  local getTSTLClassName = ____tstlClass.getTSTLClassName
63452
+ local ____types = require("functions.types")
63453
+ local parseIntSafe = ____types.parseIntSafe
63413
63454
  local ____utils = require("functions.utils")
63414
63455
  local assertDefined = ____utils.assertDefined
63415
63456
  function getExportedMethodsFromFeature(self, featureClass)
@@ -63528,9 +63569,12 @@ function ModUpgraded.prototype.logUsedFeatures(self)
63528
63569
  if callbackClass.numConsumers == 0 then
63529
63570
  goto __continue19
63530
63571
  end
63531
- local modCallbackCustom = tonumber(modCallbackCustomString)
63532
- assertDefined(nil, modCallbackCustom, "Failed to convert an index on the callbacks object to a number.")
63533
- 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)) .. ")")
63534
63578
  end
63535
63579
  ::__continue19::
63536
63580
  end
@@ -63539,13 +63583,16 @@ function ModUpgraded.prototype.logUsedFeatures(self)
63539
63583
  local featureClass = ____value[2]
63540
63584
  do
63541
63585
  if featureClass.numConsumers == 0 then
63542
- 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.")
63543
63592
  end
63544
- local iscFeature = tonumber(iscFeatureString)
63545
- assertDefined(nil, iscFeature, "Failed to convert an index on the features object to a number.")
63546
- log(((("- ISCFeature." .. tostring(ISCFeature[iscFeature])) .. " (") .. tostring(iscFeature)) .. ")")
63593
+ log(((("- ISCFeature." .. ISCFeature[iscFeature]) .. " (") .. tostring(iscFeature)) .. ")")
63547
63594
  end
63548
- ::__continue22::
63595
+ ::__continue23::
63549
63596
  end
63550
63597
  end
63551
63598
  function ModUpgraded.prototype.initFeature(self, feature)