isaacscript-common 59.2.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.
@@ -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
  /**
@@ -16771,6 +16781,15 @@ export declare function setBackdrop(backdropType: BackdropType): void;
16771
16781
  */
16772
16782
  export declare function setBlindfold(player: EntityPlayer, enabled: boolean, modifyCostume?: boolean): void;
16773
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
+
16774
16793
  /**
16775
16794
  * Helper function to set a collectible sprite to a question mark (i.e. how collectibles look when
16776
16795
  * the player has Curse of the Blind).
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 59.2.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
 
@@ -54628,6 +54628,15 @@ local DEFAULT_CHALLENGE_CHARACTER = ____challengeCharacters.DEFAULT_CHALLENGE_CH
54628
54628
  local ____challengeNames = require("src.objects.challengeNames")
54629
54629
  local CHALLENGE_NAMES = ____challengeNames.CHALLENGE_NAMES
54630
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
54631
54640
  function ____exports.getChallengeBoss(self, challenge)
54632
54641
  local challengeBossID = CHALLENGE_BOSSES[challenge]
54633
54642
  return challengeBossID or DEFAULT_CHALLENGE_BOSS_ID
@@ -54640,15 +54649,16 @@ function ____exports.getChallengeName(self, challenge)
54640
54649
  local challengeName = CHALLENGE_NAMES[challenge]
54641
54650
  return challengeName or DEFAULT_CHALLENGE_NAME
54642
54651
  end
54643
- function ____exports.onAnyChallenge(self)
54644
- local challenge = Isaac.GetChallenge()
54645
- return challenge ~= Challenge.NULL
54646
- end
54647
54652
  function ____exports.onChallenge(self, ...)
54648
54653
  local challenges = {...}
54649
54654
  local challenge = Isaac.GetChallenge()
54650
54655
  return __TS__ArrayIncludes(challenges, challenge)
54651
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
54652
54662
  return ____exports
54653
54663
  end,
54654
54664
  ["src.interfaces.ChargeBarSprites"] = function(...)
@@ -1,5 +1,14 @@
1
1
  import type { BossID, PlayerType } from "isaac-typescript-definitions";
2
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;
3
12
  /**
4
13
  * Get the final boss of a challenge. This will only work for vanilla challenges.
5
14
  *
@@ -30,4 +39,12 @@ export declare function onAnyChallenge(): boolean;
30
39
  * for.
31
40
  */
32
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;
33
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,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAczD;;;;;;;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"}
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"}
@@ -12,6 +12,22 @@ local DEFAULT_CHALLENGE_CHARACTER = ____challengeCharacters.DEFAULT_CHALLENGE_CH
12
12
  local ____challengeNames = require("src.objects.challengeNames")
13
13
  local CHALLENGE_NAMES = ____challengeNames.CHALLENGE_NAMES
14
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
15
31
  --- Get the final boss of a challenge. This will only work for vanilla challenges.
16
32
  --
17
33
  -- For modded challenges, `BossID.MOM` (6) will be returned.
@@ -36,11 +52,6 @@ function ____exports.getChallengeName(self, challenge)
36
52
  local challengeName = CHALLENGE_NAMES[challenge]
37
53
  return challengeName or DEFAULT_CHALLENGE_NAME
38
54
  end
39
- --- Helper function to see if the player is playing any challenge.
40
- function ____exports.onAnyChallenge(self)
41
- local challenge = Isaac.GetChallenge()
42
- return challenge ~= Challenge.NULL
43
- end
44
55
  --- Helper function to check to see if the player is playing a particular challenge.
45
56
  --
46
57
  -- This function is variadic, meaning that you can specify as many challenges as you want to check
@@ -50,4 +61,14 @@ function ____exports.onChallenge(self, ...)
50
61
  local challenge = Isaac.GetChallenge()
51
62
  return __TS__ArrayIncludes(challenges, challenge)
52
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
53
74
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "59.2.0",
3
+ "version": "59.3.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -13,6 +13,20 @@ import {
13
13
  DEFAULT_CHALLENGE_NAME,
14
14
  } from "../objects/challengeNames";
15
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
+
16
30
  /**
17
31
  * Get the final boss of a challenge. This will only work for vanilla challenges.
18
32
  *
@@ -68,3 +82,16 @@ export function onChallenge(...challenges: Challenge[]): boolean {
68
82
  const challenge = Isaac.GetChallenge();
69
83
  return challenges.includes(challenge);
70
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
+ }