isaacscript-common 80.2.2 → 80.2.4

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 (69) 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/ModdedElementDetection.d.ts +0 -4
  5. package/dist/classes/features/other/ModdedElementDetection.d.ts.map +1 -1
  6. package/dist/classes/features/other/ModdedElementDetection.lua +12 -12
  7. package/dist/classes/features/other/extraConsoleCommands/commands.d.ts +1 -1
  8. package/dist/classes/features/other/extraConsoleCommands/commands.d.ts.map +1 -1
  9. package/dist/classes/features/other/extraConsoleCommands/commands.lua +104 -102
  10. package/dist/classes/features/other/extraConsoleCommands/subroutines.d.ts.map +1 -1
  11. package/dist/classes/features/other/extraConsoleCommands/subroutines.lua +6 -4
  12. package/dist/core/constantsFirstLast.d.ts +4 -26
  13. package/dist/core/constantsFirstLast.d.ts.map +1 -1
  14. package/dist/core/constantsFirstLast.lua +0 -18
  15. package/dist/functions/cards.d.ts +1 -0
  16. package/dist/functions/cards.d.ts.map +1 -1
  17. package/dist/functions/cards.lua +7 -0
  18. package/dist/functions/collectibles.d.ts +7 -3
  19. package/dist/functions/collectibles.d.ts.map +1 -1
  20. package/dist/functions/collectibles.lua +9 -3
  21. package/dist/functions/doors.d.ts.map +1 -1
  22. package/dist/functions/doors.lua +14 -4
  23. package/dist/functions/entities.d.ts.map +1 -1
  24. package/dist/functions/entities.lua +19 -30
  25. package/dist/functions/gridEntities.d.ts.map +1 -1
  26. package/dist/functions/gridEntities.lua +8 -13
  27. package/dist/functions/jsonRoom.d.ts.map +1 -1
  28. package/dist/functions/jsonRoom.lua +13 -5
  29. package/dist/functions/pills.d.ts +1 -0
  30. package/dist/functions/pills.d.ts.map +1 -1
  31. package/dist/functions/pills.lua +6 -0
  32. package/dist/functions/run.d.ts +1 -2
  33. package/dist/functions/run.d.ts.map +1 -1
  34. package/dist/functions/run.lua +2 -3
  35. package/dist/functions/string.d.ts.map +1 -1
  36. package/dist/functions/string.lua +5 -3
  37. package/dist/functions/table.d.ts +3 -2
  38. package/dist/functions/table.d.ts.map +1 -1
  39. package/dist/functions/table.lua +3 -2
  40. package/dist/functions/trinkets.d.ts +1 -0
  41. package/dist/functions/trinkets.d.ts.map +1 -1
  42. package/dist/functions/trinkets.lua +6 -0
  43. package/dist/functions/types.d.ts +9 -0
  44. package/dist/functions/types.d.ts.map +1 -1
  45. package/dist/functions/types.lua +17 -0
  46. package/dist/index.rollup.d.ts +29 -34
  47. package/dist/isaacscript-common.lua +270 -221
  48. package/dist/lualib_bundle.lua +5 -0
  49. package/dist/objects/itemPoolTypeToCollectibleTypesSet.lua +4 -3
  50. package/package.json +2 -2
  51. package/src/classes/ModUpgraded.ts +18 -4
  52. package/src/classes/features/other/DeployJSONRoom.ts +11 -11
  53. package/src/classes/features/other/ModdedElementDetection.ts +4 -6
  54. package/src/classes/features/other/extraConsoleCommands/commands.ts +124 -118
  55. package/src/classes/features/other/extraConsoleCommands/subroutines.ts +5 -4
  56. package/src/core/constantsFirstLast.ts +3 -37
  57. package/src/functions/cards.ts +7 -0
  58. package/src/functions/collectibles.ts +11 -6
  59. package/src/functions/doors.ts +8 -3
  60. package/src/functions/entities.ts +40 -19
  61. package/src/functions/gridEntities.ts +15 -5
  62. package/src/functions/jsonRoom.ts +18 -5
  63. package/src/functions/pills.ts +7 -1
  64. package/src/functions/run.ts +6 -4
  65. package/src/functions/string.ts +4 -3
  66. package/src/functions/table.ts +3 -2
  67. package/src/functions/trinkets.ts +9 -1
  68. package/src/functions/types.ts +25 -0
  69. package/src/objects/itemPoolTypeToCollectibleTypesSet.ts +4 -4
@@ -28,6 +28,7 @@ local ____sprites = require("functions.sprites")
28
28
  local clearSprite = ____sprites.clearSprite
29
29
  local ____types = require("functions.types")
30
30
  local asNumber = ____types.asNumber
31
+ local asTrinketType = ____types.asTrinketType
31
32
  function ____exports.isGoldenTrinketType(self, trinketType)
32
33
  return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
33
34
  end
@@ -130,6 +131,11 @@ end
130
131
  function ____exports.isModdedTrinketType(self, trinketType)
131
132
  return not ____exports.isVanillaTrinketType(nil, trinketType)
132
133
  end
134
+ function ____exports.isValidTrinketType(self, trinketType)
135
+ local potentialTrinketType = asTrinketType(nil, trinketType)
136
+ local itemConfigItem = itemConfig:GetTrinket(potentialTrinketType)
137
+ return itemConfigItem ~= nil
138
+ end
133
139
  --- Helper function to generate a new sprite based on a collectible. If the provided collectible type
134
140
  -- is invalid, a sprite with a Curse of the Blind question mark will be returned.
135
141
  function ____exports.newTrinketSprite(self, trinketType)
@@ -130,4 +130,13 @@ export declare function isPrimitive(variable: unknown): variable is boolean | nu
130
130
  export declare function isString(variable: unknown): variable is string;
131
131
  export declare function isTable(variable: unknown): variable is LuaMap<AnyNotNil, unknown>;
132
132
  export declare function isUserdata(variable: unknown): variable is LuaUserdata;
133
+ /**
134
+ * Helper function to convert a string to an integer. Returns undefined if the string is not an
135
+ * integer.
136
+ *
137
+ * Under the hood, this uses the built-in `tonumber` and `math.floor` functions.
138
+ *
139
+ * This is named `parseIntSafe` in order to match the helper function in `isaacscript-common-ts`.
140
+ */
141
+ export declare function parseIntSafe(string: string): int | undefined;
133
142
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/functions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,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AAG,GAAG,SAAS,CAe5D"}
@@ -119,4 +119,21 @@ end
119
119
  function ____exports.isUserdata(self, variable)
120
120
  return type(variable) == "userdata"
121
121
  end
122
+ --- Helper function to convert a string to an integer. Returns undefined if the string is not an
123
+ -- integer.
124
+ --
125
+ -- Under the hood, this uses the built-in `tonumber` and `math.floor` functions.
126
+ --
127
+ -- This is named `parseIntSafe` in order to match the helper function in `isaacscript-common-ts`.
128
+ function ____exports.parseIntSafe(self, ____string)
129
+ if not ____exports.isString(nil, ____string) then
130
+ return nil
131
+ end
132
+ local number = tonumber(____string)
133
+ if number == nil then
134
+ return nil
135
+ end
136
+ local flooredNumber = math.floor(number)
137
+ return number == flooredNumber and flooredNumber or nil
138
+ end
122
139
  return ____exports
@@ -4652,10 +4652,6 @@ export declare const FIRST_PILL_COLOR = PillColor.BLUE_BLUE;
4652
4652
  /** Equal to `PillEffect.BAD_GAS`. */
4653
4653
  export declare const FIRST_PILL_EFFECT = PillEffect.BAD_GAS;
4654
4654
 
4655
- export declare const FIRST_ROOM_TYPE = RoomType.DEFAULT;
4656
-
4657
- export declare const FIRST_STAGE = LevelStage.BASEMENT_1;
4658
-
4659
4655
  /** Equal to `TrinketType.SWALLOWED_PENNY`. */
4660
4656
  export declare const FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY;
4661
4657
 
@@ -5443,8 +5439,12 @@ export declare function getCollectibleDevilHeartPrice(collectibleOrCollectibleTy
5443
5439
  export declare function getCollectibleGfxFilename(collectibleOrCollectibleType: EntityPickup | CollectibleType | -1): string;
5444
5440
 
5445
5441
  /**
5446
- * Helper function to get the initial amount of charges that a collectible has. Returns 0 if the
5447
- * provided collectible type was not valid.
5442
+ * Helper function to get the initial amount of charges that a collectible has. In most cases, when
5443
+ * picking up an active collectible for the first time, it will be fully charged, which corresponds
5444
+ * to an `InitCharge` value of -1. However, in some cases, this may be different. For example,
5445
+ * Eden's Soul starts without any charges, so it has an `InitCharge` value of 0.
5446
+ *
5447
+ * This function returns 0 if the provided collectible type was not valid.
5448
5448
  */
5449
5449
  export declare function getCollectibleInitCharge(collectibleOrCollectibleType: EntityPickup | CollectibleType): int;
5450
5450
 
@@ -6492,8 +6492,9 @@ export declare function getNormalTrinketType(trinketType: TrinketType): TrinketT
6492
6492
  export declare function getNPCs(entityType?: EntityType | -1, variant?: number, subType?: number, ignoreFriendly?: boolean): EntityNPC[];
6493
6493
 
6494
6494
  /**
6495
- * Helper function to safely get number values from specific keys on a Lua table. Will throw an
6496
- * error if the specific value does not exist on the table or if it cannot be converted to a number.
6495
+ * Helper function to safely get number values from specific keys on a Lua table. If the values are
6496
+ * strings, they will be converted to numbers. Will throw an error if the specific value does not
6497
+ * exist on the table or if it cannot be converted to a number.
6497
6498
  *
6498
6499
  * This function is variadic, meaning that you can specify N arguments to get N values.
6499
6500
  */
@@ -10249,7 +10250,9 @@ export declare function isTSTLSet(object: unknown): object is Set<AnyNotNil>;
10249
10250
 
10250
10251
  export declare function isUserdata(variable: unknown): variable is LuaUserdata;
10251
10252
 
10252
- export declare function isValidCollectibleType(collectibleType: CollectibleType): boolean;
10253
+ export declare function isValidCardType(cardType: int): cardType is CardType;
10254
+
10255
+ export declare function isValidCollectibleType(collectibleType: int): collectibleType is CollectibleType;
10253
10256
 
10254
10257
  /**
10255
10258
  * Test if a grid position is actually in the given `RoomShape`.
@@ -10258,6 +10261,10 @@ export declare function isValidCollectibleType(collectibleType: CollectibleType)
10258
10261
  */
10259
10262
  export declare function isValidGridPosition(gridPosition: Vector, roomShape: RoomShape): boolean;
10260
10263
 
10264
+ export declare function isValidPillEffect(pillEffect: int): pillEffect is PillEffect;
10265
+
10266
+ export declare function isValidTrinketType(trinketType: int): trinketType is TrinketType;
10267
+
10261
10268
  export declare function isVanillaCardType(cardType: CardType): boolean;
10262
10269
 
10263
10270
  export declare function isVanillaCharacter(character: PlayerType): boolean;
@@ -10579,26 +10586,10 @@ export declare const LAST_HORSE_PILL_COLOR = PillColor.HORSE_WHITE_YELLOW;
10579
10586
  */
10580
10587
  export declare const LAST_NORMAL_PILL_COLOR = PillColor.WHITE_YELLOW;
10581
10588
 
10582
- export declare const LAST_ROOM_TYPE: RoomType;
10583
-
10584
- export declare const LAST_STAGE: LevelStage;
10585
-
10586
- /**
10587
- * Calculated from the `CardType` enum.
10588
- *
10589
- * Note that this could be calculated from the length of the enum, because card types are
10590
- * contiguous. However, we instead get the highest enum value to be safer and to make the code more
10591
- * consistent with collectibles and trinkets.
10592
- */
10589
+ /** Calculated from the `CardType` enum. */
10593
10590
  export declare const LAST_VANILLA_CARD_TYPE: CardType;
10594
10591
 
10595
- /**
10596
- * Calculated from the `PlayerType` enum.
10597
- *
10598
- * Note that this could be calculated from the length of the enum, because characters are
10599
- * contiguous. However, we instead get the highest enum value to be safer and to make the code more
10600
- * consistent with collectibles and trinkets.
10601
- */
10592
+ /** Calculated from the `PlayerType` enum. */
10602
10593
  export declare const LAST_VANILLA_CHARACTER: PlayerType;
10603
10594
 
10604
10595
  /**
@@ -10609,13 +10600,7 @@ export declare const LAST_VANILLA_CHARACTER: PlayerType;
10609
10600
  */
10610
10601
  export declare const LAST_VANILLA_COLLECTIBLE_TYPE: CollectibleType;
10611
10602
 
10612
- /**
10613
- * Calculated from the `PillEffect` enum.
10614
- *
10615
- * Note that this could be calculated from the length of the enum, because pill effects are
10616
- * contiguous. However, we instead get the highest enum value to be safer and to make the code more
10617
- * consistent with collectibles and trinkets.
10618
- */
10603
+ /** Calculated from the `PillEffect` enum. */
10619
10604
  export declare const LAST_VANILLA_PILL_EFFECT: PillEffect;
10620
10605
 
10621
10606
  /**
@@ -15229,6 +15214,16 @@ export declare function parseEntityID(entityID: string): [entityType: EntityType
15229
15214
  */
15230
15215
  export declare function parseEntityTypeVariantString(entityTypeVariantString: string): [entityType: EntityType, variant: int] | undefined;
15231
15216
 
15217
+ /**
15218
+ * Helper function to convert a string to an integer. Returns undefined if the string is not an
15219
+ * integer.
15220
+ *
15221
+ * Under the hood, this uses the built-in `tonumber` and `math.floor` functions.
15222
+ *
15223
+ * This is named `parseIntSafe` in order to match the helper function in `isaacscript-common-ts`.
15224
+ */
15225
+ export declare function parseIntSafe(string: string): int | undefined;
15226
+
15232
15227
  /**
15233
15228
  * Helper function to parse a Semantic Versioning string into its individual constituents. Returns
15234
15229
  * undefined if the submitted string was not a proper Semantic Version string.