isaacscript-common 1.2.173 → 1.2.176

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 (79) hide show
  1. package/dist/callbacks/postNewRoomEarly.lua +2 -2
  2. package/dist/classes/null.d.ts +6 -7
  3. package/dist/classes/null.lua +5 -5
  4. package/dist/constants.d.ts +10 -10
  5. package/dist/constants.lua +3 -3
  6. package/dist/features/collectiblesSeen.d.ts +6 -0
  7. package/dist/features/collectiblesSeen.lua +43 -0
  8. package/dist/features/deployJSONRoom.lua +2 -1
  9. package/dist/features/extraConsoleCommands/commands.d.ts +11 -11
  10. package/dist/features/extraConsoleCommands/commands.lua +23 -22
  11. package/dist/features/extraConsoleCommands/init.lua +6 -6
  12. package/dist/features/playerInventory.d.ts +10 -2
  13. package/dist/features/playerInventory.lua +60 -21
  14. package/dist/features/saveDataManager/constants.d.ts +1 -1
  15. package/dist/features/saveDataManager/constants.lua +1 -1
  16. package/dist/features/saveDataManager/exports.d.ts +6 -6
  17. package/dist/features/saveDataManager/exports.lua +4 -4
  18. package/dist/features/saveDataManager/merge.lua +5 -3
  19. package/dist/featuresInitialized.d.ts +1 -1
  20. package/dist/featuresInitialized.lua +3 -3
  21. package/dist/functions/array.d.ts +39 -39
  22. package/dist/functions/array.lua +79 -79
  23. package/dist/functions/cards.d.ts +3 -3
  24. package/dist/functions/cards.lua +7 -7
  25. package/dist/functions/charge.d.ts +11 -11
  26. package/dist/functions/charge.lua +13 -13
  27. package/dist/functions/collectibles.d.ts +53 -15
  28. package/dist/functions/collectibles.lua +44 -21
  29. package/dist/functions/color.d.ts +2 -2
  30. package/dist/functions/color.lua +6 -6
  31. package/dist/functions/deepCopy.d.ts +0 -3
  32. package/dist/functions/deepCopy.lua +5 -22
  33. package/dist/functions/doors.d.ts +8 -8
  34. package/dist/functions/doors.lua +16 -16
  35. package/dist/functions/entity.d.ts +13 -14
  36. package/dist/functions/entity.lua +27 -34
  37. package/dist/functions/gridEntity.d.ts +8 -1
  38. package/dist/functions/gridEntity.lua +7 -11
  39. package/dist/functions/jsonHelpers.d.ts +7 -7
  40. package/dist/functions/jsonHelpers.lua +10 -11
  41. package/dist/functions/log.d.ts +21 -21
  42. package/dist/functions/log.lua +75 -74
  43. package/dist/functions/math.d.ts +1 -1
  44. package/dist/functions/math.lua +3 -3
  45. package/dist/functions/player.d.ts +8 -10
  46. package/dist/functions/player.lua +22 -29
  47. package/dist/functions/playerHealth.d.ts +1 -1
  48. package/dist/functions/playerHealth.lua +20 -20
  49. package/dist/functions/positionVelocity.d.ts +3 -0
  50. package/dist/functions/positionVelocity.lua +19 -5
  51. package/dist/functions/random.d.ts +7 -7
  52. package/dist/functions/revive.d.ts +5 -5
  53. package/dist/functions/revive.lua +8 -8
  54. package/dist/functions/roomData.d.ts +96 -0
  55. package/dist/functions/roomData.lua +57 -0
  56. package/dist/functions/rooms.d.ts +1 -96
  57. package/dist/functions/rooms.lua +30 -75
  58. package/dist/functions/set.d.ts +2 -2
  59. package/dist/functions/set.lua +7 -7
  60. package/dist/functions/trinketCacheFlag.d.ts +4 -4
  61. package/dist/functions/trinketCacheFlag.lua +3 -2
  62. package/dist/functions/trinketGive.d.ts +7 -7
  63. package/dist/functions/trinketGive.lua +27 -27
  64. package/dist/functions/trinkets.d.ts +2 -2
  65. package/dist/functions/trinkets.lua +6 -6
  66. package/dist/functions/ui.d.ts +13 -13
  67. package/dist/functions/ui.lua +28 -28
  68. package/dist/functions/utils.d.ts +6 -0
  69. package/dist/functions/utils.lua +7 -0
  70. package/dist/functions/vector.d.ts +2 -0
  71. package/dist/functions/vector.lua +13 -0
  72. package/dist/index.d.ts +3 -0
  73. package/dist/index.lua +13 -0
  74. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.d.ts +1 -1
  75. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.lua +1 -1
  76. package/dist/types/CollectibleIndex.d.ts +15 -0
  77. package/dist/types/CollectibleIndex.lua +3 -0
  78. package/dist/upgradeMod.lua +3 -0
  79. package/package.json +2 -2
@@ -29,7 +29,9 @@ end
29
29
  function checkRoomChanged(self)
30
30
  local room = game:GetRoom()
31
31
  local topLeftWallGridIndex = getTopLeftWallGridIndex(nil)
32
+ local rightOfTopWallGridIndex = topLeftWallGridIndex + 1
32
33
  local topLeftWall = room:GetGridEntity(topLeftWallGridIndex)
34
+ local topLeftWall2 = room:GetGridEntity(rightOfTopWallGridIndex)
33
35
  if topLeftWall == nil then
34
36
  topLeftWall = spawnGridEntity(nil, GridEntityType.GRID_WALL, topLeftWallGridIndex)
35
37
  if topLeftWall == nil then
@@ -38,8 +40,6 @@ function checkRoomChanged(self)
38
40
  end
39
41
  log("Spawned a new wall (1) for the PostNewRoomEarly callback.")
40
42
  end
41
- local rightOfTopWallGridIndex = topLeftWallGridIndex + 1
42
- local topLeftWall2 = room:GetGridEntity(rightOfTopWallGridIndex)
43
43
  if topLeftWall2 == nil then
44
44
  topLeftWall2 = spawnGridEntity(nil, GridEntityType.GRID_WALL, rightOfTopWallGridIndex)
45
45
  if topLeftWall2 == nil then
@@ -1,15 +1,14 @@
1
1
  /**
2
- * Null is a class that represents the JavaScript/TypeScript type of "null".
2
+ * NullT is a class that represents the JavaScript/TypeScript type of "null". T is short for "type".
3
3
  *
4
- * Do not instantiate this class directly and instead use the `Nul` singleton.
4
+ * Do not instantiate this class directly and instead use the `Null` singleton.
5
5
  */
6
- export declare class Null {
6
+ export declare class NullT {
7
7
  }
8
8
  /**
9
- * Nul is a singleton that represents an instantiated version of the `Null` class.
9
+ * Null is a singleton that represents an instantiated version of the `NullT` class.
10
10
  *
11
11
  * In TSTL, `null` transpiles to `nil`. This is problematic because if you use it as an object or
12
- * map value, the corresponding key will be deleted. You can work around this by using this `Nul`,
13
- * which is an instantiated version of the `Null` custom class.
12
+ * map value, the corresponding key will be deleted. You can work around this by using this `Null`.
14
13
  */
15
- export declare const Nul: Null;
14
+ export declare const Null: NullT;
@@ -3,10 +3,10 @@ local ____lualib = require("lualib_bundle")
3
3
  local __TS__Class = ____lualib.__TS__Class
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
- ____exports.Null = __TS__Class()
7
- local Null = ____exports.Null
8
- Null.name = "Null"
9
- function Null.prototype.____constructor(self)
6
+ ____exports.NullT = __TS__Class()
7
+ local NullT = ____exports.NullT
8
+ NullT.name = "NullT"
9
+ function NullT.prototype.____constructor(self)
10
10
  end
11
- ____exports.Nul = __TS__New(____exports.Null)
11
+ ____exports.Null = __TS__New(____exports.NullT)
12
12
  return ____exports
@@ -63,8 +63,8 @@ export declare const FINAL_STAGE: number;
63
63
  * second TMTRAINER item subtracts one from that, and so on.
64
64
  */
65
65
  export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: number;
66
- export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
67
66
  export declare const GAME_FRAMES_PER_SECOND = 30;
67
+ export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
68
68
  export declare const ISAAC_FRAMES_PER_SECOND = 60;
69
69
  /**
70
70
  * This is the set of characters that look like The Lost and play the "LostDeath" animation when
@@ -81,11 +81,6 @@ export declare const MAX_NUM_DOORS = 8;
81
81
  export declare const MAX_NUM_FAMILIARS = 64;
82
82
  /** The game can only handle up to four different players. */
83
83
  export declare const MAX_NUM_INPUTS = 4;
84
- /**
85
- * The maximum speed stat that a player can have. Any additional speed beyond this will not take
86
- * effect.
87
- */
88
- export declare const MAX_SPEED_STAT = 2;
89
84
  /** With Birthright, it is possible for Magdalene to have 18 heart containers. */
90
85
  export declare const MAX_PLAYER_HEART_CONTAINERS = 18;
91
86
  export declare const MAX_PLAYER_POCKET_ITEM_SLOTS = 4;
@@ -103,6 +98,11 @@ export declare const MAX_PLAYER_TRINKET_SLOTS = 2;
103
98
  * on. The maximum room index possible is 168. (It is not 169 because we start at 0 instead of 1.)
104
99
  */
105
100
  export declare const MAX_ROOM_INDEX = 168;
101
+ /**
102
+ * The maximum speed stat that a player can have. Any additional speed beyond this will not take
103
+ * effect.
104
+ */
105
+ export declare const MAX_SPEED_STAT = 2;
106
106
  export declare const MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B;
107
107
  export declare const MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING;
108
108
  export declare const NUM_DIMENSIONS = 3;
@@ -113,16 +113,16 @@ export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
113
113
  * In vanilla, this is part of the `PillColor` enum, but we implement it as a constant in
114
114
  * IsaacScript since it is not a real pill color.
115
115
  *
116
- * 1 << 11
116
+ * (1 << 11) - 1
117
117
  */
118
- export declare const PILL_GIANT_FLAG = 2048;
118
+ export declare const PILL_COLOR_MASK = 2047;
119
119
  /**
120
120
  * In vanilla, this is part of the `PillColor` enum, but we implement it as a constant in
121
121
  * IsaacScript since it is not a real pill color.
122
122
  *
123
- * (1 << 11) - 1
123
+ * 1 << 11
124
124
  */
125
- export declare const PILL_COLOR_MASK = 2047;
125
+ export declare const PILL_GIANT_FLAG = 2048;
126
126
  export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: ReadonlySet<CollectibleType>;
127
127
  export declare const STORY_BOSSES: ReadonlySet<EntityType>;
128
128
  /**
@@ -79,8 +79,8 @@ ____exports.FAMILIARS_THAT_SHOOT_PLAYER_TEARS = __TS__New(Set, {
79
79
  })
80
80
  ____exports.FINAL_STAGE = LevelStage.NUM_STAGES - 1
81
81
  ____exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = (1 << 32) - 1
82
- ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67
83
82
  ____exports.GAME_FRAMES_PER_SECOND = 30
83
+ ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67
84
84
  ____exports.ISAAC_FRAMES_PER_SECOND = 60
85
85
  ____exports.LOST_STYLE_PLAYER_TYPES = __TS__New(Set, {
86
86
  PlayerType.PLAYER_THELOST,
@@ -92,20 +92,20 @@ ____exports.LOST_STYLE_PLAYER_TYPES = __TS__New(Set, {
92
92
  ____exports.MAX_NUM_DOORS = 8
93
93
  ____exports.MAX_NUM_FAMILIARS = 64
94
94
  ____exports.MAX_NUM_INPUTS = 4
95
- ____exports.MAX_SPEED_STAT = 2
96
95
  ____exports.MAX_PLAYER_HEART_CONTAINERS = 18
97
96
  ____exports.MAX_PLAYER_POCKET_ITEM_SLOTS = 4
98
97
  ____exports.MAX_PLAYER_SPEED_IN_UNITS = 9.8
99
98
  ____exports.MAX_PLAYER_TRINKET_SLOTS = 2
100
99
  ____exports.MAX_ROOM_INDEX = 168
100
+ ____exports.MAX_SPEED_STAT = 2
101
101
  ____exports.MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B
102
102
  ____exports.MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING
103
103
  ____exports.NUM_DIMENSIONS = 3
104
104
  ____exports.SECOND_IN_MILLISECONDS = 1000
105
105
  ____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
106
106
  ____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
107
- ____exports.PILL_GIANT_FLAG = 2048
108
107
  ____exports.PILL_COLOR_MASK = 2047
108
+ ____exports.PILL_GIANT_FLAG = 2048
109
109
  ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
110
110
  CollectibleType.COLLECTIBLE_FORGET_ME_NOW,
111
111
  CollectibleType.COLLECTIBLE_EDENS_SOUL,
@@ -0,0 +1,6 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to determine if a collectible has been previously seen on the run before this
4
+ * room was entered.
5
+ */
6
+ export declare function isCollectiblePreviouslySeen(collectible: EntityPickup): boolean;
@@ -0,0 +1,43 @@
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 postPickupInitCollectible, postNewRoomEarly, v
7
+ local ____ModCallbacksCustom = require("enums.ModCallbacksCustom")
8
+ local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
9
+ local ____featuresInitialized = require("featuresInitialized")
10
+ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
11
+ local ____collectibles = require("functions.collectibles")
12
+ local getCollectibleIndex = ____collectibles.getCollectibleIndex
13
+ local ____set = require("functions.set")
14
+ local addSetsToSet = ____set.addSetsToSet
15
+ local ____exports = require("features.saveDataManager.exports")
16
+ local saveDataManager = ____exports.saveDataManager
17
+ function postPickupInitCollectible(self, collectible)
18
+ local collectibleIndex = getCollectibleIndex(nil, collectible)
19
+ v.run.collectiblesSeenInThisRoom:add(collectibleIndex)
20
+ end
21
+ function postNewRoomEarly(self)
22
+ addSetsToSet(nil, v.run.collectiblesSeenInPreviousRooms, v.run.collectiblesSeenInThisRoom)
23
+ v.run.collectiblesSeenInThisRoom:clear()
24
+ end
25
+ local FEATURE_NAME = "collectibles tracker"
26
+ v = {run = {
27
+ collectiblesSeenInPreviousRooms = __TS__New(Set),
28
+ collectiblesSeenInThisRoom = __TS__New(Set)
29
+ }}
30
+ function ____exports.collectiblesSeenInit(self, mod)
31
+ saveDataManager(nil, "collectiblesSave", v)
32
+ mod:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, postPickupInitCollectible, PickupVariant.PICKUP_COLLECTIBLE)
33
+ mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_NEW_ROOM_EARLY, postNewRoomEarly)
34
+ end
35
+ function ____exports.isCollectiblePreviouslySeen(self, collectible)
36
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
37
+ if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
38
+ error("You cannot request if the following pickup variant is previously seen: " .. tostring(collectible.Variant))
39
+ end
40
+ local collectibleIndex = getCollectibleIndex(nil, collectible)
41
+ return v.run.collectiblesSeenInPreviousRooms:has(collectibleIndex)
42
+ end
43
+ return ____exports
@@ -35,8 +35,9 @@ local ____pickups = require("functions.pickups")
35
35
  local removeAllPickups = ____pickups.removeAllPickups
36
36
  local ____random = require("functions.random")
37
37
  local nextSeed = ____random.nextSeed
38
+ local ____roomData = require("functions.roomData")
39
+ local getRoomListIndex = ____roomData.getRoomListIndex
38
40
  local ____rooms = require("functions.rooms")
39
- local getRoomListIndex = ____rooms.getRoomListIndex
40
41
  local gridToPos = ____rooms.gridToPos
41
42
  local setRoomCleared = ____rooms.setRoomCleared
42
43
  local setRoomUncleared = ____rooms.setRoomUncleared
@@ -27,6 +27,8 @@ export declare function blackMarket(): void;
27
27
  * charges. (You can use negative numbers to remove charges.)
28
28
  */
29
29
  export declare function bloodCharges(params: string): void;
30
+ /** Alias for the "blackmarket" command. */
31
+ export declare function bm(): void;
30
32
  /**
31
33
  * Gives a bomb. Provide a number to give a custom amount of bombs. (You can use negative numbers to
32
34
  * remove bombs.)
@@ -46,8 +48,6 @@ export declare function boneHearts(params: string): void;
46
48
  export declare function boss(): void;
47
49
  /** Warps to the Boss Rush for the floor. */
48
50
  export declare function bossRush(): void;
49
- /** Alias for the "blackmarket" command. */
50
- export declare function bm(): void;
51
51
  /**
52
52
  * Gives a broken heart. Provide a number to give a custom amount of hearts. (You can use negative
53
53
  * numbers to remove hearts.)
@@ -92,10 +92,10 @@ export declare function coin(params: string): void;
92
92
  export declare function coins(params: string): void;
93
93
  /** Creates a crawlspace next to the player. */
94
94
  export declare function crawlspace(): void;
95
- /** Uses the D6. */
96
- export declare function d6(): void;
97
95
  /** Uses the D20. */
98
96
  export declare function d20(): void;
97
+ /** Uses the D6. */
98
+ export declare function d6(): void;
99
99
  /** Toggles extremely high-damage tears. */
100
100
  export declare function damage(): void;
101
101
  /** Alias for the "devil" command. */
@@ -135,6 +135,10 @@ export declare function getPosition(): void;
135
135
  export declare function gigaBomb(params: string): void;
136
136
  /** Alias for the "goldenbomb" command. */
137
137
  export declare function goldBomb(): void;
138
+ /** Alias for the "goldenhearts" command. */
139
+ export declare function goldHearts(params: string): void;
140
+ /** Alias for the "goldenkey" command. */
141
+ export declare function goldKey(): void;
138
142
  /** Gives the player a golden bomb. */
139
143
  export declare function goldenBomb(): void;
140
144
  /**
@@ -144,10 +148,6 @@ export declare function goldenBomb(): void;
144
148
  export declare function goldenHearts(params: string): void;
145
149
  /** Gives the player a golden key. */
146
150
  export declare function goldenKey(): void;
147
- /** Alias for the "goldenhearts" command. */
148
- export declare function goldHearts(params: string): void;
149
- /** Alias for the "goldenkey" command. */
150
- export declare function goldKey(): void;
151
151
  /** Alias for the "debug 2" command. */
152
152
  export declare function grid(): void;
153
153
  /** Alias for the "debug 11" command. */
@@ -162,7 +162,7 @@ export declare function hearts(params: string): void;
162
162
  /** Alias for the "debug 6" command. */
163
163
  export declare function hitboxes(): void;
164
164
  /** Warps to the I AM ERROR room for the floor. */
165
- export declare function IAMERROR(): void;
165
+ export declare function iAmError(): void;
166
166
  /**
167
167
  * Gives a key. Provide a number to give a custom amount of key. (You can use negative numbers to
168
168
  * remove keys.)
@@ -263,10 +263,10 @@ export declare function s(params: string): void;
263
263
  export declare function sacrifice(): void;
264
264
  /** Warps to the first Secret Room on the floor. */
265
265
  export declare function secret(): void;
266
- /** Logs all of the current run's seed effects to the "log.txt" file. */
267
- export declare function seedsCommand(): void;
268
266
  /** Changes to a seeded run, using the seed of the current run. */
269
267
  export declare function seedStick(): void;
268
+ /** Logs all of the current run's seed effects to the "log.txt" file. */
269
+ export declare function seedsCommand(): void;
270
270
  /**
271
271
  * Sets a charge to the player's specified active item. You must provide the active slot number and
272
272
  * the number of charges to set.
@@ -18,10 +18,10 @@ local getCardName = ____cards.getCardName
18
18
  local ____gridEntity = require("functions.gridEntity")
19
19
  local spawnGridEntityWithVariant = ____gridEntity.spawnGridEntityWithVariant
20
20
  local ____log = require("functions.log")
21
- local logAllSeedEffects = ____log.logAllSeedEffects
22
21
  local logEntities = ____log.logEntities
23
22
  local logGridEntities = ____log.logGridEntities
24
23
  local logRoom = ____log.logRoom
24
+ local logSeedEffects = ____log.logSeedEffects
25
25
  local logSounds = ____log.logSounds
26
26
  local logTemporaryEffects = ____log.logTemporaryEffects
27
27
  local ____map = require("functions.map")
@@ -36,9 +36,10 @@ local getPlayers = ____player.getPlayers
36
36
  local useActiveItemTemp = ____player.useActiveItemTemp
37
37
  local ____playerHealth = require("functions.playerHealth")
38
38
  local addPlayerHealthType = ____playerHealth.addPlayerHealthType
39
+ local ____roomData = require("functions.roomData")
40
+ local getRoomData = ____roomData.getRoomData
39
41
  local ____rooms = require("functions.rooms")
40
42
  local changeRoom = ____rooms.changeRoom
41
- local getRoomData = ____rooms.getRoomData
42
43
  local getRoomGridIndexesForType = ____rooms.getRoomGridIndexesForType
43
44
  local gridToPos = ____rooms.gridToPos
44
45
  local ____run = require("functions.run")
@@ -77,10 +78,17 @@ function ____exports.goldenBomb(self)
77
78
  local player = Isaac.GetPlayer()
78
79
  player:AddGoldenBomb()
79
80
  end
81
+ function ____exports.goldenHearts(self, params)
82
+ addHeart(nil, params, HealthType.GOLDEN)
83
+ end
84
+ function ____exports.goldenKey(self)
85
+ local player = Isaac.GetPlayer()
86
+ player:AddGoldenKey()
87
+ end
80
88
  function ____exports.hearts(self, params)
81
89
  addHeart(nil, params, HealthType.RED)
82
90
  end
83
- function ____exports.IAMERROR(self)
91
+ function ____exports.iAmError(self)
84
92
  changeRoom(nil, GridRooms.ROOM_ERROR_IDX)
85
93
  end
86
94
  function ____exports.soulHearts(self, params)
@@ -279,6 +287,9 @@ function ____exports.bloodCharges(self, params)
279
287
  local player = Isaac.GetPlayer()
280
288
  player:AddBloodCharge(charges)
281
289
  end
290
+ function ____exports.bm(self)
291
+ ____exports.blackMarket(nil)
292
+ end
282
293
  function ____exports.bomb(self, params)
283
294
  local numBombs = 1
284
295
  if params ~= "" then
@@ -314,9 +325,6 @@ end
314
325
  function ____exports.bossRush(self)
315
326
  changeRoom(nil, GridRooms.ROOM_BOSSRUSH_IDX)
316
327
  end
317
- function ____exports.bm(self)
318
- ____exports.blackMarket(nil)
319
- end
320
328
  function ____exports.brokenHearts(self, params)
321
329
  addHeart(nil, params, HealthType.BROKEN)
322
330
  end
@@ -448,14 +456,14 @@ end
448
456
  function ____exports.crawlspace(self)
449
457
  spawnTrapdoorOrCrawlspace(nil, false)
450
458
  end
451
- function ____exports.d6(self)
452
- local player = Isaac.GetPlayer()
453
- useActiveItemTemp(nil, player, CollectibleType.COLLECTIBLE_D6)
454
- end
455
459
  function ____exports.d20(self)
456
460
  local player = Isaac.GetPlayer()
457
461
  useActiveItemTemp(nil, player, CollectibleType.COLLECTIBLE_D20)
458
462
  end
463
+ function ____exports.d6(self)
464
+ local player = Isaac.GetPlayer()
465
+ useActiveItemTemp(nil, player, CollectibleType.COLLECTIBLE_D6)
466
+ end
459
467
  function ____exports.damage(self)
460
468
  v.run.maxDamage = not v.run.maxDamage
461
469
  printEnabled(nil, v.run.maxDamage, "debug damage")
@@ -485,7 +493,7 @@ function ____exports.eh(self, params)
485
493
  ____exports.eternalHearts(nil, params)
486
494
  end
487
495
  function ____exports.error(self)
488
- ____exports.IAMERROR(nil)
496
+ ____exports.iAmError(nil)
489
497
  end
490
498
  function ____exports.fool(self)
491
499
  ____exports.startingRoom(nil)
@@ -515,13 +523,6 @@ end
515
523
  function ____exports.goldBomb(self)
516
524
  ____exports.goldenBomb(nil)
517
525
  end
518
- function ____exports.goldenHearts(self, params)
519
- addHeart(nil, params, HealthType.GOLDEN)
520
- end
521
- function ____exports.goldenKey(self)
522
- local player = Isaac.GetPlayer()
523
- player:AddGoldenKey()
524
- end
525
526
  function ____exports.goldHearts(self, params)
526
527
  ____exports.goldenHearts(nil, params)
527
528
  end
@@ -755,15 +756,15 @@ end
755
756
  function ____exports.secret(self)
756
757
  warpToRoomType(nil, RoomType.ROOM_SECRET)
757
758
  end
758
- function ____exports.seedsCommand(self)
759
- logAllSeedEffects()
760
- printConsole(nil, "Logged the seed effects to the \"log.txt\" file.")
761
- end
762
759
  function ____exports.seedStick(self)
763
760
  local seeds = game:GetSeeds()
764
761
  local startSeedString = seeds:GetStartSeedString()
765
762
  Isaac.ExecuteCommand("seed " .. startSeedString)
766
763
  end
764
+ function ____exports.seedsCommand(self)
765
+ logSeedEffects()
766
+ printConsole(nil, "Logged the seed effects to the \"log.txt\" file.")
767
+ end
767
768
  function ____exports.setCharges(self, params)
768
769
  if params == "" then
769
770
  printConsole(nil, "You must specify a slot number and a charge amount. (Use 0 for the primary slot, 1 for the Schoolbag slot, 2 for the pocket item slot, and 3 for the Dice Bag slot.)")
@@ -101,12 +101,12 @@ commandFunctionsMap:set("bh", commands.bh)
101
101
  commandFunctionsMap:set("blackhearts", commands.blackHearts)
102
102
  commandFunctionsMap:set("blackmarket", commands.blackMarket)
103
103
  commandFunctionsMap:set("bloodcharges", commands.bloodCharges)
104
+ commandFunctionsMap:set("bm", commands.bm)
104
105
  commandFunctionsMap:set("bomb", commands.bomb)
105
106
  commandFunctionsMap:set("bombs", commands.bombs)
106
107
  commandFunctionsMap:set("bonehearts", commands.boneHearts)
107
108
  commandFunctionsMap:set("boss", commands.boss)
108
109
  commandFunctionsMap:set("bossrush", commands.bossRush)
109
- commandFunctionsMap:set("bm", commands.bm)
110
110
  commandFunctionsMap:set("brokenhearts", commands.brokenHearts)
111
111
  commandFunctionsMap:set("card", commands.card)
112
112
  commandFunctionsMap:set("cards", commands.cards)
@@ -118,8 +118,8 @@ commandFunctionsMap:set("cleanbedroom", commands.cleanBedroom)
118
118
  commandFunctionsMap:set("coin", commands.coin)
119
119
  commandFunctionsMap:set("coins", commands.coins)
120
120
  commandFunctionsMap:set("crawlspace", commands.crawlspace)
121
- commandFunctionsMap:set("d6", commands.d6)
122
121
  commandFunctionsMap:set("d20", commands.d20)
122
+ commandFunctionsMap:set("d6", commands.d6)
123
123
  commandFunctionsMap:set("damage", commands.damage)
124
124
  commandFunctionsMap:set("dd", commands.dd)
125
125
  commandFunctionsMap:set("devil", commands.devil)
@@ -135,17 +135,17 @@ commandFunctionsMap:set("fool", commands.fool)
135
135
  commandFunctionsMap:set("getposition", commands.getPosition)
136
136
  commandFunctionsMap:set("gigabomb", commands.gigaBomb)
137
137
  commandFunctionsMap:set("goldbomb", commands.goldBomb)
138
+ commandFunctionsMap:set("goldhearts", commands.goldHearts)
139
+ commandFunctionsMap:set("goldkey", commands.goldKey)
138
140
  commandFunctionsMap:set("goldenbomb", commands.goldenBomb)
139
141
  commandFunctionsMap:set("goldenhearts", commands.goldenHearts)
140
142
  commandFunctionsMap:set("goldenkey", commands.goldenKey)
141
- commandFunctionsMap:set("goldhearts", commands.goldHearts)
142
- commandFunctionsMap:set("goldkey", commands.goldKey)
143
143
  commandFunctionsMap:set("grid", commands.grid)
144
144
  commandFunctionsMap:set("grid2", commands.grid2)
145
145
  commandFunctionsMap:set("h", commands.h)
146
146
  commandFunctionsMap:set("hearts", commands.hearts)
147
147
  commandFunctionsMap:set("hitboxes", commands.hitboxes)
148
- commandFunctionsMap:set("iamerror", commands.IAMERROR)
148
+ commandFunctionsMap:set("iamerror", commands.iAmError)
149
149
  commandFunctionsMap:set("key", commands.key)
150
150
  commandFunctionsMap:set("keys", commands.keys)
151
151
  commandFunctionsMap:set("library", commands.library)
@@ -173,8 +173,8 @@ commandFunctionsMap:set("rottenhearts", commands.rottenHearts)
173
173
  commandFunctionsMap:set("s", commands.s)
174
174
  commandFunctionsMap:set("sacrifice", commands.sacrifice)
175
175
  commandFunctionsMap:set("secret", commands.secret)
176
- commandFunctionsMap:set("seeds", commands.seedsCommand)
177
176
  commandFunctionsMap:set("seedstick", commands.seedStick)
177
+ commandFunctionsMap:set("seeds", commands.seedsCommand)
178
178
  commandFunctionsMap:set("setcharges", commands.setCharges)
179
179
  commandFunctionsMap:set("setposition", commands.setPosition)
180
180
  commandFunctionsMap:set("sh", commands.sh)
@@ -1,9 +1,17 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /**
3
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.
4
+ * order.
5
+ *
6
+ * Note that this does not include active collectibles that have since been dropped for other
7
+ * collectibles.
8
+ *
9
+ * In the case of inventory initialization or the case where the player rerolls their build in the
10
+ * middle of the run (e.g. with D4), the order of the inventory will not correspond to the order
11
+ * that the items were actually given to the player. In this case, the inventory will be in the
12
+ * order of the lowest `CollectibleType` to the highest.
5
13
  */
6
- export declare function getPlayerInventory(player: EntityPlayer): CollectibleType[];
14
+ export declare function getPlayerInventory(player: EntityPlayer, includeActiveCollectibles?: boolean): CollectibleType[];
7
15
  /**
8
16
  * Helper function to add a collectible to a player. Use this instead of the
9
17
  * `EntityPlayer.AddCollectible` method if you want the collectible that is added to be
@@ -1,11 +1,12 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
- local __TS__New = ____lualib.__TS__New
4
3
  local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
6
  local __TS__Iterator = ____lualib.__TS__Iterator
7
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
7
8
  local ____exports = {}
8
- local newPlayerInventory, useItemD4, postPlayerInit, postItemPickup, v
9
+ local newPlayerInventory, useItemD4, postGameStarted, postItemPickup, addCollectibleToInventory, COLLECTIBLE_ITEM_TYPES, v
9
10
  local ____DefaultMap = require("classes.DefaultMap")
10
11
  local DefaultMap = ____DefaultMap.DefaultMap
11
12
  local ____ModCallbacksCustom = require("enums.ModCallbacksCustom")
@@ -13,10 +14,14 @@ local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
13
14
  local ____featuresInitialized = require("featuresInitialized")
14
15
  local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
15
16
  local ____array = require("functions.array")
17
+ local arrayRemoveInPlace = ____array.arrayRemoveInPlace
16
18
  local copyArray = ____array.copyArray
19
+ local ____collectibles = require("functions.collectibles")
20
+ local isActiveCollectible = ____collectibles.isActiveCollectible
17
21
  local ____collectibleSet = require("functions.collectibleSet")
18
22
  local getCollectibleSet = ____collectibleSet.getCollectibleSet
19
23
  local ____player = require("functions.player")
24
+ local getAllPlayers = ____player.getAllPlayers
20
25
  local getPlayerIndex = ____player.getPlayerIndex
21
26
  local ____utils = require("functions.utils")
22
27
  local ____repeat = ____utils["repeat"]
@@ -42,36 +47,72 @@ function useItemD4(self, _collectibleType, _rng, player)
42
47
  local inventory = newPlayerInventory(nil, player)
43
48
  v.run.playersInventory:set(playerIndex, inventory)
44
49
  end
45
- function postPlayerInit(self, player)
46
- local playerIndex = getPlayerIndex(nil, player)
47
- if not v.run.playersInventory:has(playerIndex) then
48
- local inventory = newPlayerInventory(nil, player)
49
- v.run.playersInventory:set(playerIndex, inventory)
50
+ function postGameStarted(self)
51
+ for ____, player in ipairs(getAllPlayers(nil)) do
52
+ local playerIndex = getPlayerIndex(nil, player)
53
+ if not v.run.playersInventory:has(playerIndex) then
54
+ local inventory = newPlayerInventory(nil, player)
55
+ v.run.playersInventory:set(playerIndex, inventory)
56
+ end
50
57
  end
51
58
  end
52
59
  function postItemPickup(self, player, pickingUpItem)
53
- if pickingUpItem.itemType == ItemType.ITEM_PASSIVE or pickingUpItem.itemType == ItemType.ITEM_FAMILIAR then
54
- local playerIndex = getPlayerIndex(nil, player)
55
- local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
56
- __TS__ArrayPush(inventory, pickingUpItem.subType)
60
+ if not COLLECTIBLE_ITEM_TYPES:has(pickingUpItem.itemType) then
61
+ return
62
+ end
63
+ addCollectibleToInventory(nil, player, pickingUpItem.subType)
64
+ end
65
+ function addCollectibleToInventory(self, player, collectibleType)
66
+ local playerIndex = getPlayerIndex(nil, player)
67
+ local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
68
+ __TS__ArrayPush(inventory, collectibleType)
69
+ if not isActiveCollectible(nil, collectibleType) then
70
+ return
71
+ end
72
+ local activeCollectibleTypes = v.run.playersActiveCollectibleTypes:getAndSetDefault(playerIndex)
73
+ __TS__ArrayPush(activeCollectibleTypes, collectibleType)
74
+ local droppedActiveCollectibleTypes = __TS__ArrayFilter(
75
+ activeCollectibleTypes,
76
+ function(____, activeCollectibleType) return not player:HasCollectible(activeCollectibleType) end
77
+ )
78
+ for ____, activeCollectibleType in ipairs(droppedActiveCollectibleTypes) do
79
+ arrayRemoveInPlace(nil, inventory, activeCollectibleType)
80
+ arrayRemoveInPlace(nil, activeCollectibleTypes, activeCollectibleType)
57
81
  end
58
82
  end
59
83
  local FEATURE_NAME = "player inventory tracker"
60
- v = {run = {playersInventory = __TS__New(
61
- DefaultMap,
62
- function(____, _key, player) return newPlayerInventory(nil, player) end
63
- )}}
84
+ COLLECTIBLE_ITEM_TYPES = __TS__New(Set, {ItemType.ITEM_PASSIVE, ItemType.ITEM_ACTIVE, ItemType.ITEM_FAMILIAR})
85
+ v = {run = {
86
+ playersInventory = __TS__New(
87
+ DefaultMap,
88
+ function(____, _key, player) return newPlayerInventory(nil, player) end
89
+ ),
90
+ playersActiveCollectibleTypes = __TS__New(
91
+ DefaultMap,
92
+ function() return {} end
93
+ )
94
+ }}
64
95
  function ____exports.playerInventoryInit(self, mod)
65
96
  saveDataManager(nil, "playerInventory", v)
66
97
  mod:AddCallback(ModCallbacks.MC_USE_ITEM, useItemD4, CollectibleType.COLLECTIBLE_D4)
67
- mod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, postPlayerInit)
98
+ mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, postGameStarted)
68
99
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_ITEM_PICKUP, postItemPickup)
69
100
  end
70
- function ____exports.getPlayerInventory(self, player)
101
+ function ____exports.getPlayerInventory(self, player, includeActiveCollectibles)
102
+ if includeActiveCollectibles == nil then
103
+ includeActiveCollectibles = true
104
+ end
71
105
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
72
106
  local playerIndex = getPlayerIndex(nil, player)
73
107
  local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
74
- return copyArray(nil, inventory)
108
+ local copiedInventory = copyArray(nil, inventory)
109
+ if includeActiveCollectibles then
110
+ return copiedInventory
111
+ end
112
+ return __TS__ArrayFilter(
113
+ copiedInventory,
114
+ function(____, collectibleType) return not isActiveCollectible(nil, collectibleType) end
115
+ )
75
116
  end
76
117
  function ____exports.addCollectible(self, player, collectibleType, charge, firstTimePickingUp, activeSlot, varData)
77
118
  player:AddCollectible(
@@ -81,8 +122,6 @@ function ____exports.addCollectible(self, player, collectibleType, charge, first
81
122
  activeSlot,
82
123
  varData
83
124
  )
84
- local playerIndex = getPlayerIndex(nil, player)
85
- local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
86
- __TS__ArrayPush(inventory, collectibleType)
125
+ addCollectibleToInventory(nil, player, collectibleType)
87
126
  end
88
127
  return ____exports
@@ -1,3 +1,3 @@
1
- export declare const SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager";
2
1
  /** Set this to true to enable more verbosity in the save data manger. */
3
2
  export declare const SAVE_DATA_MANAGER_DEBUG = false;
3
+ export declare const SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager";
@@ -1,5 +1,5 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- ____exports.SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager"
4
3
  ____exports.SAVE_DATA_MANAGER_DEBUG = false
4
+ ____exports.SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager"
5
5
  return ____exports
@@ -76,12 +76,6 @@ import { SaveData } from "../../types/private/SaveData";
76
76
  * variables on run/level/room, but not clutter the the "save#.dat" file with unnecessary keys.
77
77
  */
78
78
  export declare function saveDataManager(key: string, v: SaveData, conditionalFunc?: () => boolean): void;
79
- /**
80
- * The save data manager will automatically save variables to disk at the appropriate times (i.e.
81
- * when the run is exited). Use this function to explicitly force the save data manager to write all
82
- * of its variables to disk immediately.
83
- */
84
- export declare function saveDataManagerSave(): void;
85
79
  /**
86
80
  * The save data manager will automatically load variables from disk at the appropriate times (i.e.
87
81
  * when a new run is started). Use this function to explicitly force the save data manager to load
@@ -90,6 +84,12 @@ export declare function saveDataManagerSave(): void;
90
84
  * Note that doing this will overwrite current data, which can potentially result in lost state.
91
85
  */
92
86
  export declare function saveDataManagerLoad(): void;
87
+ /**
88
+ * The save data manager will automatically save variables to disk at the appropriate times (i.e.
89
+ * when the run is exited). Use this function to explicitly force the save data manager to write all
90
+ * of its variables to disk immediately.
91
+ */
92
+ export declare function saveDataManagerSave(): void;
93
93
  /**
94
94
  * Sets the global variable of "g" equal to all of the save data variables for this mod.
95
95
  * Sets the global variable of "gd" equal to all of the save data default variables for this mod.