isaacscript-common 9.12.0 → 9.13.1

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,7 +1,5 @@
1
- local ____lualib = require("lualib_bundle")
2
- local __TS__ArrayFind = ____lualib.__TS__ArrayFind
3
1
  local ____exports = {}
4
- local hasSubscriptions, postUpdate, getPlayerWithControllerIndex, useItemEsauJr, v
2
+ local hasSubscriptions, postUpdate, useItemEsauJr, v
5
3
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
4
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
7
5
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
@@ -9,8 +7,8 @@ local ____cachedClasses = require("core.cachedClasses")
9
7
  local game = ____cachedClasses.game
10
8
  local ____exports = require("features.saveDataManager.exports")
11
9
  local saveDataManager = ____exports.saveDataManager
12
- local ____playerIndex = require("functions.playerIndex")
13
- local getPlayers = ____playerIndex.getPlayers
10
+ local ____players = require("functions.players")
11
+ local getPlayersWithControllerIndex = ____players.getPlayersWithControllerIndex
14
12
  local ____postEsauJr = require("callbacks.subscriptions.postEsauJr")
15
13
  local postEsauJrFire = ____postEsauJr.postEsauJrFire
16
14
  local postEsauJrHasSubscriptions = ____postEsauJr.postEsauJrHasSubscriptions
@@ -32,8 +30,9 @@ function postUpdate(self)
32
30
  if v.run.usedEsauJrControllerIndex == nil then
33
31
  return
34
32
  end
35
- local player = getPlayerWithControllerIndex(nil, v.run.usedEsauJrControllerIndex)
33
+ local players = getPlayersWithControllerIndex(nil, v.run.usedEsauJrControllerIndex)
36
34
  v.run.usedEsauJrControllerIndex = nil
35
+ local player = players[1]
37
36
  if player == nil then
38
37
  return
39
38
  end
@@ -43,13 +42,6 @@ function postUpdate(self)
43
42
  end
44
43
  postEsauJrFire(nil, player)
45
44
  end
46
- function getPlayerWithControllerIndex(self, controllerIndex)
47
- local players = getPlayers(nil)
48
- return __TS__ArrayFind(
49
- players,
50
- function(____, player) return player.ControllerIndex == controllerIndex end
51
- )
52
- end
53
45
  function useItemEsauJr(self, _collectibleType, _rng, player, _useFlags, _activeSlot, _customVarData)
54
46
  if not hasSubscriptions(nil) then
55
47
  return nil
@@ -145,7 +145,7 @@ end
145
145
  --- Helper function to get the corresponding `EntityPlayer` object that corresponds to a
146
146
  -- `PlayerIndex`.
147
147
  function ____exports.getPlayerFromIndex(self, playerIndex)
148
- local players = ____exports.getPlayers(nil)
148
+ local players = ____exports.getAllPlayers(nil)
149
149
  return __TS__ArrayFind(
150
150
  players,
151
151
  function(____, player) return ____exports.getPlayerIndex(nil, player) == playerIndex end
@@ -1,4 +1,4 @@
1
- import { ActiveSlot, CollectibleType, PlayerType, TrinketType } from "isaac-typescript-definitions";
1
+ import { ActiveSlot, CollectibleType, ControllerIndex, PlayerType, TrinketType } from "isaac-typescript-definitions";
2
2
  export declare function addCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType): void;
3
3
  export declare function addTrinketCostume(player: EntityPlayer, trinketType: TrinketType): void;
4
4
  export declare function anyPlayerHasCollectible(collectibleType: CollectibleType): boolean;
@@ -98,6 +98,15 @@ export declare function getPlayerNumHitsRemaining(player: EntityPlayer): int;
98
98
  * for. Returns true if any of the characters supplied are present.
99
99
  */
100
100
  export declare function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[];
101
+ /**
102
+ * Helper function to get all of the players that match the provided controller index. This function
103
+ * returns an array of players because it is possible that there is more than one player with the
104
+ * same controller index (e.g. Jacob & Esau).
105
+ *
106
+ * Note that this function includes players with a non-undefined parent like e.g. the Strawman
107
+ * Keeper.
108
+ */
109
+ export declare function getPlayersOnKeyboard(): EntityPlayer[];
101
110
  /**
102
111
  * Helper function to get only the players that have a certain collectible.
103
112
  *
@@ -105,6 +114,15 @@ export declare function getPlayersOfType(...characters: PlayerType[]): EntityPla
105
114
  * check for. It only returns the players that have all of the collectibles.
106
115
  */
107
116
  export declare function getPlayersWithCollectible(...collectibleTypes: CollectibleType[]): EntityPlayer[];
117
+ /**
118
+ * Helper function to get all of the players that match the provided controller index. This function
119
+ * returns an array of players because it is possible that there is more than one player with the
120
+ * same controller index (e.g. Jacob & Esau).
121
+ *
122
+ * Note that this function includes players with a non-undefined parent like e.g. the Strawman
123
+ * Keeper.
124
+ */
125
+ export declare function getPlayersWithControllerIndex(controllerIndex: ControllerIndex): EntityPlayer[];
108
126
  /**
109
127
  * Helper function to get only the players that have a certain trinket.
110
128
  *
@@ -1 +1 @@
1
- {"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,eAAe,EAIf,UAAU,EAEV,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAetC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAGrE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,kBAAkB,EAAE,UAAU,EAAE,GAAG,OAAO,CAIxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CASjE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,UAAU,GAAG,SAAS,CAMxB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,kBAAkB,EAAE,YAAY,GAAG,KAAK,GACvC,KAAK,CAMP;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,IAAI,UAAU,EAAE,CAG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AAY,EACpB,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,IAAI,CAIN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,OAAO,CAIT;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAa/D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAalE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAIlE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,GAAG,EACZ,WAAW,UAAQ,GAClB,IAAI,CA6DN;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,aAAa,UAAO,GACnB,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAEN"}
1
+ {"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,eAAe,EACf,eAAe,EAIf,UAAU,EAEV,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAetC,wBAAgB,qBAAqB,CACnC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,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAIlE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,GAAG,EACZ,WAAW,UAAQ,GAClB,IAAI,CA6DN;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,aAAa,UAAO,GACnB,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAEN"}
@@ -13,6 +13,7 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
13
13
  local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
14
14
  local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
15
15
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
16
+ local ControllerIndex = ____isaac_2Dtypescript_2Ddefinitions.ControllerIndex
16
17
  local FamiliarVariant = ____isaac_2Dtypescript_2Ddefinitions.FamiliarVariant
17
18
  local NullItemID = ____isaac_2Dtypescript_2Ddefinitions.NullItemID
18
19
  local PlayerForm = ____isaac_2Dtypescript_2Ddefinitions.PlayerForm
@@ -306,6 +307,19 @@ function ____exports.getPlayersOfType(self, ...)
306
307
  end
307
308
  )
308
309
  end
310
+ --- Helper function to get all of the players that match the provided controller index. This function
311
+ -- returns an array of players because it is possible that there is more than one player with the
312
+ -- same controller index (e.g. Jacob & Esau).
313
+ --
314
+ -- Note that this function includes players with a non-undefined parent like e.g. the Strawman
315
+ -- Keeper.
316
+ function ____exports.getPlayersOnKeyboard(self)
317
+ local players = getAllPlayers(nil)
318
+ return __TS__ArrayFilter(
319
+ players,
320
+ function(____, player) return player.ControllerIndex == ControllerIndex.KEYBOARD end
321
+ )
322
+ end
309
323
  --- Helper function to get only the players that have a certain collectible.
310
324
  --
311
325
  -- This function is variadic, meaning that you can supply as many collectible types as you want to
@@ -321,6 +335,19 @@ function ____exports.getPlayersWithCollectible(self, ...)
321
335
  ) end
322
336
  )
323
337
  end
338
+ --- Helper function to get all of the players that match the provided controller index. This function
339
+ -- returns an array of players because it is possible that there is more than one player with the
340
+ -- same controller index (e.g. Jacob & Esau).
341
+ --
342
+ -- Note that this function includes players with a non-undefined parent like e.g. the Strawman
343
+ -- Keeper.
344
+ function ____exports.getPlayersWithControllerIndex(self, controllerIndex)
345
+ local players = getAllPlayers(nil)
346
+ return __TS__ArrayFilter(
347
+ players,
348
+ function(____, player) return player.ControllerIndex == controllerIndex end
349
+ )
350
+ end
324
351
  --- Helper function to get only the players that have a certain trinket.
325
352
  --
326
353
  -- This function is variadic, meaning that you can supply as many trinket types as you want to check
@@ -461,7 +488,7 @@ function ____exports.removeAllActiveItems(self, player)
461
488
  do
462
489
  local collectibleType = player:GetActiveItem(activeSlot)
463
490
  if collectibleType == CollectibleType.NULL then
464
- goto __continue86
491
+ goto __continue90
465
492
  end
466
493
  local hasCollectible
467
494
  repeat
@@ -471,7 +498,7 @@ function ____exports.removeAllActiveItems(self, player)
471
498
  end
472
499
  until not hasCollectible
473
500
  end
474
- ::__continue86::
501
+ ::__continue90::
475
502
  end
476
503
  end
477
504
  --- Helper function to remove all of the held trinkets from a player.
@@ -483,7 +510,7 @@ function ____exports.removeAllPlayerTrinkets(self, player)
483
510
  do
484
511
  local trinketType = player:GetTrinket(trinketSlot)
485
512
  if trinketType == TrinketType.NULL then
486
- goto __continue91
513
+ goto __continue95
487
514
  end
488
515
  local hasTrinket
489
516
  repeat
@@ -493,7 +520,7 @@ function ____exports.removeAllPlayerTrinkets(self, player)
493
520
  end
494
521
  until not hasTrinket
495
522
  end
496
- ::__continue91::
523
+ ::__continue95::
497
524
  end
498
525
  end
499
526
  --- Helper function to remove a collectible costume from a player. Use this helper function to avoid
@@ -556,9 +583,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
556
583
  itemPool:RemoveCollectible(collectibleType)
557
584
  end
558
585
  repeat
559
- local ____switch104 = activeSlot
560
- local ____cond104 = ____switch104 == ActiveSlot.PRIMARY
561
- if ____cond104 then
586
+ local ____switch108 = activeSlot
587
+ local ____cond108 = ____switch108 == ActiveSlot.PRIMARY
588
+ if ____cond108 then
562
589
  do
563
590
  if primaryCollectibleType ~= CollectibleType.NULL then
564
591
  player:RemoveCollectible(primaryCollectibleType)
@@ -567,8 +594,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
567
594
  break
568
595
  end
569
596
  end
570
- ____cond104 = ____cond104 or ____switch104 == ActiveSlot.SECONDARY
571
- if ____cond104 then
597
+ ____cond108 = ____cond108 or ____switch108 == ActiveSlot.SECONDARY
598
+ if ____cond108 then
572
599
  do
573
600
  if primaryCollectibleType ~= CollectibleType.NULL then
574
601
  player:RemoveCollectible(primaryCollectibleType)
@@ -583,16 +610,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
583
610
  break
584
611
  end
585
612
  end
586
- ____cond104 = ____cond104 or ____switch104 == ActiveSlot.POCKET
587
- if ____cond104 then
613
+ ____cond108 = ____cond108 or ____switch108 == ActiveSlot.POCKET
614
+ if ____cond108 then
588
615
  do
589
616
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
590
617
  player:SetActiveCharge(charge, activeSlot)
591
618
  break
592
619
  end
593
620
  end
594
- ____cond104 = ____cond104 or ____switch104 == ActiveSlot.POCKET_SINGLE_USE
595
- if ____cond104 then
621
+ ____cond108 = ____cond108 or ____switch108 == ActiveSlot.POCKET_SINGLE_USE
622
+ if ____cond108 then
596
623
  do
597
624
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
598
625
  break
@@ -3,7 +3,12 @@
3
3
  /// <reference types="isaac-typescript-definitions" />
4
4
  /// <reference types="isaac-typescript-definitions" />
5
5
  export declare function anyEntityCloserThan(entities: Entity[], position: Vector, distance: int): boolean;
6
- /** Iterates over all players and checks if any player is close enough to the specified position. */
6
+ /**
7
+ * Iterates over all players and checks if any player is close enough to the specified position.
8
+ *
9
+ * Note that this function does not consider players with a non-undefined parent, since they are not
10
+ * real players (e.g. the Strawman Keeper).
11
+ */
7
12
  export declare function anyPlayerCloserThan(position: Vector, distance: float): boolean;
8
13
  /**
9
14
  * Helper function to get a room position that is not overlapping with a grid entity, a heaven door,
@@ -1 +1 @@
1
- {"version":3,"file":"positionVelocity.d.ts","sourceRoot":"","sources":["../../src/functions/positionVelocity.ts"],"names":[],"mappings":";;;;AAaA,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAAE,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,GACZ,OAAO,CAIT;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,KAAK,GACd,OAAO,CAKT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,UAAQ,GAC1B,MAAM,CAiCR;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAY5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAY7E;AA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,EAAE,MAAM,CAAC,EACtC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,IAAI,CAYN"}
@@ -26,6 +26,9 @@ function ____exports.anyEntityCloserThan(self, entities, position, distance)
26
26
  )
27
27
  end
28
28
  --- Iterates over all players and checks if any player is close enough to the specified position.
29
+ --
30
+ -- Note that this function does not consider players with a non-undefined parent, since they are not
31
+ -- real players (e.g. the Strawman Keeper).
29
32
  function ____exports.anyPlayerCloserThan(self, position, distance)
30
33
  local players = getPlayers(nil)
31
34
  return __TS__ArraySome(
@@ -1 +1 @@
1
- {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/functions/set.ts"],"names":[],"mappings":";;AAGA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAC3C,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GACtC,GAAG,CAAC,CAAC,CAAC,CASR;AAED,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAOlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAMN;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EA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CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAOlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAMN;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAC5B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,UAAU,GAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAO,GAClC,CAAC,CAGH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAC5B,iBAAiB,EAAE,OAAO,GACzB,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAK/B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAkBvE;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAGrE"}
@@ -12,6 +12,8 @@ local getRandomArrayElement = ____array.getRandomArrayElement
12
12
  local sumArray = ____array.sumArray
13
13
  local ____rng = require("functions.rng")
14
14
  local getRandomSeed = ____rng.getRandomSeed
15
+ local ____types = require("functions.types")
16
+ local isPrimitive = ____types.isPrimitive
15
17
  --- Helper function to get a sorted array based on the contents of a set.
16
18
  --
17
19
  -- Normally, set values are returned in a random order, so use this function when the ordering of
@@ -19,6 +21,13 @@ local getRandomSeed = ____rng.getRandomSeed
19
21
  function ____exports.getSortedSetValues(self, set)
20
22
  local values = set:values()
21
23
  local array = {__TS__Spread(values)}
24
+ local firstElement = array[1]
25
+ if firstElement ~= nil then
26
+ local arrayType = type(firstElement)
27
+ if not isPrimitive(nil, arrayType) then
28
+ error(("Failed to get the sorted set values because the provided set was of type \"" .. tostring(arrayType)) .. "\". Having sets with non-primitive types doesn't make much sense in general, so you might need to rethink what you are doing.")
29
+ end
30
+ end
22
31
  __TS__ArraySort(array)
23
32
  return array
24
33
  end
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ import { CoinSubType } from 'isaac-typescript-definitions';
16
16
  import { CollectiblePedestalType } from 'isaac-typescript-definitions';
17
17
  import { CollectibleType } from 'isaac-typescript-definitions';
18
18
  import { Controller } from 'isaac-typescript-definitions';
19
+ import { ControllerIndex } from 'isaac-typescript-definitions';
19
20
  import { CrawlSpaceVariant } from 'isaac-typescript-definitions';
20
21
  import { DamageFlag } from 'isaac-typescript-definitions';
21
22
  import { DiceFloorSubType } from 'isaac-typescript-definitions';
@@ -347,7 +348,12 @@ export declare function anyEntityCloserThan(entities: Entity[], position: Vector
347
348
  */
348
349
  export declare type AnyGridEntity = GridEntity | GridEntityDoor | GridEntityPit | GridEntityPoop | GridEntityPressurePlate | GridEntityRock | GridEntitySpikes | GridEntityTNT;
349
350
 
350
- /** Iterates over all players and checks if any player is close enough to the specified position. */
351
+ /**
352
+ * Iterates over all players and checks if any player is close enough to the specified position.
353
+ *
354
+ * Note that this function does not consider players with a non-undefined parent, since they are not
355
+ * real players (e.g. the Strawman Keeper).
356
+ */
351
357
  export declare function anyPlayerCloserThan(position: Vector, distance: float): boolean;
352
358
 
353
359
  export declare function anyPlayerHasCollectible(collectibleType: CollectibleType): boolean;
@@ -4149,6 +4155,16 @@ export declare function getPlayers(performCharacterExclusions?: boolean): Entity
4149
4155
  */
4150
4156
  export declare function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[];
4151
4157
 
4158
+ /**
4159
+ * Helper function to get all of the players that match the provided controller index. This function
4160
+ * returns an array of players because it is possible that there is more than one player with the
4161
+ * same controller index (e.g. Jacob & Esau).
4162
+ *
4163
+ * Note that this function includes players with a non-undefined parent like e.g. the Strawman
4164
+ * Keeper.
4165
+ */
4166
+ export declare function getPlayersOnKeyboard(): EntityPlayer[];
4167
+
4152
4168
  /**
4153
4169
  * Returns the number of soul hearts that the player has, excluding any black hearts. For example,
4154
4170
  * if the player has one full black heart, one full soul heart, and one half black heart, this
@@ -4170,6 +4186,16 @@ export declare function getPlayerStat<T extends StatType>(player: EntityPlayer,
4170
4186
  */
4171
4187
  export declare function getPlayersWithCollectible(...collectibleTypes: CollectibleType[]): EntityPlayer[];
4172
4188
 
4189
+ /**
4190
+ * Helper function to get all of the players that match the provided controller index. This function
4191
+ * returns an array of players because it is possible that there is more than one player with the
4192
+ * same controller index (e.g. Jacob & Esau).
4193
+ *
4194
+ * Note that this function includes players with a non-undefined parent like e.g. the Strawman
4195
+ * Keeper.
4196
+ */
4197
+ export declare function getPlayersWithControllerIndex(controllerIndex: ControllerIndex): EntityPlayer[];
4198
+
4173
4199
  /**
4174
4200
  * Helper function to get only the players that have a certain trinket.
4175
4201
  *
@@ -5434,6 +5460,23 @@ export declare function inDoubleTrouble(): boolean;
5434
5460
 
5435
5461
  export declare function inGenesisRoom(): boolean;
5436
5462
 
5463
+ /**
5464
+ * Initializes an array with all of the elements containing the specified default value.
5465
+ *
5466
+ * If the provided default value is not a boolean, number, or string, then it will be copied with
5467
+ * the `deepCopy` function before adding it to the new array. In this way, you can initialize an
5468
+ * array of arrays, or an array of maps, and so on. (If the `deepCopy` function was not used, then
5469
+ * all of the array elements would just be references to the same underlying data structure.)
5470
+ *
5471
+ * For example:
5472
+ *
5473
+ * ```ts
5474
+ * const arrayWithZeroes = initArray(0, 10); // Has 10 elements of 0.
5475
+ * const arrayWithArrays = initArray([0], 20); // Has 20 elements of an array with a 0 in it.
5476
+ * ```
5477
+ */
5478
+ export declare function initArray<T>(defaultValue: T, size: int): T[];
5479
+
5437
5480
  /**
5438
5481
  * `isaacscript-common` provides custom doors that can be spawned where any wall segment is. If you
5439
5482
  * use this feature, you must first call this initialization function at the beginning of your mod.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yCAAyC,CAAC;AACxD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4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AAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,mBAAmB,CAAC"}
package/dist/index.lua CHANGED
@@ -687,6 +687,14 @@ do
687
687
  end
688
688
  end
689
689
  end
690
+ do
691
+ local ____export = require("functions.initArray")
692
+ for ____exportKey, ____exportValue in pairs(____export) do
693
+ if ____exportKey ~= "default" then
694
+ ____exports[____exportKey] = ____exportValue
695
+ end
696
+ end
697
+ end
690
698
  do
691
699
  local ____export = require("functions.input")
692
700
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "9.12.0",
3
+ "version": "9.13.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -10,7 +10,7 @@ import {
10
10
  } from "isaac-typescript-definitions";
11
11
  import { game } from "../core/cachedClasses";
12
12
  import { saveDataManager } from "../features/saveDataManager/exports";
13
- import { getPlayers } from "../functions/playerIndex";
13
+ import { getPlayersWithControllerIndex } from "../functions/players";
14
14
  import {
15
15
  postEsauJrFire,
16
16
  postEsauJrHasSubscriptions,
@@ -65,8 +65,12 @@ function postUpdate() {
65
65
  if (v.run.usedEsauJrControllerIndex === null) {
66
66
  return;
67
67
  }
68
- const player = getPlayerWithControllerIndex(v.run.usedEsauJrControllerIndex);
68
+ const players = getPlayersWithControllerIndex(
69
+ v.run.usedEsauJrControllerIndex,
70
+ );
69
71
  v.run.usedEsauJrControllerIndex = null;
72
+
73
+ const player = players[0];
70
74
  if (player === undefined) {
71
75
  return;
72
76
  }
@@ -79,11 +83,6 @@ function postUpdate() {
79
83
  postEsauJrFire(player);
80
84
  }
81
85
 
82
- function getPlayerWithControllerIndex(controllerIndex: ControllerIndex) {
83
- const players = getPlayers();
84
- return players.find((player) => player.ControllerIndex === controllerIndex);
85
- }
86
-
87
86
  // ModCallback.POST_USE_ITEM (3)
88
87
  // CollectibleType.ESAU_JR (703)
89
88
  function useItemEsauJr(
@@ -47,7 +47,7 @@ export function getOtherPlayers(player: EntityPlayer): EntityPlayer[] {
47
47
  export function getPlayerFromIndex(
48
48
  playerIndex: PlayerIndex,
49
49
  ): EntityPlayer | undefined {
50
- const players = getPlayers();
50
+ const players = getAllPlayers();
51
51
  return players.find((player) => getPlayerIndex(player) === playerIndex);
52
52
  }
53
53
 
@@ -2,6 +2,7 @@ import {
2
2
  ActiveSlot,
3
3
  Challenge,
4
4
  CollectibleType,
5
+ ControllerIndex,
5
6
  FamiliarVariant,
6
7
  NullItemID,
7
8
  PlayerForm,
@@ -347,6 +348,21 @@ export function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[] {
347
348
  });
348
349
  }
349
350
 
351
+ /**
352
+ * Helper function to get all of the players that match the provided controller index. This function
353
+ * returns an array of players because it is possible that there is more than one player with the
354
+ * same controller index (e.g. Jacob & Esau).
355
+ *
356
+ * Note that this function includes players with a non-undefined parent like e.g. the Strawman
357
+ * Keeper.
358
+ */
359
+ export function getPlayersOnKeyboard(): EntityPlayer[] {
360
+ const players = getAllPlayers();
361
+ return players.filter(
362
+ (player) => player.ControllerIndex === ControllerIndex.KEYBOARD,
363
+ );
364
+ }
365
+
350
366
  /**
351
367
  * Helper function to get only the players that have a certain collectible.
352
368
  *
@@ -364,6 +380,21 @@ export function getPlayersWithCollectible(
364
380
  );
365
381
  }
366
382
 
383
+ /**
384
+ * Helper function to get all of the players that match the provided controller index. This function
385
+ * returns an array of players because it is possible that there is more than one player with the
386
+ * same controller index (e.g. Jacob & Esau).
387
+ *
388
+ * Note that this function includes players with a non-undefined parent like e.g. the Strawman
389
+ * Keeper.
390
+ */
391
+ export function getPlayersWithControllerIndex(
392
+ controllerIndex: ControllerIndex,
393
+ ): EntityPlayer[] {
394
+ const players = getAllPlayers();
395
+ return players.filter((player) => player.ControllerIndex === controllerIndex);
396
+ }
397
+
367
398
  /**
368
399
  * Helper function to get only the players that have a certain trinket.
369
400
  *
@@ -21,7 +21,12 @@ export function anyEntityCloserThan(
21
21
  );
22
22
  }
23
23
 
24
- /** Iterates over all players and checks if any player is close enough to the specified position. */
24
+ /**
25
+ * Iterates over all players and checks if any player is close enough to the specified position.
26
+ *
27
+ * Note that this function does not consider players with a non-undefined parent, since they are not
28
+ * real players (e.g. the Strawman Keeper).
29
+ */
25
30
  export function anyPlayerCloserThan(
26
31
  position: Vector,
27
32
  distance: float,
@@ -1,5 +1,6 @@
1
1
  import { getArrayCombinations, getRandomArrayElement, sumArray } from "./array";
2
2
  import { getRandomSeed } from "./rng";
3
+ import { isPrimitive } from "./types";
3
4
 
4
5
  /**
5
6
  * Helper function to add all of the values in one set to another set. The first set passed will be
@@ -118,6 +119,18 @@ export function getSetCombinations<T>(
118
119
  export function getSortedSetValues<T>(set: Set<T> | ReadonlySet<T>): T[] {
119
120
  const values = set.values();
120
121
  const array = [...values];
122
+
123
+ // Check for problematic types in order to throw a helpful error message.
124
+ const firstElement = array[0];
125
+ if (firstElement !== undefined) {
126
+ const arrayType = type(firstElement);
127
+ if (!isPrimitive(arrayType)) {
128
+ error(
129
+ `Failed to get the sorted set values because the provided set was of type "${arrayType}". Having sets with non-primitive types doesn't make much sense in general, so you might need to rethink what you are doing.`,
130
+ );
131
+ }
132
+ }
133
+
121
134
  array.sort();
122
135
 
123
136
  return array;
package/src/index.ts CHANGED
@@ -84,6 +84,7 @@ export * from "./functions/globals";
84
84
  export * from "./functions/gridEntities";
85
85
  export * from "./functions/gridEntitiesSpecific";
86
86
  export * from "./functions/hex";
87
+ export * from "./functions/initArray";
87
88
  export * from "./functions/input";
88
89
  export * from "./functions/isaacAPIClass";
89
90
  export * from "./functions/itemPool";