isaacscript-common 4.5.0 → 4.6.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 (78) hide show
  1. package/constants.d.ts +0 -3
  2. package/constantsFirstLast.d.ts +0 -3
  3. package/features/characterHealthConversion.d.ts +6 -0
  4. package/features/characterHealthConversion.lua +4 -1
  5. package/features/characterStats.d.ts +5 -0
  6. package/features/characterStats.lua +1 -1
  7. package/features/collectibleItemPoolType.lua +2 -2
  8. package/features/debugDisplay/debugDisplay.d.ts +4 -0
  9. package/features/debugDisplay/debugDisplay.lua +2 -0
  10. package/features/deployJSONRoom.lua +4 -6
  11. package/features/{disableSound.d.ts → disableAllSound.d.ts} +0 -0
  12. package/features/{disableSound.lua → disableAllSound.lua} +3 -3
  13. package/features/disableInputs.lua +2 -2
  14. package/features/extraConsoleCommands/exports.d.ts +26 -0
  15. package/features/extraConsoleCommands/exports.lua +54 -0
  16. package/features/extraConsoleCommands/init.d.ts +1 -25
  17. package/features/extraConsoleCommands/init.lua +166 -195
  18. package/features/extraConsoleCommands/v.d.ts +8 -0
  19. package/features/extraConsoleCommands/v.lua +11 -0
  20. package/features/fadeInRemover.lua +2 -2
  21. package/features/fastReset.lua +1 -1
  22. package/features/forgottenSwitch.lua +2 -2
  23. package/features/persistentEntities.lua +6 -1
  24. package/features/playerInventory.lua +2 -2
  25. package/features/ponyDetection.lua +2 -2
  26. package/features/preventCollectibleRotation.lua +2 -2
  27. package/features/registerHotkey.d.ts +3 -0
  28. package/features/registerHotkey.lua +50 -0
  29. package/features/roomClearFrame.lua +2 -2
  30. package/features/runInNFrames.lua +2 -2
  31. package/features/saveDataManager/exports.lua +1 -0
  32. package/features/sirenHelpers.lua +2 -2
  33. package/features/stageHistory.lua +2 -2
  34. package/features/taintedLazarusPlayers.lua +2 -2
  35. package/featuresInitialized.lua +1 -1
  36. package/functions/gridEntity.d.ts +12 -0
  37. package/functions/gridEntity.lua +15 -2
  38. package/functions/rng.lua +6 -2
  39. package/functions/rooms.d.ts +1 -0
  40. package/functions/rooms.lua +1 -0
  41. package/functions/run.d.ts +5 -2
  42. package/functions/run.lua +5 -2
  43. package/functions/saveFile.lua +3 -0
  44. package/functions/stage.d.ts +6 -1
  45. package/functions/stage.lua +7 -0
  46. package/functions/utils.d.ts +5 -0
  47. package/functions/utils.lua +7 -0
  48. package/index.d.ts +4 -4
  49. package/index.lua +22 -24
  50. package/initFeatures.lua +6 -6
  51. package/lualib_bundle.lua +6 -3
  52. package/maps/roomTypeMap.lua +0 -1
  53. package/objects/roomTypeGotoPrefixes.d.ts +4 -0
  54. package/objects/roomTypeGotoPrefixes.lua +35 -0
  55. package/objects/roomTypeNames.lua +0 -1
  56. package/package.json +2 -2
  57. package/sets/consoleCommandsSet.d.ts +5 -0
  58. package/sets/consoleCommandsSet.lua +61 -0
  59. package/types/PickingUpItem.d.ts +3 -3
  60. package/types/PickingUpItem.lua +3 -3
  61. package/enums/StageTravelEntityState.d.ts +0 -4
  62. package/enums/StageTravelEntityState.lua +0 -7
  63. package/enums/StageTravelState.d.ts +0 -6
  64. package/enums/StageTravelState.lua +0 -11
  65. package/features/customTrapdoor/constants.d.ts +0 -5
  66. package/features/customTrapdoor/constants.lua +0 -7
  67. package/features/customTrapdoor/exports.d.ts +0 -37
  68. package/features/customTrapdoor/exports.lua +0 -120
  69. package/features/customTrapdoor/init.d.ts +0 -1
  70. package/features/customTrapdoor/init.lua +0 -11
  71. package/features/customTrapdoor/stageTravel.d.ts +0 -0
  72. package/features/customTrapdoor/stageTravel.lua +0 -0
  73. package/features/customTrapdoor/trapdoor.d.ts +0 -0
  74. package/features/customTrapdoor/trapdoor.lua +0 -0
  75. package/features/customTrapdoor/v.d.ts +0 -14
  76. package/features/customTrapdoor/v.lua +0 -16
  77. package/interfaces/StageTravelEntityDescription.d.ts +0 -5
  78. package/interfaces/StageTravelEntityDescription.lua +0 -2
package/constants.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /**
2
- * @module Constants
3
- */
4
1
  import { CollectibleType, ItemPoolType, LevelStage, RoomType } from "isaac-typescript-definitions";
5
2
  /**
6
3
  * The distance of the laser when Azazel does not have any range up items yet. For more info, see
@@ -1,6 +1,3 @@
1
- /**
2
- * @module Constants (First and Last)
3
- */
4
1
  import { Card, CollectibleType, PillColor, PillEffect, PlayerType, TrinketType } from "isaac-typescript-definitions";
5
2
  /** Equal to `CollectibleType.SAD_ONION`. */
6
3
  export declare const FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION;
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Easily create custom characters that have the same health mechanic as Blue Baby (red heart
3
+ * containers --> soul hearts) or Black Judas (red heart containers --> black hearts).
4
+ *
5
+ * @module
6
+ */
1
7
  import { HeartSubType, PlayerType } from "isaac-typescript-definitions";
2
8
  export declare type ConversionHeartSubType = HeartSubType.SOUL | HeartSubType.BLACK;
3
9
  /**
@@ -65,7 +65,7 @@ function prePickupCollisionHeart(self, pickup, collider)
65
65
  end
66
66
  return false
67
67
  end
68
- local FEATURE_NAME = "character health manager"
68
+ local FEATURE_NAME = "characterHealthConversion"
69
69
  characterHealthReplacementMap = __TS__New(Map)
70
70
  ---
71
71
  -- @internal
@@ -79,6 +79,9 @@ end
79
79
  -- Call this function once at the beginning of your mod to declare the health conversion type.
80
80
  function ____exports.registerCharacterHealthConversion(self, playerType, conversionHeartSubType)
81
81
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
82
+ if characterHealthReplacementMap:has(playerType) then
83
+ error(("Failed to register a character of type " .. tostring(playerType)) .. " because there is already an existing registered character with that type.")
84
+ end
82
85
  characterHealthReplacementMap:set(playerType, conversionHeartSubType)
83
86
  end
84
87
  return ____exports
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Easily create custom characters that have base stats different from that of Isaac.
3
+ *
4
+ * @module
5
+ */
1
6
  import { CacheFlag, PlayerType } from "isaac-typescript-definitions";
2
7
  /**
3
8
  * Helper function to manage the stats for a vanilla or custom character. Call this function once at
@@ -25,7 +25,7 @@ function evaluateCache(self, player, cacheFlag)
25
25
  local delta = stat - defaultStat
26
26
  addStat(nil, player, cacheFlag, delta)
27
27
  end
28
- local FEATURE_NAME = "character stat manager"
28
+ local FEATURE_NAME = "characterStats"
29
29
  charactersStatMap = __TS__New(Map)
30
30
  ---
31
31
  -- @internal
@@ -24,12 +24,12 @@ function postPickupInitCollectible(self, pickup)
24
24
  local lastItemPoolType = itemPool:GetLastPool()
25
25
  v.run.collectibleItemPoolTypeMap:set(ptrHash, lastItemPoolType)
26
26
  end
27
- local FEATURE_NAME = "get collectible item pool type"
27
+ local FEATURE_NAME = "collectibleItemPoolType"
28
28
  v = {run = {collectibleItemPoolTypeMap = __TS__New(Map)}}
29
29
  ---
30
30
  -- @internal
31
31
  function ____exports.collectibleItemPoolTypeInit(self, mod)
32
- saveDataManager(nil, "collectibleItemPoolType", v)
32
+ saveDataManager(nil, FEATURE_NAME, v)
33
33
  mod:AddCallback(ModCallback.POST_PICKUP_INIT, postPickupInitCollectible, PickupVariant.COLLECTIBLE)
34
34
  end
35
35
  --- Helper function to get the item pool type that a given collectible came from. Since there is no
@@ -1,2 +1,6 @@
1
1
  import { ModUpgraded } from "../../classes/ModUpgraded";
2
+ /**
3
+ * The debug display feature is only initialized when the extra console commands feature is
4
+ * initialized.
5
+ */
2
6
  export declare function debugDisplayInit(mod: ModUpgraded): void;
@@ -152,6 +152,8 @@ function postPressurePlateRender(self, pressurePlate)
152
152
  local text = debugDisplayTextCallbacks:pressurePlate(pressurePlate)
153
153
  renderTextOnEntity(nil, pressurePlate, text)
154
154
  end
155
+ --- The debug display feature is only initialized when the extra console commands feature is
156
+ -- initialized.
155
157
  function ____exports.debugDisplayInit(self, mod)
156
158
  saveDataManager(
157
159
  nil,
@@ -37,6 +37,7 @@ local removeAllBombs = ____entitySpecific.removeAllBombs
37
37
  local removeAllPickups = ____entitySpecific.removeAllPickups
38
38
  local ____gridEntity = require("functions.gridEntity")
39
39
  local convertXMLGridEntityType = ____gridEntity.convertXMLGridEntityType
40
+ local getAllGridIndexes = ____gridEntity.getAllGridIndexes
40
41
  local getGridEntities = ____gridEntity.getGridEntities
41
42
  local removeAllGridExcept = ____gridEntity.removeAllGridExcept
42
43
  local removeGrid = ____gridEntity.removeGrid
@@ -59,8 +60,6 @@ local setRoomCleared = ____rooms.setRoomCleared
59
60
  local setRoomUncleared = ____rooms.setRoomUncleared
60
61
  local ____spawnCollectible = require("functions.spawnCollectible")
61
62
  local spawnCollectible = ____spawnCollectible.spawnCollectible
62
- local ____utils = require("functions.utils")
63
- local erange = ____utils.erange
64
63
  local ____runInNFrames = require("features.runInNFrames")
65
64
  local runNextGameFrame = ____runInNFrames.runNextGameFrame
66
65
  local ____exports = require("features.saveDataManager.exports")
@@ -182,10 +181,9 @@ function removeSpecificNPCs(self)
182
181
  end
183
182
  function fillRoomWithDecorations(self)
184
183
  local room = game:GetRoom()
185
- local gridSize = room:GetGridSize()
186
184
  local roomListIndex = getRoomListIndex(nil)
187
185
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
188
- for ____, gridIndex in ipairs(erange(nil, gridSize)) do
186
+ for ____, gridIndex in ipairs(getAllGridIndexes(nil)) do
189
187
  do
190
188
  local existingGridEntity = room:GetGridEntity(gridIndex)
191
189
  if existingGridEntity ~= nil then
@@ -451,7 +449,7 @@ function getPitFrame(self, L, R, U, D, UL, UR, DL, DR)
451
449
  end
452
450
  return F
453
451
  end
454
- FEATURE_NAME = "JSON room deployer"
452
+ FEATURE_NAME = "deployJSONRoom"
455
453
  NPC_TYPES_TO_NOT_REMOVE = __TS__New(Set, {EntityType.DARK_ESAU})
456
454
  PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.WALL_HUGGER})
457
455
  v = {
@@ -471,7 +469,7 @@ v = {
471
469
  ---
472
470
  -- @internal
473
471
  function ____exports.deployJSONRoomInit(self, mod)
474
- saveDataManager(nil, "deployJSONRoom", v)
472
+ saveDataManager(nil, FEATURE_NAME, v)
475
473
  mod:AddCallback(ModCallback.PRE_USE_ITEM, preUseItemWeNeedToGoDeeper, CollectibleType.WE_NEED_TO_GO_DEEPER)
476
474
  mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
477
475
  end
@@ -19,13 +19,13 @@ function postRender(self)
19
19
  end
20
20
  stopAllSoundEffects(nil)
21
21
  end
22
- local FEATURE_NAME = "sound disabler"
22
+ local FEATURE_NAME = "disableAllSound"
23
23
  local musicWasEnabled = false
24
24
  v = {run = {disableSoundSet = __TS__New(Set)}}
25
25
  ---
26
26
  -- @internal
27
- function ____exports.disableSoundsInit(self, mod)
28
- saveDataManager(nil, "disableSounds", v)
27
+ function ____exports.disableAllSoundInit(self, mod)
28
+ saveDataManager(nil, FEATURE_NAME, v)
29
29
  mod:AddCallback(ModCallback.POST_RENDER, postRender)
30
30
  end
31
31
  --- Helper function to stop muting all sound effects and music.
@@ -44,7 +44,7 @@ function getReturnValue(self, buttonAction, booleanCallback)
44
44
  end
45
45
  return nil
46
46
  end
47
- local FEATURE_NAME = "input disabler"
47
+ local FEATURE_NAME = "disableInputs"
48
48
  v = {run = {
49
49
  disableInputsWithWhitelistMap = __TS__New(Map),
50
50
  enableInputsWithBlacklistMap = __TS__New(Map)
@@ -52,7 +52,7 @@ v = {run = {
52
52
  ---
53
53
  -- @internal
54
54
  function ____exports.disableInputsInit(self, mod)
55
- saveDataManager(nil, "disableInputs", v)
55
+ saveDataManager(nil, FEATURE_NAME, v)
56
56
  mod:AddCallback(ModCallback.INPUT_ACTION, isActionPressed, InputHook.IS_ACTION_PRESSED)
57
57
  mod:AddCallback(ModCallback.INPUT_ACTION, isActionTriggered, InputHook.IS_ACTION_TRIGGERED)
58
58
  mod:AddCallback(ModCallback.INPUT_ACTION, getActionValue, InputHook.GET_ACTION_VALUE)
@@ -0,0 +1,26 @@
1
+ import { ModUpgraded } from "../../classes/ModUpgraded";
2
+ /**
3
+ * Enables extra console commands which are useful for debugging. See [the
4
+ * docs](https://isaacscript.github.io/isaacscript-common/features/extraConsoleCommands_listCommands)
5
+ * for the specific commands that are added.
6
+ */
7
+ export declare function enableExtraConsoleCommands(mod: ModUpgraded): void;
8
+ /**
9
+ * Helper function to add a custom console command.
10
+ *
11
+ * The standard library comes with many existing console commands that are useful for debugging, but
12
+ * you can also add your own commands that are useful for your particular mod. It's easier to add
13
+ * commands to the existing command system than to add logic manually to the ExecuteCmd callback.
14
+ *
15
+ * Before using this function, you must first invoke `enableExtraConsoleCommands`.
16
+ */
17
+ export declare function addConsoleCommand(commandName: string, commandFunction: (params: string) => void): void;
18
+ /**
19
+ * Helper function to remove a custom console command.
20
+ *
21
+ * The standard library comes with many existing console commands that are useful for debugging. If
22
+ * you want to disable one of them, use this function.
23
+ *
24
+ * Before using this function, you must first invoke `enableExtraConsoleCommands`.
25
+ */
26
+ export declare function removeConsoleCommand(commandName: string): void;
@@ -0,0 +1,54 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local ____exports = {}
4
+ local ____utils = require("functions.utils")
5
+ local isVanillaConsoleCommand = ____utils.isVanillaConsoleCommand
6
+ local ____init = require("features.extraConsoleCommands.init")
7
+ local extraConsoleCommandsInit = ____init.extraConsoleCommandsInit
8
+ local ____v = require("features.extraConsoleCommands.v")
9
+ local extraConsoleCommandsFunctionMap = ____v.extraConsoleCommandsFunctionMap
10
+ local isExtraConsoleCommandsInitialized = ____v.isExtraConsoleCommandsInitialized
11
+ --- Enables extra console commands which are useful for debugging. See [the
12
+ -- docs](https://isaacscript.github.io/isaacscript-common/features/extraConsoleCommands_listCommands)
13
+ -- for the specific commands that are added.
14
+ function ____exports.enableExtraConsoleCommands(self, mod)
15
+ if isExtraConsoleCommandsInitialized(nil) then
16
+ error("The extra console commands are already initialized.")
17
+ end
18
+ extraConsoleCommandsInit(nil, mod)
19
+ end
20
+ --- Helper function to add a custom console command.
21
+ --
22
+ -- The standard library comes with many existing console commands that are useful for debugging, but
23
+ -- you can also add your own commands that are useful for your particular mod. It's easier to add
24
+ -- commands to the existing command system than to add logic manually to the ExecuteCmd callback.
25
+ --
26
+ -- Before using this function, you must first invoke `enableExtraConsoleCommands`.
27
+ function ____exports.addConsoleCommand(self, commandName, commandFunction)
28
+ if not isExtraConsoleCommandsInitialized(nil) then
29
+ error("The \"extraConsoleCommands\" feature is not initialized. Before adding extra console commands, you must first enable the feature by invoking the \"enableExtraConsoleCommands\" function.")
30
+ end
31
+ if isVanillaConsoleCommand(nil, commandName) then
32
+ error(("Failed to add a new console command of \"" .. commandName) .. "\" because that name already belongs to a vanilla command. You must pick a non-colliding name.")
33
+ end
34
+ if extraConsoleCommandsFunctionMap:has(commandName) then
35
+ error(("Failed to add a new console command of \"" .. commandName) .. "\" because there is already an existing custom command by that name. If you want to overwrite a command from the standard library, you can use the \"removeExtraConsoleCommand\" function.")
36
+ end
37
+ extraConsoleCommandsFunctionMap:set(commandName, commandFunction)
38
+ end
39
+ --- Helper function to remove a custom console command.
40
+ --
41
+ -- The standard library comes with many existing console commands that are useful for debugging. If
42
+ -- you want to disable one of them, use this function.
43
+ --
44
+ -- Before using this function, you must first invoke `enableExtraConsoleCommands`.
45
+ function ____exports.removeConsoleCommand(self, commandName)
46
+ if not isExtraConsoleCommandsInitialized(nil) then
47
+ error("The \"extraConsoleCommands\" feature is not initialized. Before removing console commands, you must first enable the feature by invoking the \"enableExtraConsoleCommands\" function.")
48
+ end
49
+ if not extraConsoleCommandsFunctionMap:has(commandName) then
50
+ error(("Failed to remove the console command of \"" .. commandName) .. "\", since it does not already exist in the map.")
51
+ end
52
+ extraConsoleCommandsFunctionMap:delete(commandName)
53
+ end
54
+ return ____exports
@@ -1,26 +1,2 @@
1
1
  import { ModUpgraded } from "../../classes/ModUpgraded";
2
- /**
3
- * Enables extra console commands which are useful for debugging. See [the
4
- * docs](https://isaacscript.github.io/isaacscript-common/features/extraConsoleCommands_listCommands)
5
- * for the specific commands that are added.
6
- */
7
- export declare function enableExtraConsoleCommands(mod: ModUpgraded): void;
8
- /**
9
- * Helper function to add a custom console command.
10
- *
11
- * The standard library comes with many existing console commands that are useful for debugging, but
12
- * you can also add your own commands that are useful for your particular mod. It's easier to add
13
- * commands to the existing command system than to add logic manually to the ExecuteCmd callback.
14
- *
15
- * Before using this function, you must first invoke `enableExtraConsoleCommands`.
16
- */
17
- export declare function addConsoleCommand(commandName: string, commandFunction: (params: string) => void): void;
18
- /**
19
- * Helper function to remove a custom console command.
20
- *
21
- * The standard library comes with many existing console commands that are useful for debugging. If
22
- * you want to disable one of them, use this function.
23
- *
24
- * Before using this function, you must first invoke `enableExtraConsoleCommands`.
25
- */
26
- export declare function removeConsoleCommand(commandName: string): void;
2
+ export declare function extraConsoleCommandsInit(mod: ModUpgraded): void;