isaacscript-common 59.1.0 → 59.3.0

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.
@@ -12,7 +12,7 @@ import { ButtonAction } from 'isaac-typescript-definitions';
12
12
  import { CacheFlag } from 'isaac-typescript-definitions';
13
13
  import { CallbackPriority } from 'isaac-typescript-definitions/dist/src/enums/CallbackPriority';
14
14
  import { CardType } from 'isaac-typescript-definitions';
15
- import type { Challenge } from 'isaac-typescript-definitions';
15
+ import { Challenge } from 'isaac-typescript-definitions';
16
16
  import type { CoinSubType } from 'isaac-typescript-definitions';
17
17
  import type { CollectiblePedestalType } from 'isaac-typescript-definitions';
18
18
  import { CollectibleType } from 'isaac-typescript-definitions';
@@ -1550,6 +1550,16 @@ export declare const CHEST_PICKUP_VARIANTS_SET: ReadonlySet<PickupVariant>;
1550
1550
  */
1551
1551
  export declare function clamp(num: int, min: int, max: int): int;
1552
1552
 
1553
+ /**
1554
+ * Helper function to clear the current challenge, which will restart the run on a new random
1555
+ * non-challenge seed with the current character.
1556
+ *
1557
+ * If the player is not in a challenge already, this function will do nothing.
1558
+ *
1559
+ * Under the hood, this function executes the `challenge 0` console command.
1560
+ */
1561
+ export declare function clearChallenge(): void;
1562
+
1553
1563
  export declare function clearCollectibleSprite(collectible: EntityPickup): void;
1554
1564
 
1555
1565
  /**
@@ -14326,6 +14336,9 @@ export declare const NUM_VANILLA_PILL_EFFECTS: int;
14326
14336
  /** Calculated from the `TrinketType` enum. (`TrinketType.NULL` is not included.) */
14327
14337
  export declare const NUM_VANILLA_TRINKET_TYPES: number;
14328
14338
 
14339
+ /** Helper function to see if the player is playing any challenge. */
14340
+ export declare function onAnyChallenge(): boolean;
14341
+
14329
14342
  /**
14330
14343
  * Helper function to check if the player has taken Dad's Note. This sets the game state flag of
14331
14344
  * `GameStateFlag.BACKWARDS_PATH` and causes floor generation to change.
@@ -14334,6 +14347,14 @@ export declare function onAscent(): boolean;
14334
14347
 
14335
14348
  export declare function onCathedral(): boolean;
14336
14349
 
14350
+ /**
14351
+ * Helper function to check to see if the player is playing a particular challenge.
14352
+ *
14353
+ * This function is variadic, meaning that you can specify as many challenges as you want to check
14354
+ * for.
14355
+ */
14356
+ export declare function onChallenge(...challenges: Challenge[]): boolean;
14357
+
14337
14358
  export declare function onChest(): boolean;
14338
14359
 
14339
14360
  export declare function onDarkRoom(): boolean;
@@ -16760,6 +16781,15 @@ export declare function setBackdrop(backdropType: BackdropType): void;
16760
16781
  */
16761
16782
  export declare function setBlindfold(player: EntityPlayer, enabled: boolean, modifyCostume?: boolean): void;
16762
16783
 
16784
+ /**
16785
+ * Helper function to restart the run on a particular challenge.
16786
+ *
16787
+ * If the player is already in the particular challenge, this function will do nothing.
16788
+ *
16789
+ * Under the hood, this function executes the `challenge 0` console command.
16790
+ */
16791
+ export declare function setChallenge(challenge: Challenge): void;
16792
+
16763
16793
  /**
16764
16794
  * Helper function to set a collectible sprite to a question mark (i.e. how collectibles look when
16765
16795
  * the player has Curse of the Blind).
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 59.1.0
3
+ isaacscript-common 59.3.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -54614,7 +54614,11 @@ ____exports.CHALLENGE_NAMES = {
54614
54614
  return ____exports
54615
54615
  end,
54616
54616
  ["src.functions.challenges"] = function(...)
54617
+ local ____lualib = require("lualib_bundle")
54618
+ local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
54617
54619
  local ____exports = {}
54620
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
54621
+ local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
54618
54622
  local ____challengeBosses = require("src.objects.challengeBosses")
54619
54623
  local CHALLENGE_BOSSES = ____challengeBosses.CHALLENGE_BOSSES
54620
54624
  local DEFAULT_CHALLENGE_BOSS_ID = ____challengeBosses.DEFAULT_CHALLENGE_BOSS_ID
@@ -54624,6 +54628,15 @@ local DEFAULT_CHALLENGE_CHARACTER = ____challengeCharacters.DEFAULT_CHALLENGE_CH
54624
54628
  local ____challengeNames = require("src.objects.challengeNames")
54625
54629
  local CHALLENGE_NAMES = ____challengeNames.CHALLENGE_NAMES
54626
54630
  local DEFAULT_CHALLENGE_NAME = ____challengeNames.DEFAULT_CHALLENGE_NAME
54631
+ function ____exports.onAnyChallenge(self)
54632
+ local challenge = Isaac.GetChallenge()
54633
+ return challenge ~= Challenge.NULL
54634
+ end
54635
+ function ____exports.clearChallenge(self)
54636
+ if ____exports.onAnyChallenge(nil) then
54637
+ Isaac.ExecuteCommand("challenge " .. tostring(Challenge.NULL))
54638
+ end
54639
+ end
54627
54640
  function ____exports.getChallengeBoss(self, challenge)
54628
54641
  local challengeBossID = CHALLENGE_BOSSES[challenge]
54629
54642
  return challengeBossID or DEFAULT_CHALLENGE_BOSS_ID
@@ -54636,6 +54649,16 @@ function ____exports.getChallengeName(self, challenge)
54636
54649
  local challengeName = CHALLENGE_NAMES[challenge]
54637
54650
  return challengeName or DEFAULT_CHALLENGE_NAME
54638
54651
  end
54652
+ function ____exports.onChallenge(self, ...)
54653
+ local challenges = {...}
54654
+ local challenge = Isaac.GetChallenge()
54655
+ return __TS__ArrayIncludes(challenges, challenge)
54656
+ end
54657
+ function ____exports.setChallenge(self, challenge)
54658
+ if not ____exports.onChallenge(nil, challenge) then
54659
+ Isaac.ExecuteCommand("challenge " .. tostring(challenge))
54660
+ end
54661
+ end
54639
54662
  return ____exports
54640
54663
  end,
54641
54664
  ["src.interfaces.ChargeBarSprites"] = function(...)
@@ -1,4 +1,14 @@
1
- import type { BossID, Challenge, PlayerType } from "isaac-typescript-definitions";
1
+ import type { BossID, PlayerType } from "isaac-typescript-definitions";
2
+ import { Challenge } from "isaac-typescript-definitions";
3
+ /**
4
+ * Helper function to clear the current challenge, which will restart the run on a new random
5
+ * non-challenge seed with the current character.
6
+ *
7
+ * If the player is not in a challenge already, this function will do nothing.
8
+ *
9
+ * Under the hood, this function executes the `challenge 0` console command.
10
+ */
11
+ export declare function clearChallenge(): void;
2
12
  /**
3
13
  * Get the final boss of a challenge. This will only work for vanilla challenges.
4
14
  *
@@ -20,4 +30,21 @@ export declare function getChallengeCharacter(challenge: Challenge): PlayerType;
20
30
  * For modded challenges, "Unknown" will be returned.
21
31
  */
22
32
  export declare function getChallengeName(challenge: Challenge): string;
33
+ /** Helper function to see if the player is playing any challenge. */
34
+ export declare function onAnyChallenge(): boolean;
35
+ /**
36
+ * Helper function to check to see if the player is playing a particular challenge.
37
+ *
38
+ * This function is variadic, meaning that you can specify as many challenges as you want to check
39
+ * for.
40
+ */
41
+ export declare function onChallenge(...challenges: Challenge[]): boolean;
42
+ /**
43
+ * Helper function to restart the run on a particular challenge.
44
+ *
45
+ * If the player is already in the particular challenge, this function will do nothing.
46
+ *
47
+ * Under the hood, this function executes the `challenge 0` console command.
48
+ */
49
+ export declare function setChallenge(challenge: Challenge): void;
23
50
  //# sourceMappingURL=challenges.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"challenges.d.ts","sourceRoot":"","sources":["../../../src/functions/challenges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,UAAU,EACX,MAAM,8BAA8B,CAAC;AActC;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAK7D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,CAKtE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAK7D"}
1
+ {"version":3,"file":"challenges.d.ts","sourceRoot":"","sources":["../../../src/functions/challenges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAczD;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAIrC;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAK7D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,CAKtE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAK7D;AAED,qEAAqE;AACrE,wBAAgB,cAAc,IAAI,OAAO,CAGxC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAG/D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAIvD"}
@@ -1,4 +1,8 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
1
3
  local ____exports = {}
4
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
5
+ local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
2
6
  local ____challengeBosses = require("src.objects.challengeBosses")
3
7
  local CHALLENGE_BOSSES = ____challengeBosses.CHALLENGE_BOSSES
4
8
  local DEFAULT_CHALLENGE_BOSS_ID = ____challengeBosses.DEFAULT_CHALLENGE_BOSS_ID
@@ -8,6 +12,22 @@ local DEFAULT_CHALLENGE_CHARACTER = ____challengeCharacters.DEFAULT_CHALLENGE_CH
8
12
  local ____challengeNames = require("src.objects.challengeNames")
9
13
  local CHALLENGE_NAMES = ____challengeNames.CHALLENGE_NAMES
10
14
  local DEFAULT_CHALLENGE_NAME = ____challengeNames.DEFAULT_CHALLENGE_NAME
15
+ --- Helper function to see if the player is playing any challenge.
16
+ function ____exports.onAnyChallenge(self)
17
+ local challenge = Isaac.GetChallenge()
18
+ return challenge ~= Challenge.NULL
19
+ end
20
+ --- Helper function to clear the current challenge, which will restart the run on a new random
21
+ -- non-challenge seed with the current character.
22
+ --
23
+ -- If the player is not in a challenge already, this function will do nothing.
24
+ --
25
+ -- Under the hood, this function executes the `challenge 0` console command.
26
+ function ____exports.clearChallenge(self)
27
+ if ____exports.onAnyChallenge(nil) then
28
+ Isaac.ExecuteCommand("challenge " .. tostring(Challenge.NULL))
29
+ end
30
+ end
11
31
  --- Get the final boss of a challenge. This will only work for vanilla challenges.
12
32
  --
13
33
  -- For modded challenges, `BossID.MOM` (6) will be returned.
@@ -32,4 +52,23 @@ function ____exports.getChallengeName(self, challenge)
32
52
  local challengeName = CHALLENGE_NAMES[challenge]
33
53
  return challengeName or DEFAULT_CHALLENGE_NAME
34
54
  end
55
+ --- Helper function to check to see if the player is playing a particular challenge.
56
+ --
57
+ -- This function is variadic, meaning that you can specify as many challenges as you want to check
58
+ -- for.
59
+ function ____exports.onChallenge(self, ...)
60
+ local challenges = {...}
61
+ local challenge = Isaac.GetChallenge()
62
+ return __TS__ArrayIncludes(challenges, challenge)
63
+ end
64
+ --- Helper function to restart the run on a particular challenge.
65
+ --
66
+ -- If the player is already in the particular challenge, this function will do nothing.
67
+ --
68
+ -- Under the hood, this function executes the `challenge 0` console command.
69
+ function ____exports.setChallenge(self, challenge)
70
+ if not ____exports.onChallenge(nil, challenge) then
71
+ Isaac.ExecuteCommand("challenge " .. tostring(challenge))
72
+ end
73
+ end
35
74
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "59.1.0",
3
+ "version": "59.3.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,8 +1,5 @@
1
- import type {
2
- BossID,
3
- Challenge,
4
- PlayerType,
5
- } from "isaac-typescript-definitions";
1
+ import type { BossID, PlayerType } from "isaac-typescript-definitions";
2
+ import { Challenge } from "isaac-typescript-definitions";
6
3
  import {
7
4
  CHALLENGE_BOSSES,
8
5
  DEFAULT_CHALLENGE_BOSS_ID,
@@ -16,6 +13,20 @@ import {
16
13
  DEFAULT_CHALLENGE_NAME,
17
14
  } from "../objects/challengeNames";
18
15
 
16
+ /**
17
+ * Helper function to clear the current challenge, which will restart the run on a new random
18
+ * non-challenge seed with the current character.
19
+ *
20
+ * If the player is not in a challenge already, this function will do nothing.
21
+ *
22
+ * Under the hood, this function executes the `challenge 0` console command.
23
+ */
24
+ export function clearChallenge(): void {
25
+ if (onAnyChallenge()) {
26
+ Isaac.ExecuteCommand(`challenge ${Challenge.NULL}`);
27
+ }
28
+ }
29
+
19
30
  /**
20
31
  * Get the final boss of a challenge. This will only work for vanilla challenges.
21
32
  *
@@ -54,3 +65,33 @@ export function getChallengeName(challenge: Challenge): string {
54
65
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
55
66
  return challengeName ?? DEFAULT_CHALLENGE_NAME;
56
67
  }
68
+
69
+ /** Helper function to see if the player is playing any challenge. */
70
+ export function onAnyChallenge(): boolean {
71
+ const challenge = Isaac.GetChallenge();
72
+ return challenge !== Challenge.NULL;
73
+ }
74
+
75
+ /**
76
+ * Helper function to check to see if the player is playing a particular challenge.
77
+ *
78
+ * This function is variadic, meaning that you can specify as many challenges as you want to check
79
+ * for.
80
+ */
81
+ export function onChallenge(...challenges: Challenge[]): boolean {
82
+ const challenge = Isaac.GetChallenge();
83
+ return challenges.includes(challenge);
84
+ }
85
+
86
+ /**
87
+ * Helper function to restart the run on a particular challenge.
88
+ *
89
+ * If the player is already in the particular challenge, this function will do nothing.
90
+ *
91
+ * Under the hood, this function executes the `challenge 0` console command.
92
+ */
93
+ export function setChallenge(challenge: Challenge): void {
94
+ if (!onChallenge(challenge)) {
95
+ Isaac.ExecuteCommand(`challenge ${challenge}`);
96
+ }
97
+ }