isaacscript-common 7.17.5 → 7.18.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.
@@ -304,7 +304,7 @@ function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
304
304
  return 32 - 2.5 * tearHeight
305
305
  end
306
306
  function ____exports.getClosestPlayer(self, position)
307
- local closestPlayer = nil
307
+ local closestPlayer
308
308
  local closestDistance = math.huge
309
309
  for ____, player in ipairs(getPlayers(nil)) do
310
310
  local distance = position:Distance(player.Position)
@@ -1,4 +1,9 @@
1
1
  import { PlayerType } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to see if the current run can unlock achievements. For example, if playing on a
4
+ * set seed or in a victory lap, achievements are disabled.
5
+ */
6
+ export declare function canRunUnlockAchievements(): boolean;
2
7
  /**
3
8
  * Whether or not the player is playing on a set seed (i.e. that they entered in a specific seed by
4
9
  * pressing tab on the character selection screen). When the player resets the game on a set seed,
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/functions/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAMrE;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAMnC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI,CAiBpD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI,CAInE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAUlC"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/functions/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEX,MAAM,8BAA8B,CAAC;AAQtC;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAUlD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAMnC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI,CAiBpD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI,CAInE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAUlC"}
@@ -2,14 +2,27 @@ local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
4
4
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
5
+ local SlotVariant = ____isaac_2Dtypescript_2Ddefinitions.SlotVariant
5
6
  local ____cachedClasses = require("core.cachedClasses")
6
7
  local game = ____cachedClasses.game
8
+ local ____constants = require("core.constants")
9
+ local VectorZero = ____constants.VectorZero
7
10
  local ____constantsFirstLast = require("core.constantsFirstLast")
8
11
  local FIRST_CHARACTER = ____constantsFirstLast.FIRST_CHARACTER
9
12
  local ____runInNFrames = require("features.runInNFrames")
10
13
  local runNextRenderFrame = ____runInNFrames.runNextRenderFrame
14
+ local ____entitiesSpecific = require("functions.entitiesSpecific")
15
+ local spawnSlot = ____entitiesSpecific.spawnSlot
11
16
  local ____log = require("functions.log")
12
17
  local log = ____log.log
18
+ --- Helper function to see if the current run can unlock achievements. For example, if playing on a
19
+ -- set seed or in a victory lap, achievements are disabled.
20
+ function ____exports.canRunUnlockAchievements(self)
21
+ local greedDonationMachine = spawnSlot(nil, SlotVariant.GREED_DONATION_MACHINE, 0, VectorZero)
22
+ local canUnlockAchievements = greedDonationMachine:Exists()
23
+ greedDonationMachine:Remove()
24
+ return canUnlockAchievements
25
+ end
13
26
  --- Whether or not the player is playing on a set seed (i.e. that they entered in a specific seed by
14
27
  -- pressing tab on the character selection screen). When the player resets the game on a set seed,
15
28
  -- the game will not switch to a different seed.
package/dist/index.d.ts CHANGED
@@ -613,6 +613,12 @@ export declare function calculateStageTypeRepentance(stage: LevelStage): StageTy
613
613
  */
614
614
  export declare function canPlayerCrushRocks(player: EntityPlayer): boolean;
615
615
 
616
+ /**
617
+ * Helper function to see if the current run can unlock achievements. For example, if playing on a
618
+ * set seed or in a victory lap, achievements are disabled.
619
+ */
620
+ export declare function canRunUnlockAchievements(): boolean;
621
+
616
622
  export declare function capitalizeFirstLetter(string: string): string;
617
623
 
618
624
  /** Maps card names to card sub-types. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "7.17.5",
3
+ "version": "7.18.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -249,7 +249,7 @@ export function getCharacters(): PlayerType[] {
249
249
  }
250
250
 
251
251
  export function getClosestPlayer(position: Vector): EntityPlayer {
252
- let closestPlayer: EntityPlayer | null = null;
252
+ let closestPlayer: EntityPlayer | undefined;
253
253
  let closestDistance = math.huge;
254
254
  for (const player of getPlayers()) {
255
255
  const distance = position.Distance(player.Position);
@@ -260,7 +260,7 @@ export function getClosestPlayer(position: Vector): EntityPlayer {
260
260
  }
261
261
  }
262
262
 
263
- if (closestPlayer === null) {
263
+ if (closestPlayer === undefined) {
264
264
  error("Failed to find the closest player.");
265
265
  }
266
266
 
@@ -1,9 +1,31 @@
1
- import { Challenge, PlayerType } from "isaac-typescript-definitions";
1
+ import {
2
+ Challenge,
3
+ PlayerType,
4
+ SlotVariant,
5
+ } from "isaac-typescript-definitions";
2
6
  import { game } from "../core/cachedClasses";
7
+ import { VectorZero } from "../core/constants";
3
8
  import { FIRST_CHARACTER } from "../core/constantsFirstLast";
4
9
  import { runNextRenderFrame } from "../features/runInNFrames";
10
+ import { spawnSlot } from "./entitiesSpecific";
5
11
  import { log } from "./log";
6
12
 
13
+ /**
14
+ * Helper function to see if the current run can unlock achievements. For example, if playing on a
15
+ * set seed or in a victory lap, achievements are disabled.
16
+ */
17
+ export function canRunUnlockAchievements(): boolean {
18
+ const greedDonationMachine = spawnSlot(
19
+ SlotVariant.GREED_DONATION_MACHINE,
20
+ 0,
21
+ VectorZero,
22
+ );
23
+ const canUnlockAchievements = greedDonationMachine.Exists();
24
+ greedDonationMachine.Remove();
25
+
26
+ return canUnlockAchievements;
27
+ }
28
+
7
29
  /**
8
30
  * Whether or not the player is playing on a set seed (i.e. that they entered in a specific seed by
9
31
  * pressing tab on the character selection screen). When the player resets the game on a set seed,