isaacscript-common 4.2.4 → 4.2.8

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.
@@ -0,0 +1,5 @@
1
+ export declare enum StageTravelEntityType {
2
+ TRAPDOOR = 0,
3
+ CRAWLSPACE = 1,
4
+ HEAVEN_DOOR = 2
5
+ }
@@ -0,0 +1,9 @@
1
+ local ____exports = {}
2
+ ____exports.StageTravelEntityType = {}
3
+ ____exports.StageTravelEntityType.TRAPDOOR = 0
4
+ ____exports.StageTravelEntityType[____exports.StageTravelEntityType.TRAPDOOR] = "TRAPDOOR"
5
+ ____exports.StageTravelEntityType.CRAWLSPACE = 1
6
+ ____exports.StageTravelEntityType[____exports.StageTravelEntityType.CRAWLSPACE] = "CRAWLSPACE"
7
+ ____exports.StageTravelEntityType.HEAVEN_DOOR = 2
8
+ ____exports.StageTravelEntityType[____exports.StageTravelEntityType.HEAVEN_DOOR] = "HEAVEN_DOOR"
9
+ return ____exports
@@ -4,4 +4,3 @@ export declare enum SaveDataKey {
4
4
  LEVEL = "level",
5
5
  ROOM = "room"
6
6
  }
7
- export declare const RESETTABLE_SAVE_DATA_KEYS: ReadonlySet<SaveDataKey>;
@@ -1,11 +1,7 @@
1
- local ____lualib = require("lualib_bundle")
2
- local Set = ____lualib.Set
3
- local __TS__New = ____lualib.__TS__New
4
1
  local ____exports = {}
5
2
  ____exports.SaveDataKey = {}
6
3
  ____exports.SaveDataKey.PERSISTENT = "persistent"
7
4
  ____exports.SaveDataKey.RUN = "run"
8
5
  ____exports.SaveDataKey.LEVEL = "level"
9
6
  ____exports.SaveDataKey.ROOM = "room"
10
- ____exports.RESETTABLE_SAVE_DATA_KEYS = __TS__New(Set, {____exports.SaveDataKey.RUN, ____exports.SaveDataKey.LEVEL, ____exports.SaveDataKey.ROOM})
11
7
  return ____exports
@@ -1,7 +1,9 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
+ local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
3
5
  local ____exports = {}
4
- local postPlayerInit, preGameExit, postNewLevel, postNewRoomEarly, restoreDefaultsAll, restoreDefaults, clearAndCopyAllElements, mod, loadedDataOnThisRun
6
+ local postPlayerInit, preGameExit, postNewLevel, postNewRoomEarly, restoreDefaultsAll, restoreDefaults, clearAndCopyAllElements, RESETTABLE_SAVE_DATA_KEYS, mod, loadedDataOnThisRun
5
7
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
8
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
7
9
  local ____cachedClasses = require("cachedClasses")
@@ -9,7 +11,6 @@ local game = ____cachedClasses.game
9
11
  local ____ModCallbackCustom = require("enums.ModCallbackCustom")
10
12
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
11
13
  local ____SaveDataKey = require("enums.private.SaveDataKey")
12
- local RESETTABLE_SAVE_DATA_KEYS = ____SaveDataKey.RESETTABLE_SAVE_DATA_KEYS
13
14
  local SaveDataKey = ____SaveDataKey.SaveDataKey
14
15
  local ____SerializationType = require("enums.SerializationType")
15
16
  local SerializationType = ____SerializationType.SerializationType
@@ -102,6 +103,7 @@ function clearAndCopyAllElements(self, oldTable, newTable)
102
103
  oldTable[key] = value
103
104
  end
104
105
  end
106
+ RESETTABLE_SAVE_DATA_KEYS = __TS__New(Set, {SaveDataKey.RUN, SaveDataKey.LEVEL, SaveDataKey.ROOM})
105
107
  mod = nil
106
108
  loadedDataOnThisRun = false
107
109
  ---
@@ -0,0 +1,23 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
4
+ /// <reference types="isaac-typescript-definitions" />
5
+ /**
6
+ * Spawn a trapdoor grid entity that will have one or more of the following custom attributes:
7
+ *
8
+ * - custom sprite
9
+ * - custom opening/closing logic
10
+ * - custom destination / logic for after the player enters
11
+ */
12
+ export declare function spawnCustomTrapdoor(gridIndexOrPosition: int | Vector): GridEntity;
13
+ /**
14
+ * Convert an existing trapdoor into a custom trapdoor that will have one or more of the following
15
+ * custom attributes:
16
+ *
17
+ * - custom sprite
18
+ * - custom opening/closing logic
19
+ * - custom destination / logic for after the player enters
20
+ */
21
+ export declare function initCustomTrapdoor(_trapdoor: GridEntity, _shouldSpawnOpenFunc?: typeof defaultShouldSpawnOpenFunc): void;
22
+ declare function defaultShouldSpawnOpenFunc(_entity: GridEntity | EntityEffect): boolean;
23
+ export {};
@@ -0,0 +1,44 @@
1
+ local ____exports = {}
2
+ local defaultShouldSpawnOpenFunc
3
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
+ local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
5
+ local ____cachedClasses = require("cachedClasses")
6
+ local game = ____cachedClasses.game
7
+ local ____gridEntity = require("functions.gridEntity")
8
+ local spawnGrid = ____gridEntity.spawnGrid
9
+ --- Convert an existing trapdoor into a custom trapdoor that will have one or more of the following
10
+ -- custom attributes:
11
+ --
12
+ -- - custom sprite
13
+ -- - custom opening/closing logic
14
+ -- - custom destination / logic for after the player enters
15
+ function ____exports.initCustomTrapdoor(self, _trapdoor, _shouldSpawnOpenFunc)
16
+ if _shouldSpawnOpenFunc == nil then
17
+ _shouldSpawnOpenFunc = defaultShouldSpawnOpenFunc
18
+ end
19
+ end
20
+ function defaultShouldSpawnOpenFunc(self, _entity)
21
+ local room = game:GetRoom()
22
+ local roomFrameCount = room:GetFrameCount()
23
+ local roomClear = room:IsClear()
24
+ if roomFrameCount == 0 then
25
+ if not roomClear then
26
+ return false
27
+ end
28
+ end
29
+ return false
30
+ end
31
+ --- Spawn a trapdoor grid entity that will have one or more of the following custom attributes:
32
+ --
33
+ -- - custom sprite
34
+ -- - custom opening/closing logic
35
+ -- - custom destination / logic for after the player enters
36
+ function ____exports.spawnCustomTrapdoor(self, gridIndexOrPosition)
37
+ local trapdoor = spawnGrid(nil, GridEntityType.TRAPDOOR, gridIndexOrPosition)
38
+ if trapdoor == nil then
39
+ error("Failed to spawn a custom trapdoor.")
40
+ end
41
+ ____exports.initCustomTrapdoor(nil, trapdoor)
42
+ return trapdoor
43
+ end
44
+ return ____exports
File without changes
File without changes
File without changes
File without changes
@@ -42,7 +42,7 @@ export declare function getCharacterDeathAnimationName(character: PlayerType): s
42
42
  * Mother's Kiss; use the `getPlayerMaxHeartContainers` helper function for that.
43
43
  */
44
44
  export declare function getCharacterMaxHeartContainers(character: PlayerType): int;
45
- /** Helper function to get the name of a character. Returns "unknown" for modded characters. */
45
+ /** Helper function to get the name of a character. Returns "Unknown" for modded characters. */
46
46
  export declare function getCharacterName(character: PlayerType): string;
47
47
  export declare function isModdedCharacter(character: PlayerType): boolean;
48
48
  export declare function isVanillaCharacter(character: PlayerType): boolean;
@@ -5,7 +5,6 @@ local ____constantsFirstLast = require("constantsFirstLast")
5
5
  local LAST_VANILLA_CHARACTER = ____constantsFirstLast.LAST_VANILLA_CHARACTER
6
6
  local ____characterNames = require("objects.characterNames")
7
7
  local CHARACTER_NAMES = ____characterNames.CHARACTER_NAMES
8
- local DEFAULT_CHARACTER_NAME = ____characterNames.DEFAULT_CHARACTER_NAME
9
8
  local ____charactersThatStartWithAnActiveItemSet = require("sets.charactersThatStartWithAnActiveItemSet")
10
9
  local CHARACTERS_THAT_START_WITH_AN_ACTIVE_ITEM_SET = ____charactersThatStartWithAnActiveItemSet.CHARACTERS_THAT_START_WITH_AN_ACTIVE_ITEM_SET
11
10
  local ____charactersWithBlackHeartFromEternalHeartSet = require("sets.charactersWithBlackHeartFromEternalHeartSet")
@@ -18,6 +17,9 @@ local ____charactersWithNoSoulHeartsSet = require("sets.charactersWithNoSoulHear
18
17
  local CHARACTERS_WITH_NO_SOUL_HEARTS_SET = ____charactersWithNoSoulHeartsSet.CHARACTERS_WITH_NO_SOUL_HEARTS_SET
19
18
  local ____lostStyleCharactersSet = require("sets.lostStyleCharactersSet")
20
19
  local LOST_STYLE_CHARACTERS_SET = ____lostStyleCharactersSet.LOST_STYLE_CHARACTERS_SET
20
+ function ____exports.isModdedCharacter(self, character)
21
+ return not ____exports.isVanillaCharacter(nil, character)
22
+ end
21
23
  function ____exports.isVanillaCharacter(self, character)
22
24
  return character <= LAST_VANILLA_CHARACTER
23
25
  end
@@ -82,15 +84,11 @@ function ____exports.getCharacterMaxHeartContainers(self, character)
82
84
  end
83
85
  return 12
84
86
  end
85
- --- Helper function to get the name of a character. Returns "unknown" for modded characters.
87
+ --- Helper function to get the name of a character. Returns "Unknown" for modded characters.
86
88
  function ____exports.getCharacterName(self, character)
87
- if ____exports.isVanillaCharacter(nil, character) then
88
- return "unknown"
89
+ if ____exports.isModdedCharacter(nil, character) then
90
+ return "Unknown"
89
91
  end
90
- local characterName = CHARACTER_NAMES[character]
91
- return characterName == nil and DEFAULT_CHARACTER_NAME or characterName
92
- end
93
- function ____exports.isModdedCharacter(self, character)
94
- return not ____exports.isVanillaCharacter(nil, character)
92
+ return CHARACTER_NAMES[character]
95
93
  end
96
94
  return ____exports
@@ -7,8 +7,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
7
7
  local CacheFlag = ____isaac_2Dtypescript_2Ddefinitions.CacheFlag
8
8
  local ____cachedClasses = require("cachedClasses")
9
9
  local itemConfig = ____cachedClasses.itemConfig
10
- local ____collectibles = require("functions.collectibles")
11
- local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
10
+ local ____collectibleSet = require("functions.collectibleSet")
11
+ local getCollectibleArray = ____collectibleSet.getCollectibleArray
12
12
  local ____enums = require("functions.enums")
13
13
  local getEnumValues = ____enums.getEnumValues
14
14
  local ____flag = require("functions.flag")
@@ -29,7 +29,7 @@ local CACHE_FLAG_TO_COLLECTIBLES_MAP = __TS__New(Map)
29
29
  local function initCacheFlagMap(self)
30
30
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
31
31
  local collectiblesSet = __TS__New(Set)
32
- for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
32
+ for ____, collectibleType in ipairs(getCollectibleArray(nil)) do
33
33
  if ____exports.collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
34
34
  collectiblesSet:add(collectibleType)
35
35
  end
@@ -6,9 +6,11 @@ local ____exports = {}
6
6
  local ____cachedClasses = require("cachedClasses")
7
7
  local itemConfig = ____cachedClasses.itemConfig
8
8
  local ____constantsFirstLast = require("constantsFirstLast")
9
+ local FIRST_COLLECTIBLE_TYPE = ____constantsFirstLast.FIRST_COLLECTIBLE_TYPE
10
+ local LAST_COLLECTIBLE_TYPE = ____constantsFirstLast.LAST_COLLECTIBLE_TYPE
9
11
  local LAST_VANILLA_COLLECTIBLE_TYPE = ____constantsFirstLast.LAST_VANILLA_COLLECTIBLE_TYPE
10
- local ____collectibles = require("functions.collectibles")
11
- local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
12
+ local ____utils = require("functions.utils")
13
+ local irange = ____utils.irange
12
14
  local ALL_COLLECTIBLES_ARRAY = {}
13
15
  local VANILLA_COLLECTIBLES_ARRAY = {}
14
16
  local MODDED_COLLECTIBLES_ARRAY = {}
@@ -19,7 +21,8 @@ local function initCollectibleArraysAndSets(self)
19
21
  if #ALL_COLLECTIBLES_ARRAY ~= 0 then
20
22
  return
21
23
  end
22
- for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
24
+ local collectibleTypeRange = irange(nil, FIRST_COLLECTIBLE_TYPE, LAST_COLLECTIBLE_TYPE)
25
+ for ____, collectibleType in ipairs(collectibleTypeRange) do
23
26
  do
24
27
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
25
28
  if itemConfigItem == nil then
@@ -8,8 +8,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
8
8
  local ItemConfigTag = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTag
9
9
  local ____cachedClasses = require("cachedClasses")
10
10
  local itemConfig = ____cachedClasses.itemConfig
11
- local ____collectibles = require("functions.collectibles")
12
- local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
11
+ local ____collectibleSet = require("functions.collectibleSet")
12
+ local getCollectibleArray = ____collectibleSet.getCollectibleArray
13
13
  local ____enums = require("functions.enums")
14
14
  local getEnumValues = ____enums.getEnumValues
15
15
  local ____flag = require("functions.flag")
@@ -33,7 +33,7 @@ local function initTagMap(self)
33
33
  __TS__New(Set)
34
34
  )
35
35
  end
36
- for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
36
+ for ____, collectibleType in ipairs(getCollectibleArray(nil)) do
37
37
  for ____, itemConfigTag in ipairs(getEnumValues(nil, ItemConfigTag)) do
38
38
  do
39
39
  if not ____exports.collectibleHasTag(nil, collectibleType, itemConfigTag) then
@@ -106,15 +106,6 @@ export declare function getCollectibleQuality(collectibleType: CollectibleType):
106
106
  * ```
107
107
  */
108
108
  export declare function getCollectibleTags(collectibleType: CollectibleType): BitFlags<ItemConfigTag>;
109
- /**
110
- * Helper function to get an array that represents the range from the first collectible type to the
111
- * last collectible type. This will include integers that do not represent any valid collectible
112
- * types.
113
- *
114
- * This function is only useful when building collectible type objects. For most purposes, you
115
- * should use the `getCollectibleSet` helper function instead.
116
- */
117
- export declare function getCollectibleTypeRange(): CollectibleType[];
118
109
  /**
119
110
  * Helper function to get an array that represents the all modded collectible types.
120
111
  *
@@ -311,15 +311,6 @@ function ____exports.getCollectibleTags(self, collectibleType)
311
311
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
312
312
  return itemConfigItem == nil and ItemConfigTagZero or itemConfigItem.Tags
313
313
  end
314
- --- Helper function to get an array that represents the range from the first collectible type to the
315
- -- last collectible type. This will include integers that do not represent any valid collectible
316
- -- types.
317
- --
318
- -- This function is only useful when building collectible type objects. For most purposes, you
319
- -- should use the `getCollectibleSet` helper function instead.
320
- function ____exports.getCollectibleTypeRange(self)
321
- return irange(nil, FIRST_COLLECTIBLE_TYPE, LAST_COLLECTIBLE_TYPE)
322
- end
323
314
  --- Helper function to get an array that represents the all modded collectible types.
324
315
  --
325
316
  -- This function is only useful when building collectible type objects. For most purposes, you
@@ -20,10 +20,7 @@ local getPlayerBlackHearts = ____player.getPlayerBlackHearts
20
20
  local getPlayerHearts = ____player.getPlayerHearts
21
21
  local getPlayerSoulHearts = ____player.getPlayerSoulHearts
22
22
  local isCharacter = ____player.isCharacter
23
- local isKeeper = ____player.isKeeper
24
23
  local setActiveItem = ____player.setActiveItem
25
- local ____utils = require("functions.utils")
26
- local ____repeat = ____utils["repeat"]
27
24
  function ____exports.removeAllPlayerHealth(self, player)
28
25
  local goldenHearts = player:GetGoldenHearts()
29
26
  local eternalHearts = player:GetEternalHearts()
@@ -89,24 +86,15 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
89
86
  end
90
87
  end
91
88
  )
92
- if isKeeper(nil, player) then
93
- local numCoinsToHeal = playerHealth.hearts / 2
94
- player:AddCoins(numCoinsToHeal)
89
+ player:AddRottenHearts(playerHealth.rottenHearts)
90
+ if character == PlayerType.MAGDALENE_B then
91
+ local effectiveHearts = playerHealth.hearts / 2
92
+ player:AddHearts(effectiveHearts)
95
93
  else
96
- player:AddRottenHearts(playerHealth.rottenHearts)
97
- ____repeat(
98
- nil,
99
- playerHealth.hearts,
100
- function()
101
- player:AddHearts(1)
102
- if character == PlayerType.MAGDALENE_B then
103
- player:AddHearts(-1)
104
- end
105
- end
106
- )
107
- player:AddGoldenHearts(playerHealth.goldenHearts)
108
- player:AddBrokenHearts(playerHealth.brokenHearts)
94
+ player:AddHearts(playerHealth.hearts)
109
95
  end
96
+ player:AddGoldenHearts(playerHealth.goldenHearts)
97
+ player:AddBrokenHearts(playerHealth.brokenHearts)
110
98
  if character == PlayerType.BETHANY then
111
99
  player:SetSoulCharge(playerHealth.soulCharges)
112
100
  elseif character == PlayerType.BETHANY_B then
@@ -1,5 +1,4 @@
1
1
  import { PlayerType } from "isaac-typescript-definitions";
2
- export declare const DEFAULT_CHARACTER_NAME = "Unknown";
3
2
  export declare const CHARACTER_NAMES: {
4
3
  readonly [key in PlayerType]: string;
5
4
  };
@@ -1,7 +1,6 @@
1
1
  local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
4
- ____exports.DEFAULT_CHARACTER_NAME = "Unknown"
5
4
  ____exports.CHARACTER_NAMES = {
6
5
  [PlayerType.POSSESSOR] = "Possessor",
7
6
  [PlayerType.ISAAC] = "Isaac",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "4.2.4",
3
+ "version": "4.2.8",
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": "^3.0.11"
25
+ "isaac-typescript-definitions": "^3.0.12"
26
26
  }
27
27
  }