isaacscript-common 1.2.46 → 1.2.49

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.
@@ -29,7 +29,7 @@ function postPEffectUpdateReordered(self, player)
29
29
  end
30
30
  if character ~= storedCharacter then
31
31
  v.run.characterMap:set(playerIndex, character)
32
- postPlayerChangeTypeFire(nil, player, character)
32
+ postPlayerChangeTypeFire(nil, player, storedCharacter, character)
33
33
  end
34
34
  end
35
35
  v = {run = {characterMap = __TS__New(Map)}}
@@ -6,7 +6,7 @@ local hasSubscriptions, postPEffectUpdate, postPlayerInit, postPlayerUpdate, pos
6
6
  local ____exports = require("features.saveDataManager.exports")
7
7
  local saveDataManager = ____exports.saveDataManager
8
8
  local ____array = require("functions.array")
9
- local arrayEmpty = ____array.arrayEmpty
9
+ local emptyArray = ____array.emptyArray
10
10
  local ____player = require("functions.player")
11
11
  local getPlayerFromIndex = ____player.getPlayerFromIndex
12
12
  local getPlayerIndex = ____player.getPlayerIndex
@@ -89,7 +89,7 @@ function dequeue(self, playerIndexes, fireFunction)
89
89
  end
90
90
  ::__continue23::
91
91
  end
92
- arrayEmpty(nil, playerIndexes)
92
+ emptyArray(nil, playerIndexes)
93
93
  end
94
94
  v = {run = {
95
95
  postGameStartedFiredOnThisRun = false,
@@ -2,13 +2,14 @@
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
5
6
  local Map = ____lualib.Map
6
7
  local ____exports = {}
7
- local hasSubscriptions, postPEffectUpdateReordered, UNUSED_TRANSFORMATIONS, v
8
+ local hasSubscriptions, postPEffectUpdateReordered, playerTransformationChanged, updateForgottenOrSoulTransformation, TRANSFORMATIONS, v
8
9
  local ____exports = require("features.saveDataManager.exports")
9
10
  local saveDataManager = ____exports.saveDataManager
10
11
  local ____array = require("functions.array")
11
- local arrayInit = ____array.arrayInit
12
+ local copyArray = ____array.copyArray
12
13
  local ____player = require("functions.player")
13
14
  local getPlayerIndex = ____player.getPlayerIndex
14
15
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
@@ -23,32 +24,59 @@ function postPEffectUpdateReordered(self, player)
23
24
  if not hasSubscriptions(nil) then
24
25
  return
25
26
  end
26
- local index = getPlayerIndex(nil, player)
27
- local transformations = v.run.transformations:get(index)
27
+ local playerIndex = getPlayerIndex(nil, player)
28
+ local transformations = v.run.transformations:get(playerIndex)
28
29
  if transformations == nil then
29
- transformations = arrayInit(nil, false, PlayerForm.NUM_PLAYER_FORMS - 1)
30
- v.run.transformations:set(index, transformations)
30
+ transformations = __TS__New(Map)
31
+ v.run.transformations:set(playerIndex, transformations)
31
32
  end
32
- do
33
- local playerForm = 0
34
- while playerForm < PlayerForm.NUM_PLAYER_FORMS do
35
- do
36
- if UNUSED_TRANSFORMATIONS:has(playerForm) then
37
- goto __continue7
38
- end
39
- local hasForm = player:HasPlayerForm(playerForm)
40
- local storedForm = transformations[playerForm + 1]
41
- if hasForm ~= storedForm then
42
- transformations[playerForm + 1] = hasForm
43
- postTransformationFire(nil, player, playerForm, hasForm)
44
- end
33
+ for ____, playerForm in ipairs(TRANSFORMATIONS) do
34
+ local hasForm = player:HasPlayerForm(playerForm)
35
+ local storedForm = transformations:get(playerForm)
36
+ if storedForm == nil then
37
+ local defaultValue = false
38
+ storedForm = defaultValue
39
+ transformations:set(playerForm, defaultValue)
40
+ end
41
+ if hasForm ~= storedForm then
42
+ transformations:set(playerForm, hasForm)
43
+ playerTransformationChanged(nil, player, playerForm, hasForm)
44
+ end
45
+ end
46
+ end
47
+ function playerTransformationChanged(self, player, playerForm, hasForm)
48
+ postTransformationFire(nil, player, playerForm, hasForm)
49
+ updateForgottenOrSoulTransformation(nil, player, playerForm, hasForm)
50
+ end
51
+ function updateForgottenOrSoulTransformation(self, player, playerForm, hasForm)
52
+ local subPlayer = player:GetSubPlayer()
53
+ if subPlayer == nil then
54
+ return
55
+ end
56
+ local subPlayerIndex = getPlayerIndex(nil, subPlayer)
57
+ local transformations = v.run.transformations:get(subPlayerIndex)
58
+ if transformations == nil then
59
+ transformations = __TS__New(Map)
60
+ v.run.transformations:set(subPlayerIndex, transformations)
61
+ end
62
+ transformations:set(playerForm, hasForm)
63
+ end
64
+ local UNUSED_TRANSFORMATIONS = __TS__New(Set, {PlayerForm.PLAYERFORM_FLIGHT})
65
+ local tempTransformations = {}
66
+ do
67
+ local playerForm = 0
68
+ while playerForm < PlayerForm.NUM_PLAYER_FORMS do
69
+ do
70
+ if UNUSED_TRANSFORMATIONS:has(playerForm) then
71
+ goto __continue2
45
72
  end
46
- ::__continue7::
47
- playerForm = playerForm + 1
73
+ __TS__ArrayPush(tempTransformations, playerForm)
48
74
  end
75
+ ::__continue2::
76
+ playerForm = playerForm + 1
49
77
  end
50
78
  end
51
- UNUSED_TRANSFORMATIONS = __TS__New(Set, {PlayerForm.PLAYERFORM_FLIGHT})
79
+ TRANSFORMATIONS = copyArray(nil, tempTransformations)
52
80
  v = {run = {transformations = __TS__New(Map)}}
53
81
  function ____exports.postTransformationCallbackInit(self, mod)
54
82
  saveDataManager(nil, "postTransformation", v, hasSubscriptions)
@@ -1,2 +1,2 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- export declare type PostPlayerChangeTypeCallbackType = (player: EntityPlayer, character: PlayerType) => void;
2
+ export declare type PostPlayerChangeTypeCallbackType = (player: EntityPlayer, oldCharacter: PlayerType | int, newCharacter: PlayerType | int) => void;
@@ -9,10 +9,10 @@ end
9
9
  function ____exports.postPlayerChangeTypeRegister(self, callback)
10
10
  __TS__ArrayPush(subscriptions, {callback})
11
11
  end
12
- function ____exports.postPlayerChangeTypeFire(self, player, character)
12
+ function ____exports.postPlayerChangeTypeFire(self, player, oldCharacter, newCharacter)
13
13
  for ____, ____value in ipairs(subscriptions) do
14
14
  local callback = ____value[1]
15
- callback(nil, player, character)
15
+ callback(nil, player, oldCharacter, newCharacter)
16
16
  end
17
17
  end
18
18
  return ____exports
@@ -9,7 +9,7 @@ local ____deepCopy = require("functions.deepCopy")
9
9
  local deepCopy = ____deepCopy.deepCopy
10
10
  local SerializationType = ____deepCopy.SerializationType
11
11
  local ____table = require("functions.table")
12
- local tableClear = ____table.tableClear
12
+ local clearTable = ____table.clearTable
13
13
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
14
14
  local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
15
15
  local ____SaveData = require("types.SaveData")
@@ -85,7 +85,7 @@ function restoreDefaults(self, childTableName)
85
85
  end
86
86
  end
87
87
  function clearAndCopyAllElements(self, oldTable, newTable)
88
- tableClear(nil, oldTable)
88
+ clearTable(nil, oldTable)
89
89
  for key, value in pairs(newTable) do
90
90
  oldTable[key] = value
91
91
  end
@@ -21,7 +21,7 @@ local SerializationType = ____deepCopy.SerializationType
21
21
  local ____log = require("functions.log")
22
22
  local log = ____log.log
23
23
  local ____table = require("functions.table")
24
- local tableClear = ____table.tableClear
24
+ local clearTable = ____table.clearTable
25
25
  function ____exports.merge(self, oldObject, newTable, traversalDescription)
26
26
  local oldObjectType = type(oldObject)
27
27
  if oldObjectType ~= "table" then
@@ -48,7 +48,7 @@ function mergeArray(self, oldObject, newTable)
48
48
  if not isArray(nil, oldArray) or not isArray(nil, newTable) then
49
49
  return false
50
50
  end
51
- tableClear(nil, oldArray)
51
+ clearTable(nil, oldArray)
52
52
  for key, value in pairs(newTable) do
53
53
  oldArray[key] = value
54
54
  end
@@ -1,20 +1,19 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
3
  /**
4
- * Helper function to combine arrays. Returns a new array that is the composition of all of the
5
- * specified arrays. This function is variadic, meaning that you can specify N arguments to combine
6
- * N arrays. Note that this will only perform a shallow copy of the array elements.
4
+ * Helper function to combine two or more arrays. Returns a new array that is the composition of all
5
+ * of the specified arrays. This function is variadic, meaning that you can specify N arguments to
6
+ * combine N arrays. Note that this will only perform a shallow copy of the array elements.
7
7
  */
8
- export declare function arrayCombine<T>(...arrays: Array<T[] | readonly T[]>): T[];
8
+ export declare function combineArray<T>(...arrays: Array<T[] | readonly T[]>): T[];
9
9
  /** Helper function to perform a shallow copy. */
10
- export declare function arrayCopy<T>(array: T[] | readonly T[]): T[];
11
- export declare function arrayEmpty<T>(array: T[]): void;
10
+ export declare function copyArray<T>(array: T[] | readonly T[]): T[];
11
+ export declare function emptyArray<T>(array: T[]): void;
12
12
  /**
13
13
  * Helper function for determining if two arrays contain the exact same elements. Note that this
14
14
  * only performs a shallow comparison.
15
15
  */
16
16
  export declare function arrayEquals<T>(array1: T[] | readonly T[], array2: T[] | readonly T[]): boolean;
17
- export declare function arrayInArray<T>(arrayToMatch: T[] | readonly T[], parentArray: Array<T[] | readonly T[]>): boolean;
18
17
  /**
19
18
  * Initializes an array with all elements containing the specified default value.
20
19
  *
@@ -23,20 +22,21 @@ export declare function arrayInArray<T>(arrayToMatch: T[] | readonly T[], parent
23
22
  * const playerTransformations = initArray(false, PlayerForm.NUM_PLAYER_FORMS - 1);
24
23
  * ```
25
24
  */
26
- export declare function arrayInit<T>(defaultValue: T, size: int): T[];
25
+ export declare function initArray<T>(defaultValue: T, size: int): T[];
26
+ export declare function isArrayInArray<T>(arrayToMatch: T[] | readonly T[], parentArray: Array<T[] | readonly T[]>): boolean;
27
27
  /**
28
28
  * Shallow copies and shuffles the array using the Fisher-Yates algorithm. Returns the copied array.
29
29
  *
30
30
  * From: https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
31
31
  */
32
- export declare function arrayShuffle<T>(originalArray: T[] | readonly T[], seed?: number): T[];
32
+ export declare function shuffleArray<T>(originalArray: T[] | readonly T[], seed?: number): T[];
33
33
  /**
34
34
  * Shuffles the provided array in-place using the Fisher-Yates algorithm.
35
35
  *
36
36
  * From: https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
37
37
  */
38
- export declare function arrayShuffleInPlace<T>(array: T[], seed?: number): void;
39
- export declare function arraySum(array: number[] | readonly number[]): number;
38
+ export declare function shuffleArrayInPlace<T>(array: T[], seed?: number): void;
39
+ export declare function sumArray(array: number[] | readonly number[]): number;
40
40
  export declare function arrayToString<T>(array: T[]): string;
41
41
  /**
42
42
  * Shallow copies and removes the specified element(s) from the array. Returns the copied array. If
@@ -11,7 +11,7 @@ local ____exports = {}
11
11
  local ____random = require("functions.random")
12
12
  local getRandomInt = ____random.getRandomInt
13
13
  local nextSeed = ____random.nextSeed
14
- function ____exports.arrayShuffleInPlace(self, array, seed)
14
+ function ____exports.shuffleArrayInPlace(self, array, seed)
15
15
  if seed == nil then
16
16
  seed = Random()
17
17
  end
@@ -36,7 +36,7 @@ function ____exports.getRandomArrayIndex(self, array, seed)
36
36
  local randomIndex = getRandomInt(nil, 0, #array - 1, seed)
37
37
  return randomIndex
38
38
  end
39
- function ____exports.arrayCombine(self, ...)
39
+ function ____exports.combineArray(self, ...)
40
40
  local arrays = {...}
41
41
  local elements = {}
42
42
  for ____, array in ipairs(arrays) do
@@ -46,10 +46,10 @@ function ____exports.arrayCombine(self, ...)
46
46
  end
47
47
  return elements
48
48
  end
49
- function ____exports.arrayCopy(self, array)
49
+ function ____exports.copyArray(self, array)
50
50
  return {table.unpack(array)}
51
51
  end
52
- function ____exports.arrayEmpty(self, array)
52
+ function ____exports.emptyArray(self, array)
53
53
  __TS__ArraySplice(array, 0, #array)
54
54
  end
55
55
  function ____exports.arrayEquals(self, array1, array2)
@@ -64,13 +64,7 @@ function ____exports.arrayEquals(self, array1, array2)
64
64
  end
65
65
  )
66
66
  end
67
- function ____exports.arrayInArray(self, arrayToMatch, parentArray)
68
- return __TS__ArraySome(
69
- parentArray,
70
- function(____, element) return ____exports.arrayEquals(nil, element, arrayToMatch) end
71
- )
72
- end
73
- function ____exports.arrayInit(self, defaultValue, size)
67
+ function ____exports.initArray(self, defaultValue, size)
74
68
  local array = {}
75
69
  do
76
70
  local i = 0
@@ -81,15 +75,21 @@ function ____exports.arrayInit(self, defaultValue, size)
81
75
  end
82
76
  return array
83
77
  end
84
- function ____exports.arrayShuffle(self, originalArray, seed)
78
+ function ____exports.isArrayInArray(self, arrayToMatch, parentArray)
79
+ return __TS__ArraySome(
80
+ parentArray,
81
+ function(____, element) return ____exports.arrayEquals(nil, element, arrayToMatch) end
82
+ )
83
+ end
84
+ function ____exports.shuffleArray(self, originalArray, seed)
85
85
  if seed == nil then
86
86
  seed = Random()
87
87
  end
88
- local array = ____exports.arrayCopy(nil, originalArray)
89
- ____exports.arrayShuffleInPlace(nil, array, seed)
88
+ local array = ____exports.copyArray(nil, originalArray)
89
+ ____exports.shuffleArrayInPlace(nil, array, seed)
90
90
  return array
91
91
  end
92
- function ____exports.arraySum(self, array)
92
+ function ____exports.sumArray(self, array)
93
93
  return __TS__ArrayReduce(
94
94
  array,
95
95
  function(____, accumulator, element) return accumulator + element end,
@@ -109,7 +109,7 @@ function ____exports.arrayToString(self, array)
109
109
  end
110
110
  function ____exports.arrayRemove(self, originalArray, ...)
111
111
  local elements = {...}
112
- local array = ____exports.arrayCopy(nil, originalArray)
112
+ local array = ____exports.copyArray(nil, originalArray)
113
113
  for ____, element in ipairs(elements) do
114
114
  local index = __TS__ArrayIndexOf(array, element)
115
115
  if index > -1 then
@@ -5,7 +5,7 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
5
5
  local ____exports = {}
6
6
  local getTotalWeightOfJSONRooms, getJSONRoomWithChosenWeight
7
7
  local ____array = require("functions.array")
8
- local arraySum = ____array.arraySum
8
+ local sumArray = ____array.sumArray
9
9
  local ____log = require("functions.log")
10
10
  local log = ____log.log
11
11
  local ____random = require("functions.random")
@@ -22,7 +22,7 @@ function getTotalWeightOfJSONRooms(self, jsonRooms)
22
22
  return roomWeight
23
23
  end
24
24
  )
25
- return arraySum(nil, weights)
25
+ return sumArray(nil, weights)
26
26
  end
27
27
  function getJSONRoomWithChosenWeight(self, jsonRooms, chosenWeight)
28
28
  for ____, jsonRoom in ipairs(jsonRooms) do
@@ -25,26 +25,26 @@ export declare function anyPlayerHasTrinket(trinketType: TrinketType | int): boo
25
25
  * This function is variadic, meaning that you can supply as many characters as you want to check
26
26
  * for. Returns true if any of the characters supplied are present.
27
27
  */
28
- export declare function anyPlayerIs(...matchingCharacters: PlayerType[]): boolean;
28
+ export declare function anyPlayerIs(...matchingCharacters: Array<PlayerType | int>): boolean;
29
29
  /**
30
30
  * Helper function to determine if the provided character can have red heart containers. Returns
31
31
  * true for characters like Isaac, Magdalene, or Cain. Returns true for Keeper and Tainted Keeper,
32
32
  * even though coin containers are not technically the same as red heart containers. Returns false
33
33
  * for characters like Blue Baby. Returns false for The Lost and Tainted Lost.
34
34
  */
35
- export declare function characterCanHaveRedHearts(character: PlayerType): boolean;
35
+ export declare function characterCanHaveRedHearts(character: PlayerType | int): boolean;
36
36
  /**
37
37
  * Helper function to determine if the provided character can have soul hearts. Returns true for
38
38
  * characters like Isaac, Magdalene, or Cain. Returns false for characters like Bethany. Returns
39
39
  * false for The Lost and Tainted Lost.
40
40
  */
41
- export declare function characterCanHaveSoulHearts(character: PlayerType): boolean;
41
+ export declare function characterCanHaveSoulHearts(character: PlayerType | int): boolean;
42
42
  /**
43
43
  * Normally, characters get a red heart container upon reaching a new floor with an eternal heart,
44
44
  * but some characters grant a black heart instead. Returns true for Dark Judas and Tainted Judas.
45
45
  * Otherwise, returns false.
46
46
  */
47
- export declare function characterGetsBlackHeartFromEternalHeart(character: PlayerType): boolean;
47
+ export declare function characterGetsBlackHeartFromEternalHeart(character: PlayerType | int): boolean;
48
48
  /**
49
49
  * Helper function to get how long Azazel's Brimstone laser should be. You can pass either an
50
50
  * `EntityPlayer` object or a tear height stat.
@@ -86,7 +86,7 @@ export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
86
86
  * but with Keeper it is 3, with Tainted Keeper it is 2. Does not account for Birthright or Mother's
87
87
  * Kiss; use the `getPlayerMaxHeartContainers()` function for that.
88
88
  */
89
- export declare function getCharacterMaxHeartContainers(character: PlayerType): int;
89
+ export declare function getCharacterMaxHeartContainers(character: PlayerType | int): int;
90
90
  /** Helper function to get an array containing the characters of all of the current players. */
91
91
  export declare function getCharacters(): number[];
92
92
  /**
@@ -170,7 +170,7 @@ export declare function getPlayers(performExclusions?: boolean): EntityPlayer[];
170
170
  * This function is variadic, meaning that you can supply as many characters as you want to check
171
171
  * for. Returns true if any of the characters supplied are present.
172
172
  */
173
- export declare function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[];
173
+ export declare function getPlayersOfType(...characters: Array<PlayerType | int>): EntityPlayer[];
174
174
  /**
175
175
  * Helper function to return the active charge and the battery charge combined. This is useful
176
176
  * because you are not able to set the battery charge directly.
@@ -203,7 +203,7 @@ export declare function isBethany(player: EntityPlayer): boolean;
203
203
  */
204
204
  export declare function isChildPlayer(player: EntityPlayer): boolean;
205
205
  /** Uses the player's current health and character to determine if incoming damage will be fatal. */
206
- export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageFrame: int | undefined): boolean;
206
+ export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageFrame?: int): boolean;
207
207
  export declare function isFirstPlayer(player: EntityPlayer): boolean;
208
208
  /**
209
209
  * Helper function for detecting when a player is Jacob or Esau. This will only match the
@@ -21,7 +21,7 @@ local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
21
21
  local ____HealthType = require("types.HealthType")
22
22
  local HealthType = ____HealthType.HealthType
23
23
  local ____array = require("functions.array")
24
- local arraySum = ____array.arraySum
24
+ local sumArray = ____array.sumArray
25
25
  local ____bitwise = require("functions.bitwise")
26
26
  local getKBitOfN = ____bitwise.getKBitOfN
27
27
  local getNumBitsOfN = ____bitwise.getNumBitsOfN
@@ -433,7 +433,7 @@ function ____exports.getTotalPlayerCollectibles(self, collectibleType)
433
433
  players,
434
434
  function(____, player) return player:GetCollectibleNum(collectibleType) end
435
435
  )
436
- return arraySum(nil, numCollectiblesArray)
436
+ return sumArray(nil, numCollectiblesArray)
437
437
  end
438
438
  function ____exports.hasLostCurse(self, player)
439
439
  local effects = player:GetEffects()
@@ -3,4 +3,4 @@
3
3
  * In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
4
4
  * `clear` method does not exist. Use this helper function as a drop-in replacement for this.
5
5
  */
6
- export declare function tableClear(table: LuaTable): void;
6
+ export declare function clearTable(table: LuaTable): void;
@@ -1,6 +1,6 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- function ____exports.tableClear(self, ____table)
3
+ function ____exports.clearTable(self, ____table)
4
4
  for key in pairs(____table) do
5
5
  ____table[key] = nil
6
6
  end
@@ -63,7 +63,7 @@ export interface CallbackParametersCustom {
63
63
  ];
64
64
  [ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED]: [
65
65
  callback: PostPEffectUpdateReorderedCallbackType,
66
- character?: PlayerType
66
+ character?: PlayerType | int
67
67
  ];
68
68
  [ModCallbacksCustom.MC_POST_PLAYER_UPDATE_REORDERED]: [
69
69
  callback: PostPlayerUpdateReorderedCallbackType,
@@ -115,7 +115,7 @@ export interface CallbackParametersCustom {
115
115
  ];
116
116
  [ModCallbacksCustom.MC_POST_NPC_INIT_LATE]: [
117
117
  callback: PostNPCInitLateCallbackType,
118
- entityType?: EntityType
118
+ entityType?: EntityType | int
119
119
  ];
120
120
  [ModCallbacksCustom.MC_POST_EFFECT_INIT_LATE]: [
121
121
  callback: PostEffectInitLateCallbackType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.46",
3
+ "version": "1.2.49",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",