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,7 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__StringSplit = ____lualib.__TS__StringSplit
3
3
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
4
- local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
5
4
  local ____exports = {}
6
5
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
6
  local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
@@ -16,10 +15,11 @@ local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
16
15
  local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
17
16
  local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
18
17
  local PillColor = ____isaac_2Dtypescript_2Ddefinitions.PillColor
18
+ local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
19
19
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
20
+ local SoundEffect = ____isaac_2Dtypescript_2Ddefinitions.SoundEffect
20
21
  local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
21
22
  local ____cachedEnumValues = require("arrays.cachedEnumValues")
22
- local ACTIVE_SLOT_VALUES = ____cachedEnumValues.ACTIVE_SLOT_VALUES
23
23
  local GRID_ENTITY_TYPE_VALUES = ____cachedEnumValues.GRID_ENTITY_TYPE_VALUES
24
24
  local ____cachedClasses = require("core.cachedClasses")
25
25
  local game = ____cachedClasses.game
@@ -30,21 +30,14 @@ local MAX_LEVEL_GRID_INDEX = ____constants.MAX_LEVEL_GRID_INDEX
30
30
  local MAX_NUM_FAMILIARS = ____constants.MAX_NUM_FAMILIARS
31
31
  local ____constantsFirstLast = require("core.constantsFirstLast")
32
32
  local FIRST_CARD_TYPE = ____constantsFirstLast.FIRST_CARD_TYPE
33
- local FIRST_CHARACTER = ____constantsFirstLast.FIRST_CHARACTER
34
33
  local FIRST_HORSE_PILL_COLOR = ____constantsFirstLast.FIRST_HORSE_PILL_COLOR
35
34
  local FIRST_PILL_COLOR = ____constantsFirstLast.FIRST_PILL_COLOR
36
- local FIRST_PILL_EFFECT = ____constantsFirstLast.FIRST_PILL_EFFECT
37
- local FIRST_ROOM_TYPE = ____constantsFirstLast.FIRST_ROOM_TYPE
38
- local FIRST_STAGE = ____constantsFirstLast.FIRST_STAGE
39
- local LAST_ROOM_TYPE = ____constantsFirstLast.LAST_ROOM_TYPE
40
- local LAST_STAGE = ____constantsFirstLast.LAST_STAGE
41
35
  local LAST_VANILLA_CARD_TYPE = ____constantsFirstLast.LAST_VANILLA_CARD_TYPE
42
- local LAST_VANILLA_CHARACTER = ____constantsFirstLast.LAST_VANILLA_CHARACTER
43
- local LAST_VANILLA_PILL_EFFECT = ____constantsFirstLast.LAST_VANILLA_PILL_EFFECT
44
36
  local ____HealthType = require("enums.HealthType")
45
37
  local HealthType = ____HealthType.HealthType
46
38
  local ____cards = require("functions.cards")
47
39
  local getCardName = ____cards.getCardName
40
+ local isValidCardType = ____cards.isValidCardType
48
41
  local ____characters = require("functions.characters")
49
42
  local getCharacterName = ____characters.getCharacterName
50
43
  local ____charge = require("functions.charge")
@@ -58,6 +51,8 @@ local ____deepCopyTests = require("functions.deepCopyTests")
58
51
  local runDeepCopyTests = ____deepCopyTests.runDeepCopyTests
59
52
  local ____entitiesSpecific = require("functions.entitiesSpecific")
60
53
  local getNPCs = ____entitiesSpecific.getNPCs
54
+ local ____enums = require("functions.enums")
55
+ local isEnumValue = ____enums.isEnumValue
61
56
  local ____flag = require("functions.flag")
62
57
  local addFlag = ____flag.addFlag
63
58
  local ____gridEntities = require("functions.gridEntities")
@@ -78,6 +73,7 @@ local spawnPill = ____pickupsSpecific.spawnPill
78
73
  local spawnTrinketFunction = ____pickupsSpecific.spawnTrinket
79
74
  local ____pills = require("functions.pills")
80
75
  local getPillEffectName = ____pills.getPillEffectName
76
+ local isValidPillEffect = ____pills.isValidPillEffect
81
77
  local ____playerCollectibles = require("functions.playerCollectibles")
82
78
  local addCollectibleCostume = ____playerCollectibles.addCollectibleCostume
83
79
  local removeCollectibleCostume = ____playerCollectibles.removeCollectibleCostume
@@ -107,9 +103,9 @@ local ____string = require("functions.string")
107
103
  local getMapPartialMatch = ____string.getMapPartialMatch
108
104
  local ____trinkets = require("functions.trinkets")
109
105
  local getGoldenTrinketType = ____trinkets.getGoldenTrinketType
106
+ local isValidTrinketType = ____trinkets.isValidTrinketType
110
107
  local ____types = require("functions.types")
111
- local asCollectibleType = ____types.asCollectibleType
112
- local asTrinketType = ____types.asTrinketType
108
+ local parseIntSafe = ____types.parseIntSafe
113
109
  local ____utils = require("functions.utils")
114
110
  local iRange = ____utils.iRange
115
111
  local ____cardNameToTypeMap = require("maps.cardNameToTypeMap")
@@ -205,9 +201,9 @@ end
205
201
  function ____exports.poopMana(self, params)
206
202
  local charges = 1
207
203
  if params ~= "" then
208
- local num = tonumber(params)
204
+ local num = parseIntSafe(nil, params)
209
205
  if num == nil then
210
- print("That is an invalid amount of mana to add.")
206
+ print("Invalid mana amount: " .. tostring(num))
211
207
  return
212
208
  end
213
209
  charges = num
@@ -220,9 +216,9 @@ end
220
216
  -- For example:
221
217
  -- - sound 1 - Plays the 1-Up sound effect.
222
218
  function ____exports.sound(self, params)
223
- local soundEffect = tonumber(params)
224
- if soundEffect == nil then
225
- print("That is an invalid sound effect ID.")
219
+ local soundEffect = parseIntSafe(nil, params)
220
+ if soundEffect == nil or not isEnumValue(nil, soundEffect, SoundEffect) then
221
+ print(("Invalid sound effect ID: " .. tostring(soundEffect)) .. ".")
226
222
  return
227
223
  end
228
224
  sfxManager:Play(soundEffect)
@@ -243,9 +239,9 @@ function ____exports.spawnCollectible(self, params)
243
239
  print("You must specify the collectible name or the number corresponding to the collectible type.")
244
240
  return
245
241
  end
246
- local collectibleTypeNumber = tonumber(params)
242
+ local num = parseIntSafe(nil, params)
247
243
  local collectibleType
248
- if collectibleTypeNumber == nil then
244
+ if num == nil then
249
245
  local match = getMapPartialMatch(nil, params, COLLECTIBLE_NAME_TO_TYPE_MAP)
250
246
  if match == nil then
251
247
  print("Unknown collectible: " .. params)
@@ -253,7 +249,10 @@ function ____exports.spawnCollectible(self, params)
253
249
  end
254
250
  collectibleType = match[2]
255
251
  else
256
- collectibleType = asCollectibleType(nil, collectibleTypeNumber)
252
+ if not isValidCollectibleType(nil, num) then
253
+ print("Invalid collectible type: " .. tostring(num))
254
+ end
255
+ collectibleType = num
257
256
  end
258
257
  local roomClass = game:GetRoom()
259
258
  local centerPos = roomClass:GetCenterPos()
@@ -285,9 +284,9 @@ function ____exports.spawnTrinket(self, params, golden)
285
284
  print("You must specify the name or number corresponding to the trinket type.")
286
285
  return
287
286
  end
288
- local trinketTypeNumber = tonumber(params)
287
+ local num = parseIntSafe(nil, params)
289
288
  local trinketType
290
- if trinketTypeNumber == nil then
289
+ if num == nil then
291
290
  local match = getMapPartialMatch(nil, params, TRINKET_NAME_TO_TYPE_MAP)
292
291
  if match == nil then
293
292
  print("Unknown trinket: " .. params)
@@ -295,7 +294,11 @@ function ____exports.spawnTrinket(self, params, golden)
295
294
  end
296
295
  trinketType = match[2]
297
296
  else
298
- trinketType = asTrinketType(nil, trinketTypeNumber)
297
+ if not isValidTrinketType(nil, num) then
298
+ print("Invalid trinket type: " .. tostring(num))
299
+ return
300
+ end
301
+ trinketType = num
299
302
  end
300
303
  local roomClass = game:GetRoom()
301
304
  local centerPos = roomClass:GetCenterPos()
@@ -327,17 +330,20 @@ function ____exports.spawnTrinketAt(self, params, golden)
327
330
  print("You must specify the number corresponding to the trinket type and the number corresponding to the grid tile location.")
328
331
  return
329
332
  end
330
- local trinketTypeNumber = tonumber(args[1])
331
- if trinketTypeNumber == nil or trinketTypeNumber < 0 then
332
- print("Failed to parse the trinket type of: " .. tostring(args[1]))
333
+ local trinketTypeString, gridIndexString = table.unpack(args)
334
+ if trinketTypeString == nil or gridIndexString == nil then
335
+ return
336
+ end
337
+ local trinketType = parseIntSafe(nil, trinketTypeString)
338
+ if trinketType == nil or not isValidTrinketType(nil, trinketType) then
339
+ print("Invalid trinket type: " .. trinketTypeString)
333
340
  return
334
341
  end
335
- local gridIndex = tonumber(args[2])
342
+ local gridIndex = parseIntSafe(nil, gridIndexString)
336
343
  if gridIndex == nil or gridIndex < 0 then
337
344
  print("Failed to parse the grid index of: " .. tostring(args[2]))
338
345
  return
339
346
  end
340
- local trinketType = asTrinketType(nil, trinketTypeNumber)
341
347
  local goldenTrinketType = getGoldenTrinketType(nil, trinketType)
342
348
  local trinketTypeToSpawn = golden and goldenTrinketType or trinketType
343
349
  spawnTrinketFunction(nil, trinketTypeToSpawn, gridIndex)
@@ -358,24 +364,23 @@ function ____exports.addCharges(self, params)
358
364
  end
359
365
  local args = __TS__StringSplit(params, " ")
360
366
  if #args ~= 1 and #args ~= 2 then
361
- print("That is an invalid amount of arguments.")
367
+ print("Invalid amount of arguments: " .. tostring(#args))
362
368
  return
363
369
  end
364
370
  local activeSlotString, numChargeString = table.unpack(args)
365
- local activeSlot = tonumber(activeSlotString)
366
- if activeSlot == nil then
367
- print("The provided slot number is invalid: " .. tostring(activeSlotString))
371
+ if activeSlotString == nil then
368
372
  return
369
373
  end
370
- if activeSlot < ActiveSlot.PRIMARY or activeSlot > ActiveSlot.POCKET_SINGLE_USE then
371
- print("The provided slot number is invalid: " .. tostring(activeSlot))
374
+ local activeSlot = parseIntSafe(nil, activeSlotString)
375
+ if activeSlot == nil or not isEnumValue(nil, activeSlot, ActiveSlot) then
376
+ print("Invalid slot number: " .. tostring(activeSlot))
372
377
  return
373
378
  end
374
379
  local numCharges = 1
375
380
  if numChargeString ~= nil then
376
- local numChargesAttempt = tonumber(numChargeString)
381
+ local numChargesAttempt = parseIntSafe(nil, numChargeString)
377
382
  if numChargesAttempt == nil then
378
- print("The provided charge amount is invalid: " .. numChargeString)
383
+ print("Invalid charge amount: " .. numChargeString)
379
384
  return
380
385
  end
381
386
  numCharges = numChargesAttempt
@@ -427,9 +432,9 @@ end
427
432
  function ____exports.bloodCharges(self, params)
428
433
  local charges = 1
429
434
  if params ~= "" then
430
- local num = tonumber(params)
435
+ local num = parseIntSafe(nil, params)
431
436
  if num == nil then
432
- print("That is an invalid amount of charges to add.")
437
+ print("Invalid charge amount: " .. tostring(num))
433
438
  return
434
439
  end
435
440
  charges = num
@@ -446,9 +451,9 @@ end
446
451
  function ____exports.bomb(self, params)
447
452
  local numBombs = 1
448
453
  if params ~= "" then
449
- local num = tonumber(params)
454
+ local num = parseIntSafe(nil, params)
450
455
  if num == nil then
451
- print("That is an invalid amount of bombs to add.")
456
+ print("Invalid bomb amount: " .. tostring(num))
452
457
  return
453
458
  end
454
459
  numBombs = num
@@ -461,9 +466,9 @@ end
461
466
  function ____exports.bombs(self, params)
462
467
  local numBombs = 99
463
468
  if params ~= "" then
464
- local num = tonumber(params)
469
+ local num = parseIntSafe(nil, params)
465
470
  if num == nil then
466
- print("That is an invalid amount of bombs to add.")
471
+ print("Invalid bomb amount: " .. tostring(num))
467
472
  return
468
473
  end
469
474
  numBombs = num
@@ -493,7 +498,7 @@ end
493
498
  function ____exports.brokenHearts(self, params)
494
499
  addHeart(nil, params, HealthType.BROKEN)
495
500
  end
496
- --- Gives the specified card. Accepts either the card sub-type or the partial name of the card.
501
+ --- Gives the specified card. Accepts either the card type or the partial name of the card.
497
502
  --
498
503
  -- For example:
499
504
  -- - card 5 - Gives The Emperor.
@@ -504,7 +509,7 @@ function ____exports.card(self, params)
504
509
  return
505
510
  end
506
511
  local cardType
507
- local num = tonumber(params)
512
+ local num = parseIntSafe(nil, params)
508
513
  if num == nil then
509
514
  local match = getMapPartialMatch(nil, params, CARD_NAME_TO_TYPE_MAP)
510
515
  if match == nil then
@@ -513,8 +518,8 @@ function ____exports.card(self, params)
513
518
  end
514
519
  cardType = match[2]
515
520
  else
516
- if num < FIRST_CARD_TYPE or num > LAST_VANILLA_CARD_TYPE then
517
- print("Invalid card sub-type: " .. tostring(num))
521
+ if not isValidCardType(nil, num) then
522
+ print("Invalid card type: " .. tostring(num))
518
523
  return
519
524
  end
520
525
  cardType = num
@@ -561,7 +566,7 @@ function ____exports.character(self, params)
561
566
  return
562
567
  end
563
568
  local playerType
564
- local num = tonumber(params)
569
+ local num = parseIntSafe(nil, params)
565
570
  if num == nil then
566
571
  local match = getMapPartialMatch(nil, params, CHARACTER_NAME_TO_TYPE_MAP)
567
572
  if match == nil then
@@ -570,7 +575,7 @@ function ____exports.character(self, params)
570
575
  end
571
576
  playerType = match[2]
572
577
  else
573
- if num < FIRST_CHARACTER or num > LAST_VANILLA_CHARACTER then
578
+ if not isEnumValue(nil, num, PlayerType) or num == PlayerType.POSSESSOR then
574
579
  print("Invalid character number: " .. tostring(num))
575
580
  return
576
581
  end
@@ -593,9 +598,9 @@ end
593
598
  function ____exports.coin(self, params)
594
599
  local numCoins = 1
595
600
  if params ~= "" then
596
- local num = tonumber(params)
601
+ local num = parseIntSafe(nil, params)
597
602
  if num == nil then
598
- print("That is an invalid amount of coins to add.")
603
+ print("Invalid coin amount: " .. tostring(num))
599
604
  return
600
605
  end
601
606
  numCoins = num
@@ -608,9 +613,9 @@ end
608
613
  function ____exports.coins(self, params)
609
614
  local numCoins = 999
610
615
  if params ~= "" then
611
- local num = tonumber(params)
616
+ local num = parseIntSafe(nil, params)
612
617
  if num == nil then
613
- print("That is an invalid amount of coins to add.")
618
+ print("Invalid coin amount: " .. tostring(num))
614
619
  return
615
620
  end
616
621
  numCoins = num
@@ -653,7 +658,7 @@ function ____exports.damage(self, params)
653
658
  if params ~= "" then
654
659
  local num = tonumber(params)
655
660
  if num == nil then
656
- print("The provided damage amount is invalid: " .. params)
661
+ print("Invalid damage amount: " .. params)
657
662
  return
658
663
  end
659
664
  v.persistent.damageAmount = num
@@ -749,9 +754,9 @@ end
749
754
  function ____exports.getCharge(self, params)
750
755
  local activeSlot = ActiveSlot.PRIMARY
751
756
  if params ~= "" then
752
- local num = tonumber(params)
753
- if num == nil then
754
- print("The provided slot number is invalid: " .. params)
757
+ local num = parseIntSafe(nil, params)
758
+ if num == nil or not isEnumValue(nil, num, ActiveSlot) then
759
+ print("Invalid slot number: " .. params)
755
760
  return
756
761
  end
757
762
  activeSlot = num
@@ -777,9 +782,9 @@ end
777
782
  function ____exports.gigaBomb(self, params)
778
783
  local numBombs = 1
779
784
  if params ~= "" then
780
- local num = tonumber(params)
785
+ local num = parseIntSafe(nil, params)
781
786
  if num == nil then
782
- print("That is an invalid amount of Giga Bombs to add.")
787
+ print("Invalid Giga Bomb amount: " .. tostring(num))
783
788
  return
784
789
  end
785
790
  numBombs = num
@@ -858,9 +863,9 @@ end
858
863
  function ____exports.key(self, params)
859
864
  local numKeys = 1
860
865
  if params ~= "" then
861
- local num = tonumber(params)
866
+ local num = parseIntSafe(nil, params)
862
867
  if num == nil then
863
- print("That is an invalid amount of keys to add.")
868
+ print("Invalid key amount: " .. tostring(num))
864
869
  return
865
870
  end
866
871
  numKeys = num
@@ -873,9 +878,9 @@ end
873
878
  function ____exports.keys(self, params)
874
879
  local numKeys = 99
875
880
  if params ~= "" then
876
- local num = tonumber(params)
881
+ local num = parseIntSafe(nil, params)
877
882
  if num == nil then
878
- print("That is an invalid amount of keys to add.")
883
+ print("Invalid key amount: " .. tostring(num))
879
884
  return
880
885
  end
881
886
  numKeys = num
@@ -985,7 +990,7 @@ function ____exports.pill(self, params)
985
990
  return
986
991
  end
987
992
  local pillEffect
988
- local num = tonumber(params)
993
+ local num = parseIntSafe(nil, params)
989
994
  if num == nil then
990
995
  local match = getMapPartialMatch(nil, params, PILL_NAME_TO_EFFECT_MAP)
991
996
  if match == nil then
@@ -994,7 +999,7 @@ function ____exports.pill(self, params)
994
999
  end
995
1000
  pillEffect = match[2]
996
1001
  else
997
- if num < FIRST_PILL_EFFECT or num > LAST_VANILLA_PILL_EFFECT then
1002
+ if not isValidPillEffect(nil, num) then
998
1003
  print("Invalid pill effect ID: " .. tostring(num))
999
1004
  return
1000
1005
  end
@@ -1056,13 +1061,9 @@ function ____exports.pocket(self, params)
1056
1061
  print("You must supply a collectible type to put as the pocket item.")
1057
1062
  return
1058
1063
  end
1059
- local collectibleType = tonumber(params)
1060
- if collectibleType == nil then
1061
- print("That is an invalid collectible type.")
1062
- return
1063
- end
1064
- if not isValidCollectibleType(nil, collectibleType) then
1065
- print("That is an invalid collectible type.")
1064
+ local collectibleType = parseIntSafe(nil, params)
1065
+ if collectibleType == nil or not isValidCollectibleType(nil, collectibleType) then
1066
+ print("Invalid collectible type: " .. tostring(collectibleType))
1066
1067
  return
1067
1068
  end
1068
1069
  local player = Isaac.GetPlayer()
@@ -1130,13 +1131,9 @@ function ____exports.s(self, params)
1130
1131
  stageString = params
1131
1132
  stageTypeLetter = ""
1132
1133
  end
1133
- local stage = tonumber(stageString)
1134
- if stage == nil then
1135
- print("That is an invalid stage number: " .. tostring(stage))
1136
- return
1137
- end
1138
- if stage < FIRST_STAGE or stage > LAST_STAGE then
1139
- print(((("Invalid stage number; must be between " .. tostring(FIRST_STAGE)) .. " and ") .. tostring(LAST_STAGE)) .. ".")
1134
+ local stage = parseIntSafe(nil, stageString)
1135
+ if stage == nil or not isEnumValue(nil, stage, StageType) then
1136
+ print("Invalid stage number: " .. tostring(stage))
1140
1137
  return
1141
1138
  end
1142
1139
  Isaac.ExecuteCommand(("stage " .. tostring(stage)) .. stageTypeLetter)
@@ -1178,26 +1175,25 @@ function ____exports.setCharges(self, params)
1178
1175
  return
1179
1176
  end
1180
1177
  if #args ~= 2 then
1181
- print("That is an invalid amount of arguments.")
1178
+ print("Invalid amount of arguments: " .. tostring(#args))
1182
1179
  return
1183
1180
  end
1184
1181
  local activeSlotString, chargeString = table.unpack(args)
1185
- local activeSlot = tonumber(activeSlotString)
1186
- if activeSlot == nil then
1187
- print("The provided slot number is invalid: " .. tostring(activeSlotString))
1182
+ if activeSlotString == nil or chargeString == nil then
1188
1183
  return
1189
1184
  end
1190
- if not __TS__ArrayIncludes(ACTIVE_SLOT_VALUES, activeSlot) then
1191
- print("The provided slot number is invalid: " .. tostring(activeSlot))
1185
+ local activeSlot = parseIntSafe(nil, activeSlotString)
1186
+ if activeSlot == nil or not isEnumValue(nil, activeSlot, ActiveSlot) then
1187
+ print("Invalid slot number: " .. activeSlotString)
1192
1188
  return
1193
1189
  end
1194
- local chargeNum = tonumber(chargeString)
1190
+ local chargeNum = parseIntSafe(nil, chargeString)
1195
1191
  if chargeNum == nil then
1196
- print("The provided charge amount is invalid: " .. tostring(chargeString))
1192
+ print("Invalid charge amount: " .. chargeString)
1197
1193
  return
1198
1194
  end
1199
1195
  if chargeNum < 0 then
1200
- print("The provided charge amount is invalid: " .. tostring(chargeNum))
1196
+ print("Invalid charge amount: " .. tostring(chargeNum))
1201
1197
  return
1202
1198
  end
1203
1199
  local player = Isaac.GetPlayer()
@@ -1218,14 +1214,17 @@ function ____exports.setPosition(self, params)
1218
1214
  return
1219
1215
  end
1220
1216
  local xString, yString = table.unpack(args)
1221
- local x = tonumber(xString)
1217
+ if xString == nil or yString == nil then
1218
+ return
1219
+ end
1220
+ local x = parseIntSafe(nil, xString)
1222
1221
  if x == nil then
1223
- print("That is an invalid x value: " .. tostring(xString))
1222
+ print("Invalid x value: " .. xString)
1224
1223
  return
1225
1224
  end
1226
- local y = tonumber(yString)
1225
+ local y = parseIntSafe(nil, yString)
1227
1226
  if y == nil then
1228
- print("That is an invalid y value: " .. tostring(yString))
1227
+ print("Invalid y value: " .. yString)
1229
1228
  return
1230
1229
  end
1231
1230
  local player = Isaac.GetPlayer()
@@ -1246,9 +1245,9 @@ end
1246
1245
  function ____exports.soulCharges(self, params)
1247
1246
  local charges = 1
1248
1247
  if params ~= "" then
1249
- local num = tonumber(params)
1248
+ local num = parseIntSafe(nil, params)
1250
1249
  if num == nil then
1251
- print("That is an invalid amount of charges to add.")
1250
+ print("Invalid charges amount: " .. tostring(num))
1252
1251
  return
1253
1252
  end
1254
1253
  charges = num
@@ -1293,17 +1292,20 @@ function ____exports.spawnCollectibleAt(self, params)
1293
1292
  print("You must specify the number corresponding to the collectible type and the number corresponding to the grid tile location.")
1294
1293
  return
1295
1294
  end
1296
- local collectibleTypeNumber = tonumber(args[1])
1297
- if collectibleTypeNumber == nil or collectibleTypeNumber < 0 then
1298
- print("Failed to parse the collectible type of: " .. tostring(args[1]))
1295
+ local collectibleTypeString, gridIndexString = table.unpack(args)
1296
+ if collectibleTypeString == nil or gridIndexString == nil then
1297
+ return
1298
+ end
1299
+ local collectibleType = parseIntSafe(nil, collectibleTypeString)
1300
+ if collectibleType == nil or not isValidCollectibleType(nil, collectibleType) then
1301
+ print("Invalid collectible type: " .. tostring(args[1]))
1299
1302
  return
1300
1303
  end
1301
- local gridIndex = tonumber(args[2])
1304
+ local gridIndex = parseIntSafe(nil, gridIndexString)
1302
1305
  if gridIndex == nil or gridIndex < 0 then
1303
1306
  print("Failed to parse the grid index of: " .. tostring(args[2]))
1304
1307
  return
1305
1308
  end
1306
- local collectibleType = asCollectibleType(nil, collectibleTypeNumber)
1307
1309
  spawnCollectibleFunc(nil, collectibleType, gridIndex, nil)
1308
1310
  end
1309
1311
  --- Alias for the `spawnGoldenTrinket` command.
@@ -1323,7 +1325,7 @@ function ____exports.speed(self, params)
1323
1325
  if params ~= "" then
1324
1326
  local num = tonumber(params)
1325
1327
  if num == nil then
1326
- print("The provided speed amount is invalid: " .. params)
1328
+ print("Invalid speed amount: " .. params)
1327
1329
  return
1328
1330
  end
1329
1331
  v.persistent.damageAmount = num
@@ -1357,7 +1359,7 @@ function ____exports.tears(self, params)
1357
1359
  if params ~= "" then
1358
1360
  local num = tonumber(params)
1359
1361
  if num == nil then
1360
- print("The provided tear delay amount is invalid: " .. params)
1362
+ print("Invalid tear delay amount: " .. params)
1361
1363
  return
1362
1364
  end
1363
1365
  v.persistent.tearsAmount = num
@@ -1418,7 +1420,7 @@ function ____exports.warp(self, params)
1418
1420
  return
1419
1421
  end
1420
1422
  local roomType
1421
- local num = tonumber(params)
1423
+ local num = parseIntSafe(nil, params)
1422
1424
  if num == nil then
1423
1425
  local match = getMapPartialMatch(nil, params, ROOM_NAME_TO_TYPE_MAP)
1424
1426
  if match == nil then
@@ -1427,7 +1429,7 @@ function ____exports.warp(self, params)
1427
1429
  end
1428
1430
  roomType = match[2]
1429
1431
  else
1430
- if num < FIRST_ROOM_TYPE or num > LAST_ROOM_TYPE then
1432
+ if not isEnumValue(nil, num, RoomType) then
1431
1433
  print("Invalid room type: " .. tostring(num))
1432
1434
  return
1433
1435
  end
@@ -1 +1 @@
1
- {"version":3,"file":"subroutines.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/extraConsoleCommands/subroutines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAGL,QAAQ,EACT,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAkB1D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAcrE;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAqBlD;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,wBAAwB,EAAE,OAAO,GAChC,IAAI,CAYN;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI,CAY5E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAgBrE;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CASjE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAWvD;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAuB3D"}
1
+ {"version":3,"file":"subroutines.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/extraConsoleCommands/subroutines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAGL,QAAQ,EACT,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAmB1D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAcrE;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAqBlD;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,wBAAwB,EAAE,OAAO,GAChC,IAAI,CAYN;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI,CAY5E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAgBrE;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CASjE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAWvD;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAuB3D"}
@@ -26,13 +26,15 @@ local getRoomData = ____roomData.getRoomData
26
26
  local getRoomDescriptor = ____roomData.getRoomDescriptor
27
27
  local ____rooms = require("functions.rooms")
28
28
  local changeRoom = ____rooms.changeRoom
29
+ local ____types = require("functions.types")
30
+ local parseIntSafe = ____types.parseIntSafe
29
31
  local ____roomTypeNames = require("objects.roomTypeNames")
30
32
  local ROOM_TYPE_NAMES = ____roomTypeNames.ROOM_TYPE_NAMES
31
33
  local DEFAULT_MOVE_UNITS = 0.5
32
34
  function ____exports.addHeart(self, params, healthType)
33
35
  local numHearts = healthType == HealthType.MAX_HEARTS and 2 or 1
34
36
  if params ~= "" then
35
- local num = tonumber(params)
37
+ local num = parseIntSafe(nil, params)
36
38
  if num == nil then
37
39
  print("That is an invalid amount of hearts to add.")
38
40
  return
@@ -63,7 +65,7 @@ end
63
65
  function ____exports.listEntities(self, params, includeBackgroundEffects)
64
66
  local entityTypeFilter
65
67
  if params ~= "" then
66
- entityTypeFilter = tonumber(params)
68
+ entityTypeFilter = parseIntSafe(nil, params)
67
69
  if entityTypeFilter == nil then
68
70
  print("That is an invalid entity type to filter by.")
69
71
  return
@@ -75,7 +77,7 @@ end
75
77
  function ____exports.listGridEntities(self, params, includeWalls)
76
78
  local gridEntityTypeFilter
77
79
  if params ~= "" then
78
- gridEntityTypeFilter = tonumber(params)
80
+ gridEntityTypeFilter = parseIntSafe(nil, params)
79
81
  if gridEntityTypeFilter == nil then
80
82
  print("That is an invalid grid entity type to filter by.")
81
83
  return
@@ -87,7 +89,7 @@ end
87
89
  function ____exports.movePlayer(self, params, direction)
88
90
  local amount = DEFAULT_MOVE_UNITS
89
91
  if params ~= "" then
90
- local num = tonumber(params)
92
+ local num = parseIntSafe(nil, params)
91
93
  if num == nil then
92
94
  print("That is an invalid amount of units to move.")
93
95
  return
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import { CardType, CollectibleType, LevelStage, PillColor, PillEffect, PlayerType, RoomType, TrinketType } from "isaac-typescript-definitions";
6
+ import { CardType, CollectibleType, PillColor, PillEffect, PlayerType, TrinketType } from "isaac-typescript-definitions";
7
7
  /** Equal to `CollectibleType.SAD_ONION`. */
8
8
  export declare const FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION;
9
9
  /**
@@ -28,25 +28,13 @@ export declare const LAST_VANILLA_TRINKET_TYPE: TrinketType;
28
28
  export declare const NUM_VANILLA_TRINKET_TYPES: number;
29
29
  /** Equal to `Card.FOOL`. */
30
30
  export declare const FIRST_CARD_TYPE = CardType.FOOL;
31
- /**
32
- * Calculated from the `CardType` enum.
33
- *
34
- * Note that this could be calculated from the length of the enum, because card types are
35
- * contiguous. However, we instead get the highest enum value to be safer and to make the code more
36
- * consistent with collectibles and trinkets.
37
- */
31
+ /** Calculated from the `CardType` enum. */
38
32
  export declare const LAST_VANILLA_CARD_TYPE: CardType;
39
33
  /** Calculated from the `Card` enum. `Card.NULL` is not included. */
40
34
  export declare const NUM_VANILLA_CARD_TYPES: number;
41
35
  /** Equal to `PillEffect.BAD_GAS`. */
42
36
  export declare const FIRST_PILL_EFFECT = PillEffect.BAD_GAS;
43
- /**
44
- * Calculated from the `PillEffect` enum.
45
- *
46
- * Note that this could be calculated from the length of the enum, because pill effects are
47
- * contiguous. However, we instead get the highest enum value to be safer and to make the code more
48
- * consistent with collectibles and trinkets.
49
- */
37
+ /** Calculated from the `PillEffect` enum. */
50
38
  export declare const LAST_VANILLA_PILL_EFFECT: PillEffect;
51
39
  /**
52
40
  * Calculated from the `PillEffect` enum. (There is no `PillEffect.NULL` in the custom enum, so we
@@ -74,18 +62,8 @@ export declare const LAST_HORSE_PILL_COLOR = PillColor.HORSE_WHITE_YELLOW;
74
62
  export declare const NUM_NORMAL_PILL_COLORS: number;
75
63
  /** Equal to `PlayerType.ISAAC`. */
76
64
  export declare const FIRST_CHARACTER = PlayerType.ISAAC;
77
- /**
78
- * Calculated from the `PlayerType` enum.
79
- *
80
- * Note that this could be calculated from the length of the enum, because characters are
81
- * contiguous. However, we instead get the highest enum value to be safer and to make the code more
82
- * consistent with collectibles and trinkets.
83
- */
65
+ /** Calculated from the `PlayerType` enum. */
84
66
  export declare const LAST_VANILLA_CHARACTER: PlayerType;
85
- export declare const FIRST_ROOM_TYPE = RoomType.DEFAULT;
86
- export declare const LAST_ROOM_TYPE: RoomType;
87
- export declare const FIRST_STAGE = LevelStage.BASEMENT_1;
88
- export declare const LAST_STAGE: LevelStage;
89
67
  /** Calculated from the `Challenge` enum. `Challenge.NULL` is not included. */
90
68
  export declare const NUM_VANILLA_CHALLENGES: number;
91
69
  //# sourceMappingURL=constantsFirstLast.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constantsFirstLast.d.ts","sourceRoot":"","sources":["../../src/core/constantsFirstLast.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,QAAQ,EAER,eAAe,EACf,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAQtC,4CAA4C;AAC5C,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE;;;;;GAK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