isaacscript-common 4.2.3 → 4.2.6

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.
@@ -196,6 +196,7 @@ commandFunctionsMap:set("listGrid", commands.listGrid)
196
196
  commandFunctionsMap:set("listGridAll", commands.listGridAll)
197
197
  commandFunctionsMap:set("lowHP", commands.lowHP)
198
198
  commandFunctionsMap:set("luck", commands.luck)
199
+ commandFunctionsMap:set("mana", commands.mana)
199
200
  commandFunctionsMap:set("map", commands.map)
200
201
  commandFunctionsMap:set("maxHearts", commands.maxHearts)
201
202
  commandFunctionsMap:set("mh", commands.mh)
@@ -209,6 +209,8 @@ export declare function listGridAll(params: string): void;
209
209
  export declare function lowHP(): void;
210
210
  /** Alias for "debug 9". */
211
211
  export declare function luck(): void;
212
+ /** Alias for the "poopMana" command. */
213
+ export declare function mana(params: string): void;
212
214
  /** Completely reveals the entire map, including the Ultra Secret Room. */
213
215
  export declare function map(): void;
214
216
  /**
@@ -148,6 +148,21 @@ function ____exports.oneHP(self)
148
148
  end
149
149
  printConsole(nil, "Set every NPC to 1 HP.")
150
150
  end
151
+ --- Gives a poop mana charge. This only affects Tainted Blue Baby. Provide a number to give a custom
152
+ -- amount of charges. (You can use negative numbers to remove charges.)
153
+ function ____exports.poopMana(self, params)
154
+ local charges = 1
155
+ if params ~= "" then
156
+ local num = tonumber(params)
157
+ if num == nil then
158
+ printConsole(nil, "That is an invalid amount of mana to add.")
159
+ return
160
+ end
161
+ charges = num
162
+ end
163
+ local player = Isaac.GetPlayer()
164
+ player:AddPoopMana(charges)
165
+ end
151
166
  --- Gives a half soul heart. Provide a number to give a custom amount of hearts. (You can use
152
167
  -- negative numbers to remove hearts.)
153
168
  function ____exports.soulHearts(self, params)
@@ -658,6 +673,10 @@ end
658
673
  function ____exports.luck(self)
659
674
  Isaac.ExecuteCommand("debug 9")
660
675
  end
676
+ --- Alias for the "poopMana" command.
677
+ function ____exports.mana(self, params)
678
+ ____exports.poopMana(nil, params)
679
+ end
661
680
  --- Completely reveals the entire map, including the Ultra Secret Room.
662
681
  function ____exports.map(self)
663
682
  local level = game:GetLevel()
@@ -776,21 +795,6 @@ function ____exports.pocket(self, params)
776
795
  local player = Isaac.GetPlayer()
777
796
  player:SetPocketActiveItem(collectibleType, ActiveSlot.POCKET)
778
797
  end
779
- --- Gives a poop mana charge. This only affects Tainted Blue Baby. Provide a number to give a custom
780
- -- amount of charges. (You can use negative numbers to remove charges.)
781
- function ____exports.poopMana(self, params)
782
- local charges = 1
783
- if params ~= "" then
784
- local num = tonumber(params)
785
- if num == nil then
786
- printConsole(nil, "That is an invalid amount of mana to add.")
787
- return
788
- end
789
- charges = num
790
- end
791
- local player = Isaac.GetPlayer()
792
- player:AddPoopMana(charges)
793
- end
794
798
  --- Alias for the "getPosition" command.
795
799
  function ____exports.positionCommand(self)
796
800
  ____exports.getPosition(nil)
@@ -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
@@ -84,13 +86,9 @@ function ____exports.getCharacterMaxHeartContainers(self, character)
84
86
  end
85
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
89
+ if ____exports.isModdedCharacter(nil, character) then
88
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
@@ -21,8 +21,6 @@ local getPlayerHearts = ____player.getPlayerHearts
21
21
  local getPlayerSoulHearts = ____player.getPlayerSoulHearts
22
22
  local isCharacter = ____player.isCharacter
23
23
  local setActiveItem = ____player.setActiveItem
24
- local ____utils = require("functions.utils")
25
- local ____repeat = ____utils["repeat"]
26
24
  function ____exports.removeAllPlayerHealth(self, player)
27
25
  local goldenHearts = player:GetGoldenHearts()
28
26
  local eternalHearts = player:GetEternalHearts()
@@ -89,16 +87,12 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
89
87
  end
90
88
  )
91
89
  player:AddRottenHearts(playerHealth.rottenHearts)
92
- ____repeat(
93
- nil,
94
- playerHealth.hearts,
95
- function()
96
- player:AddHearts(1)
97
- if character == PlayerType.MAGDALENE_B then
98
- player:AddHearts(-1)
99
- end
100
- end
101
- )
90
+ if character == PlayerType.MAGDALENE_B then
91
+ local effectiveHearts = playerHealth.hearts / 2
92
+ player:AddHearts(effectiveHearts)
93
+ else
94
+ player:AddHearts(playerHealth.hearts)
95
+ end
102
96
  player:AddGoldenHearts(playerHealth.goldenHearts)
103
97
  player:AddBrokenHearts(playerHealth.brokenHearts)
104
98
  if character == PlayerType.BETHANY then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "4.2.3",
3
+ "version": "4.2.6",
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.10"
25
+ "isaac-typescript-definitions": "^3.0.11"
26
26
  }
27
27
  }