isaacscript-common 3.16.0 → 4.0.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.
Files changed (39) hide show
  1. package/callbacks/subscriptions/postPlayerCollectibleAdded.d.ts +2 -3
  2. package/callbacks/subscriptions/postPlayerCollectibleAdded.lua +2 -7
  3. package/callbacks/subscriptions/postPlayerCollectibleRemoved.d.ts +2 -3
  4. package/callbacks/subscriptions/postPlayerCollectibleRemoved.lua +2 -7
  5. package/callbacks/subscriptions/preBerserkDeath.d.ts +1 -1
  6. package/classes/ModUpgraded.d.ts +3 -3
  7. package/classes/ModUpgraded.lua +3 -6
  8. package/constants.d.ts +1 -1
  9. package/constants.lua +1 -1
  10. package/enums/ModCallbackCustom.d.ts +20 -18
  11. package/features/extraConsoleCommands/commandsSubroutines.lua +1 -1
  12. package/functions/cards.lua +1 -1
  13. package/functions/color.d.ts +1 -1
  14. package/functions/debug.lua +2 -2
  15. package/functions/doors.lua +1 -2
  16. package/functions/globals.d.ts +3 -3
  17. package/functions/globals.lua +8 -2
  18. package/functions/kColor.d.ts +1 -1
  19. package/functions/pills.lua +1 -1
  20. package/functions/playerHealth.d.ts +2 -0
  21. package/functions/playerHealth.lua +45 -0
  22. package/functions/rng.d.ts +1 -1
  23. package/functions/rooms.lua +1 -3
  24. package/functions/serialization.lua +0 -3
  25. package/functions/transformations.lua +1 -3
  26. package/functions/vector.d.ts +1 -1
  27. package/interfaces/JSONDoor.d.ts +1 -1
  28. package/interfaces/JSONEntity.d.ts +1 -1
  29. package/interfaces/JSONRoom.d.ts +1 -1
  30. package/interfaces/JSONSpawn.d.ts +1 -1
  31. package/package.json +2 -2
  32. package/types/CollectibleIndex.d.ts +1 -1
  33. package/types/PickingUpItem.d.ts +3 -3
  34. package/types/PlayerIndex.d.ts +1 -1
  35. package/types/private/IsaacAPIClass.d.ts +1 -1
  36. package/types/private/SerializedIsaacAPIClass.d.ts +1 -1
  37. package/types/private/TSTLClass.d.ts +1 -1
  38. package/upgradeMod.d.ts +2 -2
  39. package/upgradeMod.lua +2 -2
@@ -1,6 +1,5 @@
1
- import { CollectibleType, PlayerType, PlayerVariant } from "isaac-typescript-definitions";
1
+ import { CollectibleType } from "isaac-typescript-definitions";
2
2
  export declare type PostPlayerCollectibleAddedRegisterParameters = [
3
3
  callback: (player: EntityPlayer, collectibleType: CollectibleType) => void,
4
- playerVariant?: PlayerVariant,
5
- character?: PlayerType
4
+ collectibleType?: CollectibleType
6
5
  ];
@@ -14,16 +14,11 @@ end
14
14
  ---
15
15
  -- @internal
16
16
  function ____exports.postPlayerCollectibleAddedFire(self, player, collectibleType)
17
- local character = player:GetPlayerType()
18
17
  for ____, ____value in ipairs(subscriptions) do
19
18
  local callback = ____value[1]
20
- local playerVariant = ____value[2]
21
- local callbackCharacter = ____value[3]
19
+ local callbackCollectibleType = ____value[2]
22
20
  do
23
- if playerVariant ~= nil and playerVariant ~= player.Variant then
24
- goto __continue5
25
- end
26
- if callbackCharacter ~= nil and callbackCharacter ~= character then
21
+ if callbackCollectibleType ~= nil and callbackCollectibleType ~= collectibleType then
27
22
  goto __continue5
28
23
  end
29
24
  callback(nil, player, collectibleType)
@@ -1,6 +1,5 @@
1
- import { CollectibleType, PlayerType, PlayerVariant } from "isaac-typescript-definitions";
1
+ import { CollectibleType } from "isaac-typescript-definitions";
2
2
  export declare type PostPlayerCollectibleRemovedRegisterParameters = [
3
3
  callback: (player: EntityPlayer, collectibleType: CollectibleType) => void,
4
- playerVariant?: PlayerVariant,
5
- character?: PlayerType
4
+ collectibleType?: CollectibleType
6
5
  ];
@@ -14,16 +14,11 @@ end
14
14
  ---
15
15
  -- @internal
16
16
  function ____exports.postPlayerCollectibleRemovedFire(self, player, collectibleType)
17
- local character = player:GetPlayerType()
18
17
  for ____, ____value in ipairs(subscriptions) do
19
18
  local callback = ____value[1]
20
- local playerVariant = ____value[2]
21
- local callbackCharacter = ____value[3]
19
+ local callbackCollectibleType = ____value[2]
22
20
  do
23
- if playerVariant ~= nil and playerVariant ~= player.Variant then
24
- goto __continue5
25
- end
26
- if callbackCharacter ~= nil and callbackCharacter ~= character then
21
+ if callbackCollectibleType ~= nil and callbackCollectibleType ~= collectibleType then
27
22
  goto __continue5
28
23
  end
29
24
  callback(nil, player, collectibleType)
@@ -1,6 +1,6 @@
1
1
  import { PlayerType, PlayerVariant } from "isaac-typescript-definitions";
2
2
  export declare type PreBerserkDeathRegisterParameters = [
3
- callback: (player: EntityPlayer) => boolean | void,
3
+ callback: (player: EntityPlayer) => void,
4
4
  playerVariant?: PlayerVariant,
5
5
  character?: PlayerType
6
6
  ];
@@ -2,9 +2,9 @@ import { ModCallback } from "isaac-typescript-definitions";
2
2
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
3
3
  import { AddCallbackParameterCustom } from "../interfaces/AddCallbackParameterCustom";
4
4
  /**
5
- * `isaacscript-common` has many {@link ModCallbackCustom custom callbacks} that you can use in your
6
- * mods. Instead of hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to
7
- * use, which extends the base class and adds a new method of `AddCallbackCustom`.
5
+ * `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
6
+ * hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
7
+ * extends the base class and adds a new method of `AddCallbackCustom`.
8
8
  *
9
9
  * To upgrade your mod, use the `upgradeMod` helper function.
10
10
  */
@@ -3,9 +3,9 @@ local __TS__Class = ____lualib.__TS__Class
3
3
  local ____exports = {}
4
4
  local ____callbackRegisterFunctions = require("objects.callbackRegisterFunctions")
5
5
  local CALLBACK_REGISTER_FUNCTIONS = ____callbackRegisterFunctions.CALLBACK_REGISTER_FUNCTIONS
6
- --- `isaacscript-common` has many {@link ModCallbackCustomcustom callbacks} that you can use in your
7
- -- mods. Instead of hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to
8
- -- use, which extends the base class and adds a new method of `AddCallbackCustom`.
6
+ --- `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
7
+ -- hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
8
+ -- extends the base class and adds a new method of `AddCallbackCustom`.
9
9
  --
10
10
  -- To upgrade your mod, use the `upgradeMod` helper function.
11
11
  ____exports.ModUpgraded = __TS__Class()
@@ -35,9 +35,6 @@ function ModUpgraded.prototype.SaveData(self, data)
35
35
  end
36
36
  function ModUpgraded.prototype.AddCallbackCustom(self, modCallbackCustom, ...)
37
37
  local callbackRegisterFunction = CALLBACK_REGISTER_FUNCTIONS[modCallbackCustom]
38
- if callbackRegisterFunction == nil then
39
- error("Failed to find a callback registration function for custom callback: " .. tostring(modCallbackCustom))
40
- end
41
38
  callbackRegisterFunction(nil, ...)
42
39
  end
43
40
  return ____exports
package/constants.d.ts CHANGED
@@ -15,7 +15,7 @@ export declare const BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.
15
15
  /** Bombs explode when their frame count is equal to this value. */
16
16
  export declare const BOMB_EXPLODE_FRAME = 45;
17
17
  /** This is the initial value of the `EntityPickup.Wait` property after a collectible is spawned. */
18
- export declare const COLLECTIBLE_STARTING_WAIT = 20;
18
+ export declare const COLLECTIBLE_INITIAL_WAIT = 20;
19
19
  export declare const DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE;
20
20
  /** This is also the distance that a player spawns from the door that they enter a room from. */
21
21
  export declare const DISTANCE_OF_GRID_TILE = 40;
package/constants.lua CHANGED
@@ -19,7 +19,7 @@ ____exports.BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
19
19
  --- Bombs explode when their frame count is equal to this value.
20
20
  ____exports.BOMB_EXPLODE_FRAME = 45
21
21
  --- This is the initial value of the `EntityPickup.Wait` property after a collectible is spawned.
22
- ____exports.COLLECTIBLE_STARTING_WAIT = 20
22
+ ____exports.COLLECTIBLE_INITIAL_WAIT = 20
23
23
  ____exports.DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE
24
24
  --- This is also the distance that a player spawns from the door that they enter a room from.
25
25
  ____exports.DISTANCE_OF_GRID_TILE = 40
@@ -121,7 +121,7 @@ export declare enum ModCallbackCustom {
121
121
  * only fire if the revival type matches the one provided.
122
122
  *
123
123
  * ```ts
124
- * function postCustomRevive(player: EntityPlayer, revivalType: int) {}
124
+ * function postCustomRevive(player: EntityPlayer, revivalType: int): void {}
125
125
  * ```
126
126
  */
127
127
  POST_CUSTOM_REVIVE = 8,
@@ -133,7 +133,10 @@ export declare enum ModCallbackCustom {
133
133
  * only fire if the `DiceFloorSubType` type matches the one provided.
134
134
  *
135
135
  * ```ts
136
- * function postDiceRoomActivated(player: EntityPlayer, diceFloorSubType: DiceFloorSubType) {}
136
+ * function postDiceRoomActivated(
137
+ * player: EntityPlayer,
138
+ * diceFloorSubType: DiceFloorSubType,
139
+ * ): void {}
137
140
  * ```
138
141
  */
139
142
  POST_DICE_ROOM_ACTIVATED = 9,
@@ -281,7 +284,7 @@ export declare enum ModCallbackCustom {
281
284
  * Fires from the `POST_UPDATE` callback when the Greed Mode wave increases.
282
285
  *
283
286
  * ```ts
284
- * function postGreedModeWave(oldWave: int, newWave: int) {}
287
+ * function postGreedModeWave(oldWave: int, newWave: int): void {}
285
288
  * ```
286
289
  */
287
290
  POST_GREED_MODE_WAVE = 21,
@@ -676,7 +679,7 @@ export declare enum ModCallbackCustom {
676
679
  * player: EntityPlayer,
677
680
  * healthType: HealthType,
678
681
  * difference: int,
679
- * ) {}
682
+ * ): void {}
680
683
  * ```
681
684
  */
682
685
  POST_PLAYER_CHANGE_HEALTH = 46,
@@ -694,7 +697,7 @@ export declare enum ModCallbackCustom {
694
697
  * player: EntityPlayer,
695
698
  * oldCharacter: PlayerType,
696
699
  * newCharacter: PlayerType,
697
- * ) {}
700
+ * ): void {}
698
701
  * ```
699
702
  */
700
703
  POST_PLAYER_CHANGE_TYPE = 47,
@@ -702,13 +705,14 @@ export declare enum ModCallbackCustom {
702
705
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is higher than
703
706
  * what it was on the previous frame.
704
707
  *
705
- * - When registering the callback, takes an optional second argument that will make the callback
706
- * only fire if the player matches the `PlayerVariant` provided.
707
- * - When registering the callback, takes an optional third argument that will make the callback
708
- * only fire if the player matches the `PlayerType` provided.
708
+ * When registering the callback, takes an optional second argument that will make the callback
709
+ * only fire if the player matches the `CollectibleType` provided.
709
710
  *
710
711
  * ```ts
711
- * function postPlayerCollectibleAdded(player: EntityPlayer, collectibleType: CollectibleType) {}
712
+ * function postPlayerCollectibleAdded(
713
+ * player: EntityPlayer,
714
+ * collectibleType: CollectibleType,
715
+ * ): void {}
712
716
  * ```
713
717
  */
714
718
  POST_PLAYER_COLLECTIBLE_ADDED = 48,
@@ -716,16 +720,14 @@ export declare enum ModCallbackCustom {
716
720
  * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is lower than
717
721
  * what it was on the previous frame.
718
722
  *
719
- * - When registering the callback, takes an optional second argument that will make the callback
720
- * only fire if the player matches the `PlayerVariant` provided.
721
- * - When registering the callback, takes an optional third argument that will make the callback
722
- * only fire if the player matches the `PlayerType` provided.
723
+ * When registering the callback, takes an optional second argument that will make the callback
724
+ * only fire if the player matches the `CollectibleType` provided.
723
725
  *
724
726
  * ```ts
725
727
  * function postPlayerCollectibleRemoved(
726
728
  * player: EntityPlayer,
727
729
  * collectibleType: CollectibleType,
728
- * ) {}
730
+ * ): void {}
729
731
  * ```
730
732
  */
731
733
  POST_PLAYER_COLLECTIBLE_REMOVED = 49,
@@ -742,7 +744,7 @@ export declare enum ModCallbackCustom {
742
744
  * only fire if the player matches the `PlayerType` provided.
743
745
  *
744
746
  * ```ts
745
- * function postPlayerFatalDamage(player: EntityPlayer) {}
747
+ * function postPlayerFatalDamage(player: EntityPlayer): boolean | void {}
746
748
  * ```
747
749
  */
748
750
  POST_PLAYER_FATAL_DAMAGE = 50,
@@ -1128,7 +1130,7 @@ export declare enum ModCallbackCustom {
1128
1130
  * only fire if the player matches the `PlayerType` provided.
1129
1131
  *
1130
1132
  * ```ts
1131
- * function preBerserkDeath(player: EntityPlayer) {}
1133
+ * function preBerserkDeath(player: EntityPlayer): void {}
1132
1134
  * ```
1133
1135
  */
1134
1136
  PRE_BERSERK_DEATH = 78,
@@ -1146,7 +1148,7 @@ export declare enum ModCallbackCustom {
1146
1148
  * only fire if the player matches the `PlayerType` provided.
1147
1149
  *
1148
1150
  * ```ts
1149
- * function preCustomRevive(player: EntityPlayer) {}
1151
+ * function preCustomRevive(player: EntityPlayer): int | void {}
1150
1152
  * ```
1151
1153
  */
1152
1154
  PRE_CUSTOM_REVIVE = 79,
@@ -108,7 +108,7 @@ function ____exports.spawnTrapdoorOrCrawlspace(self, trapdoor)
108
108
  end
109
109
  function ____exports.warpToRoomType(self, roomType)
110
110
  local roomTypeName = ROOM_TYPE_NAMES[roomType]
111
- if roomTypeName == nil or roomTypeName == DEFAULT_ROOM_TYPE_NAME then
111
+ if roomTypeName == DEFAULT_ROOM_TYPE_NAME then
112
112
  printConsole(
113
113
  nil,
114
114
  "Invalid room type: " .. tostring(roomType)
@@ -117,7 +117,7 @@ end
117
117
  -- ```
118
118
  function ____exports.getCardName(self, card)
119
119
  local cardName = CARD_NAMES[card]
120
- if cardName ~= nil and cardName ~= DEFAULT_CARD_NAME then
120
+ if cardName ~= nil then
121
121
  return cardName
122
122
  end
123
123
  local itemConfigCard = itemConfig:GetCard(card)
@@ -2,7 +2,7 @@
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
3
  import { SerializationType } from "../enums/SerializationType";
4
4
  declare type SerializedColor = LuaTable<string, unknown> & {
5
- __serializedColorBrand: void;
5
+ readonly __serializedColorBrand: unique symbol;
6
6
  };
7
7
  interface CopyColorReturn {
8
8
  [SerializationType.NONE]: Color;
@@ -24,7 +24,7 @@ end
24
24
  -- This function uses the `package` global variable as a proxy to determine if the "--luadebug" flag
25
25
  -- is enabled or not.
26
26
  function ____exports.isLuaDebugEnabled(self)
27
- return package ~= nil
27
+ return _G.package ~= nil
28
28
  end
29
29
  --- Helper function to print a stack trace to the "log.txt" file, similar to JavaScript's
30
30
  -- `console.trace` function.
@@ -36,7 +36,7 @@ function ____exports.traceback(self)
36
36
  log(tracebackOutput)
37
37
  end
38
38
  local function setDebugFunctionsGlobal(self)
39
- if debug == nil and sandboxGetTraceback == nil then
39
+ if _G.debug == nil and sandboxGetTraceback == nil then
40
40
  return
41
41
  end
42
42
  local globals = _G
@@ -144,8 +144,7 @@ function ____exports.getDoorEnterPosition(self, door)
144
144
  end
145
145
  --- Helper function to get the possible door slots that can exist for a given room shape.
146
146
  function ____exports.getDoorSlotsForRoomShape(self, roomShape)
147
- local doorSlots = ROOM_SHAPE_TO_DOOR_SLOTS[roomShape]
148
- return doorSlots == nil and __TS__New(Set) or doorSlots
147
+ return ROOM_SHAPE_TO_DOOR_SLOTS[roomShape]
149
148
  end
150
149
  --- Helper function to get all of the doors in the room that lead to the provided room index.
151
150
  --
@@ -5,10 +5,10 @@
5
5
  *
6
6
  * Returns a slightly different set depending on whether the "--luadebug" flag is enabled or not.
7
7
  */
8
- export declare function getDefaultGlobals(): Set<string>;
8
+ export declare function getDefaultGlobals(): ReadonlySet<string>;
9
9
  /**
10
10
  * Helper function to get an array of any added global variables in the Isaac Lua environment.
11
- * Returns an array of key/value tuples.
11
+ * Returns a sorted array of key/value tuples.
12
12
  */
13
- export declare function getNewGlobals(): Array<[AnyNotNil, unknown]>;
13
+ export declare function getNewGlobals(): ReadonlyArray<[AnyNotNil, unknown]>;
14
14
  export declare function logNewGlobals(): void;
@@ -4,6 +4,7 @@ local __TS__New = ____lualib.__TS__New
4
4
  local __TS__ArraySort = ____lualib.__TS__ArraySort
5
5
  local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
6
6
  local ____exports = {}
7
+ local isRacingPlusSandboxEnabled
7
8
  local ____debug = require("functions.debug")
8
9
  local isLuaDebugEnabled = ____debug.isLuaDebugEnabled
9
10
  local ____log = require("functions.log")
@@ -13,6 +14,9 @@ local addSetsToSet = ____set.addSetsToSet
13
14
  local copySet = ____set.copySet
14
15
  local ____utils = require("functions.utils")
15
16
  local twoDimensionalSort = ____utils.twoDimensionalSort
17
+ function isRacingPlusSandboxEnabled(self)
18
+ return getParentFunctionDescription ~= nil
19
+ end
16
20
  local DEFAULT_GLOBALS = __TS__New(Set, {
17
21
  "ActionTriggers",
18
22
  "ActiveSlot",
@@ -191,11 +195,13 @@ function ____exports.getDefaultGlobals(self)
191
195
  if isLuaDebugEnabled(nil) then
192
196
  addSetsToSet(nil, defaultGlobals, LUA_DEBUG_ADDED_GLOBALS)
193
197
  end
194
- addSetsToSet(nil, defaultGlobals, RACING_PLUS_SANDBOX_ADDED_GLOBALS)
198
+ if isRacingPlusSandboxEnabled(nil) then
199
+ addSetsToSet(nil, defaultGlobals, RACING_PLUS_SANDBOX_ADDED_GLOBALS)
200
+ end
195
201
  return defaultGlobals
196
202
  end
197
203
  --- Helper function to get an array of any added global variables in the Isaac Lua environment.
198
- -- Returns an array of key/value tuples.
204
+ -- Returns a sorted array of key/value tuples.
199
205
  function ____exports.getNewGlobals(self)
200
206
  local defaultGlobals = ____exports.getDefaultGlobals(nil)
201
207
  local newGlobals = {}
@@ -2,7 +2,7 @@
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
3
  import { SerializationType } from "../enums/SerializationType";
4
4
  declare type SerializedKColor = LuaTable<string, unknown> & {
5
- __serializedKColorBrand: void;
5
+ readonly __serializedKColorBrand: unique symbol;
6
6
  };
7
7
  interface CopyKColorReturn {
8
8
  [SerializationType.NONE]: KColor;
@@ -114,7 +114,7 @@ end
114
114
  -- ```
115
115
  function ____exports.getPillEffectName(self, pillEffect)
116
116
  local pillEffectName = PILL_EFFECT_NAMES[pillEffect]
117
- if pillEffectName ~= nil and pillEffectName ~= DEFAULT_PILL_EFFECT_NAME then
117
+ if pillEffectName ~= nil then
118
118
  return pillEffectName
119
119
  end
120
120
  local itemConfigPillEffect = itemConfig:GetPillEffect(pillEffect)
@@ -12,6 +12,8 @@ export declare function addPlayerHealthType(player: EntityPlayer, healthType: He
12
12
  */
13
13
  export declare function getPlayerHealth(player: EntityPlayer): PlayerHealth;
14
14
  export declare function getPlayerHealthType(player: EntityPlayer, healthType: HealthType): int;
15
+ /** Returns a `PlayerHealth` object with all 0s. */
16
+ export declare function newPlayerHealth(): PlayerHealth;
15
17
  export declare function playerConvertBlackHeartsToSoulHearts(player: EntityPlayer): void;
16
18
  export declare function playerConvertSoulHeartsToBlackHearts(player: EntityPlayer): void;
17
19
  export declare function removeAllPlayerHealth(player: EntityPlayer): void;
@@ -3,17 +3,24 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
3
3
  local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
4
4
  local ____exports = {}
5
5
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
+ local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
7
+ local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
6
8
  local HeartSubType = ____isaac_2Dtypescript_2Ddefinitions.HeartSubType
7
9
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
8
10
  local ____constants = require("constants")
9
11
  local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
10
12
  local ____HealthType = require("enums.HealthType")
11
13
  local HealthType = ____HealthType.HealthType
14
+ local ____charge = require("functions.charge")
15
+ local getTotalCharge = ____charge.getTotalCharge
16
+ local ____enums = require("functions.enums")
17
+ local getEnumValues = ____enums.getEnumValues
12
18
  local ____player = require("functions.player")
13
19
  local getPlayerBlackHearts = ____player.getPlayerBlackHearts
14
20
  local getPlayerHearts = ____player.getPlayerHearts
15
21
  local getPlayerSoulHearts = ____player.getPlayerSoulHearts
16
22
  local isCharacter = ____player.isCharacter
23
+ local setActiveItem = ____player.setActiveItem
17
24
  local ____utils = require("functions.utils")
18
25
  local ensureAllCases = ____utils.ensureAllCases
19
26
  local ____repeat = ____utils["repeat"]
@@ -45,6 +52,17 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
45
52
  local character = player:GetPlayerType()
46
53
  local subPlayer = player:GetSubPlayer()
47
54
  ____exports.removeAllPlayerHealth(nil, player)
55
+ local alabasterBoxes = {}
56
+ if player:HasCollectible(CollectibleType.ALABASTER_BOX) then
57
+ for ____, activeSlot in ipairs(getEnumValues(nil, ActiveSlot)) do
58
+ local activeItem = player:GetActiveItem()
59
+ if activeItem == CollectibleType.ALABASTER_BOX then
60
+ local totalCharge = getTotalCharge(nil, player, activeSlot)
61
+ setActiveItem(nil, player, CollectibleType.NULL, activeSlot)
62
+ alabasterBoxes[#alabasterBoxes + 1] = {activeSlot, totalCharge}
63
+ end
64
+ end
65
+ end
48
66
  if character == PlayerType.THE_SOUL and subPlayer ~= nil then
49
67
  subPlayer:AddMaxHearts(playerHealth.maxHearts, false)
50
68
  else
@@ -89,6 +107,17 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
89
107
  elseif character == PlayerType.BETHANY_B then
90
108
  player:SetBloodCharge(playerHealth.bloodCharges)
91
109
  end
110
+ for ____, ____value in ipairs(alabasterBoxes) do
111
+ local activeSlot = ____value[1]
112
+ local totalCharge = ____value[2]
113
+ setActiveItem(
114
+ nil,
115
+ player,
116
+ CollectibleType.ALABASTER_BOX,
117
+ activeSlot,
118
+ totalCharge
119
+ )
120
+ end
92
121
  end
93
122
  function ____exports.addPlayerHealthType(self, player, healthType, numHearts)
94
123
  repeat
@@ -294,6 +323,22 @@ function ____exports.getPlayerHealthType(self, player, healthType)
294
323
  end
295
324
  until true
296
325
  end
326
+ --- Returns a `PlayerHealth` object with all 0s.
327
+ function ____exports.newPlayerHealth(self)
328
+ return {
329
+ maxHearts = 0,
330
+ hearts = 0,
331
+ eternalHearts = 0,
332
+ soulHearts = 0,
333
+ boneHearts = 0,
334
+ goldenHearts = 0,
335
+ rottenHearts = 0,
336
+ brokenHearts = 0,
337
+ soulCharges = 0,
338
+ bloodCharges = 0,
339
+ soulHeartTypes = {}
340
+ }
341
+ end
297
342
  function ____exports.playerConvertBlackHeartsToSoulHearts(self, player)
298
343
  local playerHealth = ____exports.getPlayerHealth(nil, player)
299
344
  ____exports.removeAllPlayerHealth(nil, player)
@@ -3,7 +3,7 @@
3
3
  /// <reference types="typescript-to-lua/language-extensions" />
4
4
  import { SerializationType } from "../enums/SerializationType";
5
5
  declare type SerializedRNG = LuaTable<string, unknown> & {
6
- __serializedRNGBrand: void;
6
+ readonly __serializedRNGBrand: unique symbol;
7
7
  };
8
8
  interface CopyRNGReturn {
9
9
  [SerializationType.NONE]: RNG;
@@ -32,7 +32,6 @@ local NUM_DIMENSIONS = ____constants.NUM_DIMENSIONS
32
32
  local ____roomShapeToDoorSlotsToGridIndexDelta = require("objects.roomShapeToDoorSlotsToGridIndexDelta")
33
33
  local ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA = ____roomShapeToDoorSlotsToGridIndexDelta.ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA
34
34
  local ____roomTypeNames = require("objects.roomTypeNames")
35
- local DEFAULT_ROOM_TYPE_NAME = ____roomTypeNames.DEFAULT_ROOM_TYPE_NAME
36
35
  local ROOM_TYPE_NAMES = ____roomTypeNames.ROOM_TYPE_NAMES
37
36
  local ____mineShaftRoomSubTypesSet = require("sets.mineShaftRoomSubTypesSet")
38
37
  local MINE_SHAFT_ROOM_SUB_TYPE_SET = ____mineShaftRoomSubTypesSet.MINE_SHAFT_ROOM_SUB_TYPE_SET
@@ -208,8 +207,7 @@ end
208
207
  --
209
208
  -- For example, `RoomType.TREASURE` will return "Treasure Room".
210
209
  function ____exports.getRoomTypeName(self, roomType)
211
- local roomTypeName = ROOM_TYPE_NAMES[roomType]
212
- return roomTypeName == nil and DEFAULT_ROOM_TYPE_NAME or roomTypeName
210
+ return ROOM_TYPE_NAMES[roomType]
213
211
  end
214
212
  --- Helper function to get the room descriptor for every room on the level in a specific dimension.
215
213
  -- Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
@@ -56,9 +56,6 @@ function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
56
56
  error("Failed to deserialize an API class since a valid class type brand was not found.")
57
57
  end
58
58
  local copyFunction = ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[copyableIsaacAPIClassType]
59
- if copyFunction == nil then
60
- error(("Failed to deserialize Isaac API class \"" .. copyableIsaacAPIClassType) .. "\" since there is not a defined copy function for this class type.")
61
- end
62
59
  return copyFunction(nil, serializedIsaacAPIClass, SerializationType.DESERIALIZE)
63
60
  end
64
61
  function ____exports.isSerializedIsaacAPIClass(self, object)
@@ -9,7 +9,6 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
9
9
  local ItemConfigTag = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTag
10
10
  local PlayerForm = ____isaac_2Dtypescript_2Ddefinitions.PlayerForm
11
11
  local ____transformationNames = require("objects.transformationNames")
12
- local DEFAULT_TRANSFORMATION_NAME = ____transformationNames.DEFAULT_TRANSFORMATION_NAME
13
12
  local TRANSFORMATION_NAMES = ____transformationNames.TRANSFORMATION_NAMES
14
13
  local ____collectibles = require("functions.collectibles")
15
14
  local getCollectibleTags = ____collectibles.getCollectibleTags
@@ -79,8 +78,7 @@ end
79
78
  -- // transformationName is "Beelzebub"
80
79
  -- ```
81
80
  function ____exports.getTransformationName(self, playerForm)
82
- local transformationName = TRANSFORMATION_NAMES[playerForm]
83
- return transformationName == nil and DEFAULT_TRANSFORMATION_NAME or transformationName
81
+ return TRANSFORMATION_NAMES[playerForm]
84
82
  end
85
83
  function ____exports.getTransformationsForCollectibleType(self, collectibleType)
86
84
  local itemConfigTags = getCollectibleTags(nil, collectibleType)
@@ -2,7 +2,7 @@
2
2
  import { Direction } from "isaac-typescript-definitions";
3
3
  import { SerializationType } from "../enums/SerializationType";
4
4
  declare type SerializedVector = LuaTable<string, unknown> & {
5
- __serializedVectorBrand: void;
5
+ readonly __serializedVectorBrand: unique symbol;
6
6
  };
7
7
  interface CopyVectorReturn {
8
8
  [SerializationType.NONE]: Vector;
@@ -1,4 +1,4 @@
1
- /** Part of {@link JSONRooms}. */
1
+ /** Part of `JSONRooms`. */
2
2
  export interface JSONDoor {
3
3
  $: {
4
4
  /** Equal to "True" or "False". */
@@ -1,4 +1,4 @@
1
- /** Part of {@link JSONRooms}. */
1
+ /** Part of `JSONRooms`. */
2
2
  export interface JSONEntity {
3
3
  $: {
4
4
  /** Needs to be converted to an int. */
@@ -1,6 +1,6 @@
1
1
  import { JSONDoor } from "./JSONDoor";
2
2
  import { JSONSpawn } from "./JSONSpawn";
3
- /** Part of {@link JSONRooms}. */
3
+ /** Part of `JSONRooms`. */
4
4
  export interface JSONRoom {
5
5
  $: {
6
6
  /** Needs to be converted to an int. */
@@ -1,5 +1,5 @@
1
1
  import { JSONEntity } from "./JSONEntity";
2
- /** Part of {@link JSONRooms}. */
2
+ /** Part of `JSONRooms`. */
3
3
  export interface JSONSpawn {
4
4
  $: {
5
5
  /** Needs to be converted to an int. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "3.16.0",
3
+ "version": "4.0.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "index",
23
23
  "types": "index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^2.2.3"
25
+ "isaac-typescript-definitions": "^3.0.3"
26
26
  }
27
27
  }
@@ -12,5 +12,5 @@
12
12
  * This type is branded for extra type safety.
13
13
  */
14
14
  export declare type CollectibleIndex = string & {
15
- __collectibleIndexBrand: void;
15
+ readonly __collectibleIndexBrand: unique symbol;
16
16
  };
@@ -5,21 +5,21 @@
5
5
  */
6
6
  import { CollectibleType, ItemType, TrinketType } from "isaac-typescript-definitions";
7
7
  export declare type PickingUpItem = PickingUpItemNull | PickingUpItemCollectible | PickingUpItemTrinket;
8
- /** Part of {@link PickingUpItem}. */
8
+ /** Part of `PickingUpItem`. */
9
9
  export interface PickingUpItemNull {
10
10
  /** Needed so that we can distinguish between picking up a collectible and a trinket. */
11
11
  itemType: ItemType.NULL;
12
12
  /** Equal to either the collectible type, the trinket type, or 0. */
13
13
  subType: 0;
14
14
  }
15
- /** Part of {@link PickingUpItem}. */
15
+ /** Part of `PickingUpItem`. */
16
16
  export interface PickingUpItemCollectible {
17
17
  /** Needed so that we can distinguish between picking up a collectible and a trinket. */
18
18
  itemType: ItemType.PASSIVE | ItemType.ACTIVE | ItemType.FAMILIAR;
19
19
  /** Equal to either the collectible type, the trinket type, or 0. */
20
20
  subType: CollectibleType;
21
21
  }
22
- /** Part of {@link PickingUpItem}. */
22
+ /** Part of `PickingUpItem`. */
23
23
  export interface PickingUpItemTrinket {
24
24
  /** Needed so that we can distinguish between picking up a collectible and a trinket. */
25
25
  itemType: ItemType.TRINKET;
@@ -12,5 +12,5 @@
12
12
  * This type is branded for extra type safety.
13
13
  */
14
14
  export declare type PlayerIndex = int & {
15
- __playerIndexBrand: void;
15
+ readonly __playerIndexBrand: unique symbol;
16
16
  };
@@ -1,4 +1,4 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  export declare type IsaacAPIClass = LuaTable<string, unknown> & {
3
- __isaacAPIClassBrand: void;
3
+ readonly __isaacAPIClassBrand: unique symbol;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  export declare type SerializedIsaacAPIClass = LuaTable<string, unknown> & {
3
- __serializedIsaacAPIClassBrand: void;
3
+ readonly __serializedIsaacAPIClassBrand: unique symbol;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  export declare type TSTLClass = LuaTable<AnyNotNil, unknown> & {
3
- __tstlClassBrand: void;
3
+ readonly __tstlClassBrand: unique symbol;
4
4
  };
package/upgradeMod.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { ModUpgraded } from "./classes/ModUpgraded";
3
3
  /**
4
- * Use this function to enable the {@link ModCallbackCustom custom callbacks} and other optional
5
- * features provided by `isaacscript-common`.
4
+ * Use this function to enable the custom callbacks and other optional features provided by
5
+ * `isaacscript-common`.
6
6
  *
7
7
  * For example:
8
8
  *
package/upgradeMod.lua CHANGED
@@ -17,8 +17,8 @@ local initFeaturesMajor = ____initFeatures.initFeaturesMajor
17
17
  local initFeaturesMinor = ____initFeatures.initFeaturesMinor
18
18
  local ____patchErrorFunctions = require("patchErrorFunctions")
19
19
  local patchErrorFunction = ____patchErrorFunctions.patchErrorFunction
20
- --- Use this function to enable the {@link ModCallbackCustomcustom callbacks} and other optional
21
- -- features provided by `isaacscript-common`.
20
+ --- Use this function to enable the custom callbacks and other optional features provided by
21
+ -- `isaacscript-common`.
22
22
  --
23
23
  -- For example:
24
24
  --