isaacscript-common 8.7.0 → 8.8.2

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.
@@ -1,3 +1,12 @@
1
1
  import { LevelCurse } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to get the actual bit flag for modded curses.
4
+ *
5
+ * Will throw a runtime error if the provided curse does not exist.
6
+ *
7
+ * Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
8
+ * a bit flag.
9
+ */
10
+ export declare function getCurseIDByName(name: string): LevelCurse;
2
11
  export declare function hasCurse(curse: LevelCurse): boolean;
3
12
  //# sourceMappingURL=curses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"curses.d.ts","sourceRoot":"","sources":["../../src/functions/curses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAI1D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAInD"}
1
+ {"version":3,"file":"curses.d.ts","sourceRoot":"","sources":["../../src/functions/curses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAI1D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAWzD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAInD"}
@@ -3,6 +3,19 @@ local ____cachedClasses = require("core.cachedClasses")
3
3
  local game = ____cachedClasses.game
4
4
  local ____flag = require("functions.flag")
5
5
  local hasFlag = ____flag.hasFlag
6
+ --- Helper function to get the actual bit flag for modded curses.
7
+ --
8
+ -- Will throw a runtime error if the provided curse does not exist.
9
+ --
10
+ -- Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
11
+ -- a bit flag.
12
+ function ____exports.getCurseIDByName(self, name)
13
+ local curseID = Isaac.GetCurseIdByName(name)
14
+ if curseID == -1 then
15
+ error(("Failed to get the curse ID corresponding to the curse name of \"" .. tostring(curseID)) .. "\". Does this name match what you put in the \"content/curses.xml\" file?")
16
+ end
17
+ return 1 << curseID - 1
18
+ end
6
19
  function ____exports.hasCurse(self, curse)
7
20
  local level = game:GetLevel()
8
21
  local curses = level:GetCurses()
package/dist/index.d.ts CHANGED
@@ -2805,6 +2805,16 @@ export declare function getCombinedBossSet(stage: int): ReadonlySet<string> | un
2805
2805
  */
2806
2806
  export declare function getCrawlSpaces(crawlSpaceVariant?: CrawlSpaceVariant): GridEntity[];
2807
2807
 
2808
+ /**
2809
+ * Helper function to get the actual bit flag for modded curses.
2810
+ *
2811
+ * Will throw a runtime error if the provided curse does not exist.
2812
+ *
2813
+ * Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
2814
+ * a bit flag.
2815
+ */
2816
+ export declare function getCurseIDByName(name: string): LevelCurse;
2817
+
2808
2818
  /**
2809
2819
  * Helper function to get the custom grid entities in the current room. Returns an array of tuples
2810
2820
  * containing the raw decoration grid entity and the associated entity data.
@@ -241,7 +241,7 @@ local MINES_BOSSES_SET = __TS__New(
241
241
  (tostring(EntityType.LARRY_JR) .. ".") .. tostring(LarryJrVariant.TUFF_TWIN),
242
242
  tostring(EntityType.REAP_CREEP) .. ".0",
243
243
  tostring(EntityType.HORNFEL) .. ".0",
244
- tostring(EntityType.GIDEON) .. ".0"
244
+ tostring(EntityType.GREAT_GIDEON) .. ".0"
245
245
  }
246
246
  )
247
247
  --- Contains just the bosses in Ashpit (not e.g. Flooded Caves).
@@ -250,7 +250,7 @@ local ASHPIT_BOSSES_SET = __TS__New(
250
250
  {
251
251
  (tostring(EntityType.LARRY_JR) .. ".") .. tostring(LarryJrVariant.THE_SHELL),
252
252
  (tostring(EntityType.POLYCEPHALUS) .. ".") .. tostring(PolycephalusVariant.THE_PILE),
253
- tostring(EntityType.GIDEON) .. ".0",
253
+ tostring(EntityType.GREAT_GIDEON) .. ".0",
254
254
  tostring(EntityType.SINGE) .. ".0",
255
255
  tostring(EntityType.CLUTCH) .. ".0"
256
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "8.7.0",
3
+ "version": "8.8.2",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/index",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^3.5.2"
25
+ "isaac-typescript-definitions": "^3.6.2"
26
26
  }
27
27
  }
@@ -2,6 +2,27 @@ import { LevelCurse } from "isaac-typescript-definitions";
2
2
  import { game } from "../core/cachedClasses";
3
3
  import { hasFlag } from "./flag";
4
4
 
5
+ /**
6
+ * Helper function to get the actual bit flag for modded curses.
7
+ *
8
+ * Will throw a runtime error if the provided curse does not exist.
9
+ *
10
+ * Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
11
+ * a bit flag.
12
+ */
13
+ export function getCurseIDByName(name: string): LevelCurse {
14
+ const curseID = Isaac.GetCurseIdByName(name);
15
+ if (curseID === -1) {
16
+ error(
17
+ `Failed to get the curse ID corresponding to the curse name of "${curseID}". Does this name match what you put in the "content/curses.xml" file?`,
18
+ );
19
+ }
20
+
21
+ // For example, the final vanilla curse is "Curse of the Giant", which has an ID of 8. This
22
+ // corresponds to `LevelCurse.GIANT`, which has a value of `1 << 7`.
23
+ return (1 << (curseID - 1)) as LevelCurse;
24
+ }
25
+
5
26
  export function hasCurse(curse: LevelCurse): boolean {
6
27
  const level = game.GetLevel();
7
28
  const curses = level.GetCurses();
@@ -193,14 +193,14 @@ const MINES_BOSSES_SET: ReadonlySet<string> = new Set([
193
193
  `${EntityType.LARRY_JR}.${LarryJrVariant.TUFF_TWIN}`, // 19.2
194
194
  `${EntityType.REAP_CREEP}.0`, // 900.0
195
195
  `${EntityType.HORNFEL}.0`, // 906.0
196
- `${EntityType.GIDEON}.0`, // 907.0
196
+ `${EntityType.GREAT_GIDEON}.0`, // 907.0
197
197
  ]);
198
198
 
199
199
  /** Contains just the bosses in Ashpit (not e.g. Flooded Caves). */
200
200
  const ASHPIT_BOSSES_SET: ReadonlySet<string> = new Set([
201
201
  `${EntityType.LARRY_JR}.${LarryJrVariant.THE_SHELL}`, // 19.3
202
202
  `${EntityType.POLYCEPHALUS}.${PolycephalusVariant.THE_PILE}`, // 269.1
203
- `${EntityType.GIDEON}.0`, // 907.0
203
+ `${EntityType.GREAT_GIDEON}.0`, // 907.0
204
204
  `${EntityType.SINGE}.0`, // 915.0
205
205
  `${EntityType.CLUTCH}.0`, // 921.0
206
206
  ]);