isaacscript-common 59.2.0 → 59.4.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).
@@ -16986,6 +17005,16 @@ export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, disp
16986
17005
  */
16987
17006
  export declare function setRoomUncleared(): void;
16988
17007
 
17008
+ /**
17009
+ * Helper function to restart the run on a particular starting seed.
17010
+ *
17011
+ * Under the hood, this function executes the `seed` console command.
17012
+ *
17013
+ * @param startSeedOrStartSeedString Either the numerical start seed (e.g. 268365970) or the start
17014
+ * seed string (e.g. "AAJ2 8V9C").
17015
+ */
17016
+ export declare function setRunSeed(startSeedOrStartSeedString: Seed | string): void;
17017
+
16989
17018
  /** Helper function to set a seed to an RNG object using Blade's recommended shift index. */
16990
17019
  export declare function setSeed(rng: RNG, seed: Seed): void;
16991
17020
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 59.2.0
3
+ isaacscript-common 59.4.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -22636,6 +22636,8 @@ local ____entitiesSpecific = require("src.functions.entitiesSpecific")
22636
22636
  local spawnSlot = ____entitiesSpecific.spawnSlot
22637
22637
  local ____log = require("src.functions.log")
22638
22638
  local log = ____log.log
22639
+ local ____types = require("src.functions.types")
22640
+ local isString = ____types.isString
22639
22641
  function ____exports.anySeedEffectEnabled(self)
22640
22642
  local seeds = game:GetSeeds()
22641
22643
  local numSeedEffects = seeds:CountSeedEffects()
@@ -22685,6 +22687,10 @@ function ____exports.restart(self, character)
22685
22687
  log((((("Restarting the run as " .. characterName) .. " (") .. tostring(character)) .. ") with a console command of: ") .. command)
22686
22688
  Isaac.ExecuteCommand(command)
22687
22689
  end
22690
+ function ____exports.setRunSeed(self, startSeedOrStartSeedString)
22691
+ local startSeedString = isString(nil, startSeedOrStartSeedString) and startSeedOrStartSeedString or Seeds.Seed2String(startSeedOrStartSeedString)
22692
+ Isaac.ExecuteCommand("seed " .. startSeedString)
22693
+ end
22688
22694
  function ____exports.setUnseeded(self)
22689
22695
  local seeds = game:GetSeeds()
22690
22696
  seeds:Reset()
@@ -54628,6 +54634,15 @@ local DEFAULT_CHALLENGE_CHARACTER = ____challengeCharacters.DEFAULT_CHALLENGE_CH
54628
54634
  local ____challengeNames = require("src.objects.challengeNames")
54629
54635
  local CHALLENGE_NAMES = ____challengeNames.CHALLENGE_NAMES
54630
54636
  local DEFAULT_CHALLENGE_NAME = ____challengeNames.DEFAULT_CHALLENGE_NAME
54637
+ function ____exports.onAnyChallenge(self)
54638
+ local challenge = Isaac.GetChallenge()
54639
+ return challenge ~= Challenge.NULL
54640
+ end
54641
+ function ____exports.clearChallenge(self)
54642
+ if ____exports.onAnyChallenge(nil) then
54643
+ Isaac.ExecuteCommand("challenge " .. tostring(Challenge.NULL))
54644
+ end
54645
+ end
54631
54646
  function ____exports.getChallengeBoss(self, challenge)
54632
54647
  local challengeBossID = CHALLENGE_BOSSES[challenge]
54633
54648
  return challengeBossID or DEFAULT_CHALLENGE_BOSS_ID
@@ -54640,15 +54655,16 @@ function ____exports.getChallengeName(self, challenge)
54640
54655
  local challengeName = CHALLENGE_NAMES[challenge]
54641
54656
  return challengeName or DEFAULT_CHALLENGE_NAME
54642
54657
  end
54643
- function ____exports.onAnyChallenge(self)
54644
- local challenge = Isaac.GetChallenge()
54645
- return challenge ~= Challenge.NULL
54646
- end
54647
54658
  function ____exports.onChallenge(self, ...)
54648
54659
  local challenges = {...}
54649
54660
  local challenge = Isaac.GetChallenge()
54650
54661
  return __TS__ArrayIncludes(challenges, challenge)
54651
54662
  end
54663
+ function ____exports.setChallenge(self, challenge)
54664
+ if not ____exports.onChallenge(nil, challenge) then
54665
+ Isaac.ExecuteCommand("challenge " .. tostring(challenge))
54666
+ end
54667
+ end
54652
54668
  return ____exports
54653
54669
  end,
54654
54670
  ["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
@@ -45,6 +45,15 @@ export declare function onVictoryLap(): boolean;
45
45
  * You can optionally specify a `PlayerType` to restart the game as that character.
46
46
  */
47
47
  export declare function restart(character?: PlayerType): void;
48
+ /**
49
+ * Helper function to restart the run on a particular starting seed.
50
+ *
51
+ * Under the hood, this function executes the `seed` console command.
52
+ *
53
+ * @param startSeedOrStartSeedString Either the numerical start seed (e.g. 268365970) or the start
54
+ * seed string (e.g. "AAJ2 8V9C").
55
+ */
56
+ export declare function setRunSeed(startSeedOrStartSeedString: Seed | string): void;
48
57
  /**
49
58
  * Helper function to change the run status to that of an unseeded run with a new random seed.
50
59
  *
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/functions/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAGL,UAAU,EAEX,MAAM,8BAA8B,CAAC;AAStC,qDAAqD;AACrD,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAK9C;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAUlD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,EAAE,CAO7C;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAKrC;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAMnC;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAGtC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI,CAkBpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAUlC"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/functions/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAGL,UAAU,EAEX,MAAM,8BAA8B,CAAC;AAUtC,qDAAqD;AACrD,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAK9C;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAUlD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,EAAE,CAO7C;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAKrC;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAMnC;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAGtC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI,CAkBpD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,0BAA0B,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAM1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAUlC"}
@@ -20,6 +20,8 @@ local ____entitiesSpecific = require("src.functions.entitiesSpecific")
20
20
  local spawnSlot = ____entitiesSpecific.spawnSlot
21
21
  local ____log = require("src.functions.log")
22
22
  local log = ____log.log
23
+ local ____types = require("src.functions.types")
24
+ local isString = ____types.isString
23
25
  --- Helper function to see if any seed effects (i.e. Easter Eggs) are enabled for the current run.
24
26
  function ____exports.anySeedEffectEnabled(self)
25
27
  local seeds = game:GetSeeds()
@@ -92,6 +94,16 @@ function ____exports.restart(self, character)
92
94
  log((((("Restarting the run as " .. characterName) .. " (") .. tostring(character)) .. ") with a console command of: ") .. command)
93
95
  Isaac.ExecuteCommand(command)
94
96
  end
97
+ --- Helper function to restart the run on a particular starting seed.
98
+ --
99
+ -- Under the hood, this function executes the `seed` console command.
100
+ --
101
+ -- @param startSeedOrStartSeedString Either the numerical start seed (e.g. 268365970) or the start
102
+ -- seed string (e.g. "AAJ2 8V9C").
103
+ function ____exports.setRunSeed(self, startSeedOrStartSeedString)
104
+ local startSeedString = isString(nil, startSeedOrStartSeedString) and startSeedOrStartSeedString or Seeds.Seed2String(startSeedOrStartSeedString)
105
+ Isaac.ExecuteCommand("seed " .. startSeedString)
106
+ end
95
107
  --- Helper function to change the run status to that of an unseeded run with a new random seed.
96
108
  --
97
109
  -- This is useful to revert the behavior where playing on a set seed and restarting the game will
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "59.2.0",
3
+ "version": "59.4.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
+ }
@@ -12,6 +12,7 @@ import { FIRST_CHARACTER } from "../core/constantsFirstLast";
12
12
  import { getCharacterName } from "./characters";
13
13
  import { spawnSlot } from "./entitiesSpecific";
14
14
  import { log } from "./log";
15
+ import { isString } from "./types";
15
16
 
16
17
  /** Alias for the `anySeedEffectEnabled` function. */
17
18
  export function anyEasterEggEnabled(): boolean {
@@ -122,6 +123,22 @@ export function restart(character?: PlayerType): void {
122
123
  Isaac.ExecuteCommand(command);
123
124
  }
124
125
 
126
+ /**
127
+ * Helper function to restart the run on a particular starting seed.
128
+ *
129
+ * Under the hood, this function executes the `seed` console command.
130
+ *
131
+ * @param startSeedOrStartSeedString Either the numerical start seed (e.g. 268365970) or the start
132
+ * seed string (e.g. "AAJ2 8V9C").
133
+ */
134
+ export function setRunSeed(startSeedOrStartSeedString: Seed | string): void {
135
+ const startSeedString = isString(startSeedOrStartSeedString)
136
+ ? startSeedOrStartSeedString
137
+ : Seeds.Seed2String(startSeedOrStartSeedString);
138
+
139
+ Isaac.ExecuteCommand(`seed ${startSeedString}`);
140
+ }
141
+
125
142
  /**
126
143
  * Helper function to change the run status to that of an unseeded run with a new random seed.
127
144
  *