isaacscript-common 1.2.139 → 1.2.142

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 (61) hide show
  1. package/dist/callbacks/postSlotRender.d.ts +1 -0
  2. package/dist/callbacks/postSlotRender.lua +73 -0
  3. package/dist/callbacks/subscriptions/postSlotAnimationChanged.d.ts +2 -0
  4. package/dist/callbacks/subscriptions/postSlotAnimationChanged.lua +25 -0
  5. package/dist/features/extraConsoleCommands/commands.lua +76 -62
  6. package/dist/features/extraConsoleCommands/init.lua +6 -4
  7. package/dist/features/playerInventory.d.ts +6 -0
  8. package/dist/features/playerInventory.lua +73 -0
  9. package/dist/functions/cards.lua +12 -18
  10. package/dist/functions/challenges.lua +3 -2
  11. package/dist/functions/collectibles.lua +8 -14
  12. package/dist/functions/map.d.ts +4 -1
  13. package/dist/functions/map.lua +5 -1
  14. package/dist/functions/pills.lua +10 -15
  15. package/dist/functions/player.d.ts +2 -0
  16. package/dist/functions/player.lua +37 -81
  17. package/dist/functions/playerHealth.d.ts +3 -3
  18. package/dist/functions/transformations.lua +3 -3
  19. package/dist/functions/trinkets.lua +8 -14
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.lua +5 -0
  22. package/dist/maps/cardDescriptionMap.d.ts +4 -1
  23. package/dist/maps/cardDescriptionMap.lua +103 -102
  24. package/dist/maps/cardNameMap.d.ts +4 -1
  25. package/dist/maps/cardNameMap.lua +103 -102
  26. package/dist/maps/cardTypeMap.d.ts +3 -1
  27. package/dist/maps/cardTypeMap.lua +102 -102
  28. package/dist/maps/challengeNameMap.d.ts +4 -1
  29. package/dist/maps/challengeNameMap.lua +50 -50
  30. package/dist/maps/characterNameMap.d.ts +5 -0
  31. package/dist/maps/characterNameMap.lua +49 -0
  32. package/dist/maps/collectibleDescriptionMap.d.ts +1 -0
  33. package/dist/maps/collectibleDescriptionMap.lua +1 -0
  34. package/dist/maps/collectibleNameMap.d.ts +1 -0
  35. package/dist/maps/collectibleNameMap.lua +1 -0
  36. package/dist/maps/pillEffectClassMap.d.ts +4 -1
  37. package/dist/maps/pillEffectClassMap.lua +56 -55
  38. package/dist/maps/pillEffectNameMap.d.ts +4 -1
  39. package/dist/maps/pillEffectNameMap.lua +55 -55
  40. package/dist/maps/pillEffectTypeMap.d.ts +4 -1
  41. package/dist/maps/pillEffectTypeMap.lua +55 -55
  42. package/dist/maps/roomTypeNameMap.d.ts +4 -1
  43. package/dist/maps/roomTypeNameMap.lua +34 -35
  44. package/dist/maps/transformationNameMap.d.ts +4 -1
  45. package/dist/maps/transformationNameMap.lua +19 -20
  46. package/dist/maps/trinketDescriptionMap.d.ts +1 -0
  47. package/dist/maps/trinketDescriptionMap.lua +1 -0
  48. package/dist/maps/trinketNameMap.d.ts +1 -0
  49. package/dist/maps/trinketNameMap.lua +1 -0
  50. package/dist/types/CallbackParametersCustom.d.ts +5 -0
  51. package/dist/types/CardType.d.ts +10 -8
  52. package/dist/types/CardType.lua +9 -7
  53. package/dist/types/ModCallbacksCustom.d.ts +10 -9
  54. package/dist/types/ModCallbacksCustom.lua +11 -9
  55. package/dist/types/ModUpgraded.lua +8 -0
  56. package/dist/types/PillEffectClass.d.ts +11 -5
  57. package/dist/types/PillEffectClass.lua +8 -5
  58. package/dist/types/PillEffectType.d.ts +10 -4
  59. package/dist/types/PillEffectType.lua +7 -4
  60. package/dist/upgradeMod.lua +3 -3
  61. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,73 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local hasSubscriptions, postRender, checkSlotAnimationChanged, checkSlotBroken, BROKEN_ANIMATIONS, v
7
+ local ____exports = require("features.saveDataManager.exports")
8
+ local saveDataManager = ____exports.saveDataManager
9
+ local ____entitySpecific = require("functions.entitySpecific")
10
+ local getSlots = ____entitySpecific.getSlots
11
+ local ____DefaultMap = require("types.DefaultMap")
12
+ local DefaultMap = ____DefaultMap.DefaultMap
13
+ local ____postSlotAnimationChanged = require("callbacks.subscriptions.postSlotAnimationChanged")
14
+ local postSlotAnimationChangedFire = ____postSlotAnimationChanged.postSlotAnimationChangedFire
15
+ local postSlotAnimationChangedHasSubscriptions = ____postSlotAnimationChanged.postSlotAnimationChangedHasSubscriptions
16
+ local ____postSlotDestroyed = require("callbacks.subscriptions.postSlotDestroyed")
17
+ local postSlotDestroyedFire = ____postSlotDestroyed.postSlotDestroyedFire
18
+ local postSlotDestroyedHasSubscriptions = ____postSlotDestroyed.postSlotDestroyedHasSubscriptions
19
+ local ____postSlotRender = require("callbacks.subscriptions.postSlotRender")
20
+ local postSlotRenderFire = ____postSlotRender.postSlotRenderFire
21
+ local postSlotRenderHasSubscriptions = ____postSlotRender.postSlotRenderHasSubscriptions
22
+ function hasSubscriptions(self)
23
+ return postSlotRenderHasSubscriptions(nil) or postSlotDestroyedHasSubscriptions(nil) or postSlotAnimationChangedHasSubscriptions(nil)
24
+ end
25
+ function postRender(self)
26
+ if not hasSubscriptions(nil) then
27
+ return
28
+ end
29
+ for ____, slot in ipairs(getSlots(nil)) do
30
+ postSlotRenderFire(nil, slot)
31
+ checkSlotAnimationChanged(nil, slot)
32
+ checkSlotBroken(nil, slot)
33
+ end
34
+ end
35
+ function checkSlotAnimationChanged(self, slot)
36
+ local sprite = slot:GetSprite()
37
+ local currentAnimation = sprite:GetAnimation()
38
+ local ptrHash = GetPtrHash(slot)
39
+ local previousAnimation = v.room.slotAnimations:getAndSetDefault(ptrHash, slot)
40
+ v.room.slotAnimations:set(ptrHash, currentAnimation)
41
+ if currentAnimation ~= previousAnimation then
42
+ postSlotAnimationChangedFire(nil, slot, previousAnimation, currentAnimation)
43
+ end
44
+ end
45
+ function checkSlotBroken(self, slot)
46
+ local ptrHash = GetPtrHash(slot)
47
+ local alreadyBroken = v.room.brokenSlots:has(ptrHash)
48
+ if alreadyBroken then
49
+ return
50
+ end
51
+ local sprite = slot:GetSprite()
52
+ local animation = sprite:GetAnimation()
53
+ if BROKEN_ANIMATIONS:has(animation) then
54
+ v.room.brokenSlots:add(ptrHash)
55
+ postSlotDestroyedFire(nil, slot)
56
+ end
57
+ end
58
+ BROKEN_ANIMATIONS = __TS__New(Set, {"Broken", "Death"})
59
+ v = {room = {
60
+ slotAnimations = __TS__New(
61
+ DefaultMap,
62
+ function(____, _key, slot)
63
+ local sprite = slot:GetSprite()
64
+ return sprite:GetAnimation()
65
+ end
66
+ ),
67
+ brokenSlots = __TS__New(Set)
68
+ }}
69
+ function ____exports.postSlotRenderCallbacksInit(self, mod)
70
+ saveDataManager(nil, "postSlotRender", v, hasSubscriptions)
71
+ mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
72
+ end
73
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare type PostSlotAnimationChangedCallbackType = (slot: Entity, previousAnimation: string, currentAnimation: string) => void;
@@ -0,0 +1,25 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
+ local ____exports = {}
5
+ local subscriptions = {}
6
+ function ____exports.postSlotAnimationChangedHasSubscriptions(self)
7
+ return #subscriptions > 0
8
+ end
9
+ function ____exports.postSlotAnimationChangedRegister(self, callback, slotVariant)
10
+ __TS__ArrayPush(subscriptions, {callback, slotVariant})
11
+ end
12
+ function ____exports.postSlotAnimationChangedFire(self, slot, previousAnimation, currentAnimation)
13
+ for ____, ____value in ipairs(subscriptions) do
14
+ local callback = ____value[1]
15
+ local slotVariant = ____value[2]
16
+ do
17
+ if slotVariant ~= nil and slotVariant ~= slot.Variant then
18
+ goto __continue5
19
+ end
20
+ callback(nil, slot, previousAnimation, currentAnimation)
21
+ end
22
+ ::__continue5::
23
+ end
24
+ end
25
+ return ____exports
@@ -11,6 +11,8 @@ local sfxManager = ____cachedClasses.sfxManager
11
11
  local ____constants = require("constants")
12
12
  local PILL_GIANT_FLAG = ____constants.PILL_GIANT_FLAG
13
13
  local TRINKET_GOLDEN_FLAG = ____constants.TRINKET_GOLDEN_FLAG
14
+ local ____cards = require("functions.cards")
15
+ local getCardName = ____cards.getCardName
14
16
  local ____gridEntity = require("functions.gridEntity")
15
17
  local spawnGridEntityWithVariant = ____gridEntity.spawnGridEntityWithVariant
16
18
  local ____log = require("functions.log")
@@ -24,7 +26,10 @@ local ____map = require("functions.map")
24
26
  local getMapPartialMatch = ____map.getMapPartialMatch
25
27
  local ____npc = require("functions.npc")
26
28
  local getNPCs = ____npc.getNPCs
29
+ local ____pills = require("functions.pills")
30
+ local getPillEffectName = ____pills.getPillEffectName
27
31
  local ____player = require("functions.player")
32
+ local getCharacterName = ____player.getCharacterName
28
33
  local getPlayers = ____player.getPlayers
29
34
  local useActiveItemTemp = ____player.useActiveItemTemp
30
35
  local ____playerHealth = require("functions.playerHealth")
@@ -49,6 +54,7 @@ local PILL_EFFECT_MAP = ____pillEffectMap.PILL_EFFECT_MAP
49
54
  local ____roomTypeMap = require("maps.roomTypeMap")
50
55
  local ROOM_TYPE_MAP = ____roomTypeMap.ROOM_TYPE_MAP
51
56
  local ____roomTypeNameMap = require("maps.roomTypeNameMap")
57
+ local DEFAULT_ROOM_TYPE_NAME = ____roomTypeNameMap.DEFAULT_ROOM_TYPE_NAME
52
58
  local ROOM_TYPE_NAME_MAP = ____roomTypeNameMap.ROOM_TYPE_NAME_MAP
53
59
  local ____HealthType = require("types.HealthType")
54
60
  local HealthType = ____HealthType.HealthType
@@ -176,8 +182,8 @@ function spawnTrapdoorOrCrawlspace(self, trapdoor)
176
182
  spawnGridEntityWithVariant(nil, gridEntityType, 0, gridIndex)
177
183
  end
178
184
  function warpToRoomType(self, roomType)
179
- local roomTypeName = ROOM_TYPE_NAME_MAP:get(roomType)
180
- if roomTypeName == nil then
185
+ local roomTypeName = ROOM_TYPE_NAME_MAP[roomType]
186
+ if roomTypeName == nil or roomTypeName == DEFAULT_ROOM_TYPE_NAME then
181
187
  printConsole(
182
188
  nil,
183
189
  "Invalid room type: " .. tostring(roomType)
@@ -185,17 +191,14 @@ function warpToRoomType(self, roomType)
185
191
  end
186
192
  local gridIndexes = getRoomGridIndexesForType(nil, roomType)
187
193
  if #gridIndexes == 0 then
188
- printConsole(
189
- nil,
190
- ("There are no " .. tostring(roomTypeName)) .. "s on this floor."
191
- )
194
+ printConsole(nil, ("There are no " .. roomTypeName) .. "s on this floor.")
192
195
  return
193
196
  end
194
197
  local firstGridIndex = gridIndexes[1]
195
198
  changeRoom(nil, firstGridIndex)
196
199
  printConsole(
197
200
  nil,
198
- ((("Warped to room type: " .. tostring(roomTypeName)) .. " (") .. tostring(roomType)) .. ")"
201
+ ((("Warped to room type: " .. roomTypeName) .. " (") .. tostring(roomType)) .. ")"
199
202
  )
200
203
  end
201
204
  DEFAULT_MOVE_UNITS = 0.5
@@ -322,28 +325,30 @@ function ____exports.card(self, params)
322
325
  printConsole(nil, "You must specify a card name or number.")
323
326
  return
324
327
  end
328
+ local cardNum
325
329
  local num = tonumber(params)
326
- if num ~= nil then
330
+ if num == nil then
331
+ local match = getMapPartialMatch(nil, params, CARD_MAP)
332
+ if match == nil then
333
+ printConsole(nil, "Unknown card: " .. params)
334
+ return
335
+ end
336
+ cardNum = match[2]
337
+ else
327
338
  if num < 1 or num >= Card.NUM_CARDS then
328
- printConsole(nil, "That is an invalid card sub-type.")
339
+ printConsole(
340
+ nil,
341
+ "Invalid card sub-type: " .. tostring(num)
342
+ )
329
343
  return
330
344
  end
331
- Isaac.ExecuteCommand("g k" .. tostring(num))
332
- printConsole(
333
- nil,
334
- "Gave card: " .. tostring(num)
335
- )
336
- return
337
- end
338
- local match = getMapPartialMatch(nil, params, CARD_MAP)
339
- if match == nil then
340
- printConsole(nil, "Unknown card: " .. params)
341
- return
345
+ cardNum = num
342
346
  end
343
- Isaac.ExecuteCommand("g k" .. tostring(match))
347
+ local cardName = getCardName(nil, cardNum)
348
+ Isaac.ExecuteCommand("g k" .. tostring(cardNum))
344
349
  printConsole(
345
350
  nil,
346
- "Gave card: " .. tostring(match)
351
+ ((("Gave card: " .. cardName) .. " (") .. tostring(cardNum)) .. ")"
347
352
  )
348
353
  end
349
354
  function ____exports.cards(self)
@@ -382,28 +387,30 @@ function ____exports.characterCommand(self, params)
382
387
  printConsole(nil, "You must specify a character name or number.")
383
388
  return
384
389
  end
390
+ local character
385
391
  local num = tonumber(params)
386
- if num ~= nil then
392
+ if num == nil then
393
+ local match = getMapPartialMatch(nil, params, CHARACTER_MAP)
394
+ if match == nil then
395
+ printConsole(nil, "Unknown character: " .. params)
396
+ return
397
+ end
398
+ character = match[2]
399
+ else
387
400
  if num < 0 or num >= PlayerType.NUM_PLAYER_TYPES then
388
- printConsole(nil, "That is an invalid player sub-type.")
401
+ printConsole(
402
+ nil,
403
+ "Invalid player sub-type: " .. tostring(num)
404
+ )
389
405
  return
390
406
  end
391
- printConsole(
392
- nil,
393
- "Restarting as character: " .. tostring(num)
394
- )
395
- restart(nil, num)
396
- return
397
- end
398
- local match = getMapPartialMatch(nil, params, CHARACTER_MAP)
399
- if match == nil then
400
- printConsole(nil, "Unknown character: " .. params)
401
- return
407
+ character = num
402
408
  end
403
- restart(nil, match)
409
+ local characterName = getCharacterName(nil, character)
410
+ restart(nil, character)
404
411
  printConsole(
405
412
  nil,
406
- "Restarting as character: " .. tostring(match)
413
+ ((("Restarting as character: " .. characterName) .. " (") .. tostring(character)) .. ")"
407
414
  )
408
415
  end
409
416
  function ____exports.charge(self, params)
@@ -600,28 +607,30 @@ function ____exports.pill(self, params)
600
607
  printConsole(nil, "You must specify a pill name or number.")
601
608
  return
602
609
  end
610
+ local pillEffect
603
611
  local num = tonumber(params)
604
- if num ~= nil then
612
+ if num == nil then
613
+ local match = getMapPartialMatch(nil, params, PILL_EFFECT_MAP)
614
+ if match == nil then
615
+ printConsole(nil, "Unknown pill effect: " .. params)
616
+ return
617
+ end
618
+ pillEffect = match[2]
619
+ else
605
620
  if num < 1 or num >= PillEffect.NUM_PILL_EFFECTS then
606
- printConsole(nil, "That is an invalid pill effect ID.")
621
+ printConsole(
622
+ nil,
623
+ "Invalid pill effect ID: " .. tostring(num)
624
+ )
607
625
  return
608
626
  end
609
- Isaac.ExecuteCommand("g p" .. tostring(num))
610
- printConsole(
611
- nil,
612
- "Gave pill: " .. tostring(num)
613
- )
614
- return
615
- end
616
- local match = getMapPartialMatch(nil, params, PILL_EFFECT_MAP)
617
- if match == nil then
618
- printConsole(nil, "Unknown pill effect: " .. params)
619
- return
627
+ pillEffect = num
620
628
  end
621
- Isaac.ExecuteCommand("g p" .. tostring(match))
629
+ local pillEffectName = getPillEffectName(nil, pillEffect)
630
+ Isaac.ExecuteCommand("g p" .. tostring(pillEffect))
622
631
  printConsole(
623
632
  nil,
624
- "Gave pill: " .. tostring(match)
633
+ ((("Gave pill: " .. pillEffectName) .. " (") .. tostring(pillEffect)) .. ")"
625
634
  )
626
635
  end
627
636
  function ____exports.pills(self)
@@ -911,20 +920,25 @@ function ____exports.warp(self, params)
911
920
  printConsole(nil, "You must specify a room type name or number.")
912
921
  return
913
922
  end
923
+ local roomType
914
924
  local num = tonumber(params)
915
- if num ~= nil then
925
+ if num == nil then
926
+ local match = getMapPartialMatch(nil, params, ROOM_TYPE_MAP)
927
+ if match == nil then
928
+ printConsole(nil, "Unknown room type: " .. params)
929
+ return
930
+ end
931
+ roomType = match[2]
932
+ else
916
933
  if num < 1 or num >= RoomType.NUM_ROOMTYPES then
917
- printConsole(nil, "That is an invalid room type.")
934
+ printConsole(
935
+ nil,
936
+ "Invalid room type: " .. tostring(num)
937
+ )
918
938
  return
919
939
  end
920
- warpToRoomType(nil, num)
921
- return
922
- end
923
- local match = getMapPartialMatch(nil, params, ROOM_TYPE_MAP)
924
- if match == nil then
925
- printConsole(nil, "Unknown room type: " .. params)
926
- return
940
+ roomType = num
927
941
  end
928
- warpToRoomType(nil, match)
942
+ warpToRoomType(nil, roomType)
929
943
  end
930
944
  return ____exports
@@ -44,12 +44,14 @@ function postCurseEval(self, curses)
44
44
  return v.persistent.disableCurses and LevelCurse.CURSE_NONE or curses
45
45
  end
46
46
  function executeCmd(self, command, params)
47
- local commandFunction = getMapPartialMatch(nil, command, commandFunctionsMap)
48
- if commandFunction == nil then
47
+ local resultTuple = getMapPartialMatch(nil, command, commandFunctionsMap)
48
+ if resultTuple == nil then
49
49
  printConsole(nil, "That is an invalid console command.")
50
- else
51
- commandFunction(nil, params)
50
+ return
52
51
  end
52
+ local commandName, commandFunction = table.unpack(resultTuple)
53
+ printConsole(nil, "Command: " .. commandName)
54
+ commandFunction(nil, params)
53
55
  end
54
56
  function postFireTear(self, tear)
55
57
  if v.run.chaosCardTears then
@@ -0,0 +1,6 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to get all of the collectibles that the player has gotten so far on this run, in
4
+ * order. This does not include active items.
5
+ */
6
+ export declare function getPlayerInventory(player: EntityPlayer): CollectibleType[];
@@ -0,0 +1,73 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local __TS__New = ____lualib.__TS__New
4
+ local Set = ____lualib.Set
5
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
+ local __TS__Iterator = ____lualib.__TS__Iterator
7
+ local ____exports = {}
8
+ local newPlayerInventory, useItemD4, postPlayerInit, postItemPickup, v
9
+ local ____featuresInitialized = require("featuresInitialized")
10
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
11
+ local ____collectibleSet = require("functions.collectibleSet")
12
+ local getCollectibleSet = ____collectibleSet.getCollectibleSet
13
+ local ____player = require("functions.player")
14
+ local getPlayerIndex = ____player.getPlayerIndex
15
+ local ____utils = require("functions.utils")
16
+ local ____repeat = ____utils["repeat"]
17
+ local ____DefaultMap = require("types.DefaultMap")
18
+ local DefaultMap = ____DefaultMap.DefaultMap
19
+ local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
20
+ local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
21
+ local ____exports = require("features.saveDataManager.exports")
22
+ local saveDataManager = ____exports.saveDataManager
23
+ function newPlayerInventory(self, player)
24
+ local inventory = {}
25
+ local collectibleSet = getCollectibleSet(nil)
26
+ for ____, collectibleType in __TS__Iterator(collectibleSet:values()) do
27
+ local numCollectibles = player:GetCollectibleNum(collectibleType, true)
28
+ ____repeat(
29
+ nil,
30
+ numCollectibles,
31
+ function()
32
+ __TS__ArrayPush(inventory, collectibleType)
33
+ end
34
+ )
35
+ end
36
+ return inventory
37
+ end
38
+ function useItemD4(self, _collectibleType, _rng, player)
39
+ local playerIndex = getPlayerIndex(nil, player)
40
+ local inventory = newPlayerInventory(nil, player)
41
+ v.run.playersInventory:set(playerIndex, inventory)
42
+ end
43
+ function postPlayerInit(self, player)
44
+ local playerIndex = getPlayerIndex(nil, player)
45
+ if not v.run.playersInventory:has(playerIndex) then
46
+ local inventory = newPlayerInventory(nil, player)
47
+ v.run.playersInventory:set(playerIndex, inventory)
48
+ end
49
+ end
50
+ function postItemPickup(self, player, pickingUpItem)
51
+ if pickingUpItem.itemType == ItemType.ITEM_PASSIVE or pickingUpItem.itemType == ItemType.ITEM_FAMILIAR then
52
+ local playerIndex = getPlayerIndex(nil, player)
53
+ local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
54
+ __TS__ArrayPush(inventory, pickingUpItem.subType)
55
+ end
56
+ end
57
+ local FEATURE_NAME = "player inventory tracker"
58
+ v = {run = {playersInventory = __TS__New(
59
+ DefaultMap,
60
+ function(____, _key, player) return newPlayerInventory(nil, player) end
61
+ )}}
62
+ function ____exports.playerInventoryInit(self, mod)
63
+ saveDataManager(nil, "playerInventory", v)
64
+ mod:AddCallback(ModCallbacks.MC_USE_ITEM, useItemD4, CollectibleType.COLLECTIBLE_D4)
65
+ mod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, postPlayerInit)
66
+ mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_ITEM_PICKUP, postItemPickup)
67
+ end
68
+ function ____exports.getPlayerInventory(self, player)
69
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
70
+ local playerIndex = getPlayerIndex(nil, player)
71
+ return v.run.playersInventory:getAndSetDefault(playerIndex, player)
72
+ end
73
+ return ____exports
@@ -10,8 +10,10 @@ local ____cachedClasses = require("cachedClasses")
10
10
  local itemConfig = ____cachedClasses.itemConfig
11
11
  local ____cardDescriptionMap = require("maps.cardDescriptionMap")
12
12
  local CARD_DESCRIPTION_MAP = ____cardDescriptionMap.CARD_DESCRIPTION_MAP
13
+ local DEFAULT_CARD_DESCRIPTION = ____cardDescriptionMap.DEFAULT_CARD_DESCRIPTION
13
14
  local ____cardNameMap = require("maps.cardNameMap")
14
15
  local CARD_NAME_MAP = ____cardNameMap.CARD_NAME_MAP
16
+ local DEFAULT_CARD_NAME = ____cardNameMap.DEFAULT_CARD_NAME
15
17
  local ____cardTypeMap = require("maps.cardTypeMap")
16
18
  local CARD_TYPE_MAP = ____cardTypeMap.CARD_TYPE_MAP
17
19
  local DEFAULT_CARD_TYPE = ____cardTypeMap.DEFAULT_CARD_TYPE
@@ -67,7 +69,7 @@ function ____exports.getCardsOfType(self, ...)
67
69
  return matchingCards
68
70
  end
69
71
  function ____exports.getCardType(self, card)
70
- local cardType = CARD_TYPE_MAP:get(card)
72
+ local cardType = CARD_TYPE_MAP[card]
71
73
  return cardType == nil and DEFAULT_CARD_TYPE or cardType
72
74
  end
73
75
  function ____exports.getMaxCards(self)
@@ -76,34 +78,26 @@ end
76
78
  CARD_TYPE_TO_CARDS_MAP = __TS__New(Map)
77
79
  CARD_SET = __TS__New(Set)
78
80
  function ____exports.getCardDescription(self, card)
79
- local defaultDescription = "Unknown"
80
- if type(card) ~= "number" then
81
- return defaultDescription
82
- end
83
- local cardDescription = CARD_DESCRIPTION_MAP:get(card)
81
+ local cardDescription = CARD_DESCRIPTION_MAP[card]
84
82
  if cardDescription ~= nil then
85
83
  return cardDescription
86
84
  end
87
85
  local itemConfigCard = itemConfig:GetCard(card)
88
- if itemConfigCard == nil then
89
- return defaultDescription
86
+ if itemConfigCard ~= nil then
87
+ return itemConfigCard.Description
90
88
  end
91
- return itemConfigCard.Description
89
+ return DEFAULT_CARD_DESCRIPTION
92
90
  end
93
91
  function ____exports.getCardName(self, card)
94
- local defaultName = "Unknown"
95
- if type(card) ~= "number" then
96
- return defaultName
97
- end
98
- local cardName = CARD_NAME_MAP:get(card)
99
- if cardName ~= nil then
92
+ local cardName = CARD_NAME_MAP[card]
93
+ if cardName ~= nil and cardName ~= DEFAULT_CARD_NAME then
100
94
  return cardName
101
95
  end
102
96
  local itemConfigCard = itemConfig:GetCard(card)
103
- if itemConfigCard == nil then
104
- return defaultName
97
+ if itemConfigCard ~= nil then
98
+ return itemConfigCard.Name
105
99
  end
106
- return itemConfigCard.Name
100
+ return DEFAULT_CARD_NAME
107
101
  end
108
102
  function ____exports.getRandomCard(self, seed, exceptions)
109
103
  if seed == nil then
@@ -2,8 +2,9 @@
2
2
  local ____exports = {}
3
3
  local ____challengeNameMap = require("maps.challengeNameMap")
4
4
  local CHALLENGE_NAME_MAP = ____challengeNameMap.CHALLENGE_NAME_MAP
5
+ local DEFAULT_CHALLENGE_NAME = ____challengeNameMap.DEFAULT_CHALLENGE_NAME
5
6
  function ____exports.getChallengeName(self, challenge)
6
- local challengeName = CHALLENGE_NAME_MAP:get(challenge)
7
- return challengeName == nil and "Unknown" or challengeName
7
+ local challengeName = CHALLENGE_NAME_MAP[challenge]
8
+ return challengeName == nil and DEFAULT_CHALLENGE_NAME or challengeName
8
9
  end
9
10
  return ____exports
@@ -8,8 +8,10 @@ local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
8
8
  local SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = ____constants.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES
9
9
  local ____collectibleDescriptionMap = require("maps.collectibleDescriptionMap")
10
10
  local COLLECTIBLE_DESCRIPTION_MAP = ____collectibleDescriptionMap.COLLECTIBLE_DESCRIPTION_MAP
11
+ local DEFAULT_COLLECTIBLE_DESCRIPTION = ____collectibleDescriptionMap.DEFAULT_COLLECTIBLE_DESCRIPTION
11
12
  local ____collectibleNameMap = require("maps.collectibleNameMap")
12
13
  local COLLECTIBLE_NAME_MAP = ____collectibleNameMap.COLLECTIBLE_NAME_MAP
14
+ local DEFAULT_COLLECTIBLE_NAME = ____collectibleNameMap.DEFAULT_COLLECTIBLE_NAME
13
15
  local ____flag = require("functions.flag")
14
16
  local hasFlag = ____flag.hasFlag
15
17
  local ____pickups = require("functions.pickups")
@@ -50,19 +52,15 @@ function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
50
52
  return hasFlag(nil, itemConfigItem.CacheFlags, cacheFlag)
51
53
  end
52
54
  function ____exports.getCollectibleDescription(self, collectibleType)
53
- local defaultDescription = "Unknown"
54
- if type(collectibleType) ~= "number" then
55
- return defaultDescription
56
- end
57
55
  local collectibleDescription = COLLECTIBLE_DESCRIPTION_MAP:get(collectibleType)
58
56
  if collectibleDescription ~= nil then
59
57
  return collectibleDescription
60
58
  end
61
59
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
62
- if itemConfigItem == nil then
63
- return defaultDescription
60
+ if itemConfigItem ~= nil then
61
+ return itemConfigItem.Description
64
62
  end
65
- return itemConfigItem.Description
63
+ return DEFAULT_COLLECTIBLE_DESCRIPTION
66
64
  end
67
65
  function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player)
68
66
  local maxHearts = player:GetMaxHearts()
@@ -116,19 +114,15 @@ function ____exports.getCollectibleMaxCharges(self, collectibleType)
116
114
  return itemConfigItem.MaxCharges
117
115
  end
118
116
  function ____exports.getCollectibleName(self, collectibleType)
119
- local defaultName = "Unknown"
120
- if type(collectibleType) ~= "number" then
121
- return defaultName
122
- end
123
117
  local collectibleName = COLLECTIBLE_NAME_MAP:get(collectibleType)
124
118
  if collectibleName ~= nil then
125
119
  return collectibleName
126
120
  end
127
121
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
128
- if itemConfigItem == nil then
129
- return defaultName
122
+ if itemConfigItem ~= nil then
123
+ return itemConfigItem.Name
130
124
  end
131
- return itemConfigItem.Name
125
+ return DEFAULT_COLLECTIBLE_NAME
132
126
  end
133
127
  function ____exports.getCollectiblePedestalType(self, collectible)
134
128
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
@@ -20,9 +20,12 @@ export declare function defaultMapGetNextSeed<K, A extends unknown[]>(map: Defau
20
20
  * ]);
21
21
  * const searchText = "f";
22
22
  * const match = getMapPartialMatch(map, searchText); // match is now equal to 123
23
+ *
24
+ * @returns If a match was found, returns a tuple of the map key and value. If a match was not
25
+ * found, returns undefined.
23
26
  * ```
24
27
  */
25
- export declare function getMapPartialMatch<T>(searchText: string, map: ReadonlyMap<string, T>): T | undefined;
28
+ export declare function getMapPartialMatch<T>(searchText: string, map: ReadonlyMap<string, T>): [string, T] | undefined;
26
29
  /**
27
30
  * Helper function to make using maps with `Seed` values easier. Use this instead of manually
28
31
  * getting the current value, incrementing it, and then setting it.
@@ -46,7 +46,11 @@ function ____exports.getMapPartialMatch(self, searchText, map)
46
46
  if matchingKey == nil then
47
47
  return nil
48
48
  end
49
- return map:get(matchingKey)
49
+ local value = map:get(matchingKey)
50
+ if value == nil then
51
+ return nil
52
+ end
53
+ return {matchingKey, value}
50
54
  end
51
55
  function ____exports.mapGetNextSeed(self, map, key)
52
56
  local seed = map:get(key)
@@ -3,39 +3,34 @@ local ____exports = {}
3
3
  local ____cachedClasses = require("cachedClasses")
4
4
  local itemConfig = ____cachedClasses.itemConfig
5
5
  local ____pillEffectClassMap = require("maps.pillEffectClassMap")
6
+ local DEFAULT_PILL_EFFECT_CLASS = ____pillEffectClassMap.DEFAULT_PILL_EFFECT_CLASS
6
7
  local PILL_EFFECT_CLASS_MAP = ____pillEffectClassMap.PILL_EFFECT_CLASS_MAP
7
8
  local ____pillEffectNameMap = require("maps.pillEffectNameMap")
9
+ local DEFAULT_PILL_EFFECT_NAME = ____pillEffectNameMap.DEFAULT_PILL_EFFECT_NAME
8
10
  local PILL_EFFECT_NAME_MAP = ____pillEffectNameMap.PILL_EFFECT_NAME_MAP
9
11
  local ____pillEffectTypeMap = require("maps.pillEffectTypeMap")
12
+ local DEFAULT_PILL_EFFECT_TYPE = ____pillEffectTypeMap.DEFAULT_PILL_EFFECT_TYPE
10
13
  local PILL_EFFECT_TYPE_MAP = ____pillEffectTypeMap.PILL_EFFECT_TYPE_MAP
11
- local ____PillEffectClass = require("types.PillEffectClass")
12
- local DEFAULT_PILL_EFFECT_CLASS = ____PillEffectClass.DEFAULT_PILL_EFFECT_CLASS
13
- local ____PillEffectType = require("types.PillEffectType")
14
- local DEFAULT_PILL_EFFECT_TYPE = ____PillEffectType.DEFAULT_PILL_EFFECT_TYPE
15
14
  function ____exports.getMaxPillEffects(self)
16
15
  return itemConfig:GetPillEffects().Size - 1
17
16
  end
18
17
  function ____exports.getPillEffectClass(self, pillEffect)
19
- local pillEffectClass = PILL_EFFECT_CLASS_MAP:get(pillEffect)
18
+ local pillEffectClass = PILL_EFFECT_CLASS_MAP[pillEffect]
20
19
  return pillEffectClass == nil and DEFAULT_PILL_EFFECT_CLASS or pillEffectClass
21
20
  end
22
21
  function ____exports.getPillEffectName(self, pillEffect)
23
- local defaultName = "Unknown"
24
- if type(pillEffect) ~= "number" then
25
- return defaultName
26
- end
27
- local pillEffectName = PILL_EFFECT_NAME_MAP:get(pillEffect)
28
- if pillEffectName ~= nil then
22
+ local pillEffectName = PILL_EFFECT_NAME_MAP[pillEffect]
23
+ if pillEffectName ~= nil and pillEffectName ~= DEFAULT_PILL_EFFECT_NAME then
29
24
  return pillEffectName
30
25
  end
31
26
  local itemConfigPillEffect = itemConfig:GetPillEffect(pillEffect)
32
- if itemConfigPillEffect == nil then
33
- return defaultName
27
+ if itemConfigPillEffect ~= nil then
28
+ return itemConfigPillEffect.Name
34
29
  end
35
- return itemConfigPillEffect.Name
30
+ return DEFAULT_PILL_EFFECT_NAME
36
31
  end
37
32
  function ____exports.getPillEffectType(self, pillEffect)
38
- local pillEffectClass = PILL_EFFECT_TYPE_MAP:get(pillEffect)
33
+ local pillEffectClass = PILL_EFFECT_TYPE_MAP[pillEffect]
39
34
  return pillEffectClass == nil and DEFAULT_PILL_EFFECT_TYPE or pillEffectClass
40
35
  end
41
36
  return ____exports
@@ -72,6 +72,8 @@ export declare function getBlackHearts(player: EntityPlayer): int;
72
72
  * Mother's Kiss; use the `getPlayerMaxHeartContainers` helper function for that.
73
73
  */
74
74
  export declare function getCharacterMaxHeartContainers(character: PlayerType | int): int;
75
+ /** Helper function to get the name of a character. Returns "unknown" for modded characters. */
76
+ export declare function getCharacterName(character: PlayerType | int): string;
75
77
  /** Helper function to get an array containing the characters of all of the current players. */
76
78
  export declare function getCharacters(): PlayerType[];
77
79
  export declare function getClosestPlayer(position: Vector): EntityPlayer;