isaacscript-common 1.2.86 → 1.2.89

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.
@@ -45,7 +45,7 @@ function checkPickupsPurchased(self, pickups, players)
45
45
  nil,
46
46
  player,
47
47
  pickupDescription.variant,
48
- pickupDescription.subtype,
48
+ pickupDescription.subType,
49
49
  pickupDescription.price
50
50
  )
51
51
  end
@@ -70,7 +70,7 @@ function storePickupsInMap(self, pickups)
70
70
  function(____, pickup) return pickup.Price ~= 0 end
71
71
  )
72
72
  for ____, pickup in ipairs(pickupsWithPrice) do
73
- v.room.pickupMap:set(pickup.Index, {variant = pickup.Variant, subtype = pickup.SubType, price = pickup.Price})
73
+ v.room.pickupMap:set(pickup.Index, {variant = pickup.Variant, subType = pickup.SubType, price = pickup.Price})
74
74
  end
75
75
  end
76
76
  function storePlayersInMap(self, players)
@@ -4,8 +4,8 @@
4
4
  * beginning of every run.
5
5
  *
6
6
  * @param familiarVariant The familiar variant to blacklist.
7
- * @param familiarSubType The subtype to blacklist. Optional. The default is to blacklist all
8
- * subtypes of the given variant.
7
+ * @param familiarSubType The sub-type to blacklist. Optional. The default is to blacklist all
8
+ * sub-types of the given variant.
9
9
  */
10
10
  export declare function setFamiliarNoSirenSteal(familiarVariant: FamiliarVariant | int, familiarSubType?: int): void;
11
11
  /**
@@ -0,0 +1,3 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare function testInit(mod: Mod): void;
3
+ export declare function test(): void;
@@ -0,0 +1,24 @@
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 postPEffectUpdate
7
+ local ____errors = require("errors")
8
+ local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
+ function postPEffectUpdate(self, _player)
10
+ end
11
+ local FEATURE_NAME = "test"
12
+ local initialized = false
13
+ local v = {run = {playersIsPonyActive = __TS__New(Set)}}
14
+ function ____exports.testInit(self, mod)
15
+ initialized = true
16
+ mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
17
+ end
18
+ function ____exports.test(self)
19
+ if not initialized then
20
+ local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
21
+ error(msg)
22
+ end
23
+ end
24
+ return ____exports
@@ -43,13 +43,11 @@ function ____exports.logAllFlags(flags, flagEnum, description)
43
43
  end
44
44
  ____exports.log(("Logging all " .. description) .. "flags:")
45
45
  local hasNoFlags = true
46
- local i = 1
47
46
  for key, value in pairs(flagEnum) do
48
47
  if hasFlag(nil, flags, value) then
49
- ____exports.log((((((" " .. tostring(i)) .. ") Has flag: ") .. tostring(key)) .. " (") .. tostring(value)) .. ")")
48
+ ____exports.log((((" Has flag: " .. tostring(key)) .. " (") .. tostring(value)) .. ")")
50
49
  hasNoFlags = false
51
50
  end
52
- i = i + 1
53
51
  end
54
52
  if hasNoFlags then
55
53
  ____exports.log(" n/a (no flags)")
@@ -65,15 +63,13 @@ function ____exports.logAllGameStateFlags()
65
63
  local game = Game()
66
64
  ____exports.log("Logging all game state flags:")
67
65
  local hasNoFlags = true
68
- local i = 1
69
66
  for key, value in pairs(GameStateFlag) do
70
67
  local gameStateFlag = value
71
68
  local flagValue = game:GetStateFlag(gameStateFlag)
72
69
  if flagValue then
73
- ____exports.log((((((" " .. tostring(i)) .. ") Has flag: ") .. key) .. " (") .. tostring(value)) .. ")")
70
+ ____exports.log((((" Has flag: " .. key) .. " (") .. tostring(value)) .. ")")
74
71
  hasNoFlags = false
75
72
  end
76
- i = i + 1
77
73
  end
78
74
  if hasNoFlags then
79
75
  ____exports.log(" n/a (no flags)")
@@ -87,14 +83,12 @@ function ____exports.logAllSeedEffects()
87
83
  local seeds = game:GetSeeds()
88
84
  ____exports.log("Logging all seed effects:")
89
85
  local hasNoSeedEffects = true
90
- local i = 1
91
86
  for key, value in pairs(SeedEffect) do
92
87
  local seedEffect = value
93
88
  if seeds:HasSeedEffect(seedEffect) then
94
- ____exports.log((((((" " .. tostring(i)) .. ") ") .. key) .. " (") .. tostring(value)) .. ")")
89
+ ____exports.log((((" " .. key) .. " (") .. tostring(value)) .. ")")
95
90
  hasNoSeedEffects = false
96
91
  end
97
- i = i + 1
98
92
  end
99
93
  if hasNoSeedEffects then
100
94
  ____exports.log(" n/a (no seed effects)")
@@ -19,16 +19,16 @@ export declare function fireProjectiles(npc: EntityNPC, position: Vector, veloci
19
19
  * This function will not include bosses on an internal blacklist, such as Death's scythes or Big
20
20
  * Horn holes.
21
21
  */
22
- export declare function getAliveBosses(): EntityNPC[];
22
+ export declare function getAliveBosses(matchingEntityType?: EntityType | int, matchingVariant?: int, matchingSubType?: int, ignoreFriendly?: boolean): EntityNPC[];
23
23
  /**
24
24
  * Helper function to get all of the non-dead NPCs in the room.
25
25
  *
26
26
  * This function will not include NPCs on an internal blacklist, such as Death's scythes or Big Horn
27
27
  * holes.
28
28
  */
29
- export declare function getAliveNPCs(): EntityNPC[];
29
+ export declare function getAliveNPCs(matchingEntityType?: EntityType | int, matchingVariant?: int, matchingSubType?: int, ignoreFriendly?: boolean): EntityNPC[];
30
30
  /** Helper function to get all of the bosses in the room. */
31
- export declare function getBosses(): EntityNPC[];
31
+ export declare function getBosses(matchingEntityType?: EntityType | int, matchingVariant?: int, matchingSubType?: int, ignoreFriendly?: boolean): EntityNPC[];
32
32
  /** The same thing as the `getEntities()` function, but returns only NPCs. */
33
33
  export declare function getNPCs(matchingEntityType?: EntityType | int, matchingVariant?: int, matchingSubType?: int, ignoreFriendly?: boolean): EntityNPC[];
34
34
  /**
@@ -14,8 +14,17 @@ local getFilteredNewEntities = ____entity.getFilteredNewEntities
14
14
  local removeEntities = ____entity.removeEntities
15
15
  local ____entitySpecific = require("functions.entitySpecific")
16
16
  local getProjectiles = ____entitySpecific.getProjectiles
17
- function ____exports.getAliveNPCs(self)
18
- local npcs = ____exports.getNPCs(nil)
17
+ function ____exports.getAliveNPCs(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
18
+ if ignoreFriendly == nil then
19
+ ignoreFriendly = false
20
+ end
21
+ local npcs = ____exports.getNPCs(
22
+ nil,
23
+ matchingEntityType,
24
+ matchingVariant,
25
+ matchingSubType,
26
+ ignoreFriendly
27
+ )
19
28
  return __TS__ArrayFilter(
20
29
  npcs,
21
30
  function(____, npc) return not npc:IsDead() and not ____exports.isAliveExceptionNPC(nil, npc) end
@@ -99,15 +108,33 @@ function ____exports.fireProjectiles(self, npc, position, velocity, projectilesM
99
108
  local newProjectiles = getProjectiles(nil, projectileParams.Variant)
100
109
  return getFilteredNewEntities(nil, oldProjectiles, newProjectiles)
101
110
  end
102
- function ____exports.getAliveBosses(self)
103
- local aliveNPCs = ____exports.getAliveNPCs(nil)
111
+ function ____exports.getAliveBosses(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
112
+ if ignoreFriendly == nil then
113
+ ignoreFriendly = false
114
+ end
115
+ local aliveNPCs = ____exports.getAliveNPCs(
116
+ nil,
117
+ matchingEntityType,
118
+ matchingVariant,
119
+ matchingSubType,
120
+ ignoreFriendly
121
+ )
104
122
  return __TS__ArrayFilter(
105
123
  aliveNPCs,
106
124
  function(____, aliveNPC) return aliveNPC:IsBoss() end
107
125
  )
108
126
  end
109
- function ____exports.getBosses(self)
110
- local npcs = ____exports.getNPCs(nil)
127
+ function ____exports.getBosses(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
128
+ if ignoreFriendly == nil then
129
+ ignoreFriendly = false
130
+ end
131
+ local npcs = ____exports.getNPCs(
132
+ nil,
133
+ matchingEntityType,
134
+ matchingVariant,
135
+ matchingSubType,
136
+ ignoreFriendly
137
+ )
111
138
  return __TS__ArrayFilter(
112
139
  npcs,
113
140
  function(____, npc) return npc:IsBoss() end
@@ -1,18 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { HealthType } from "../types/HealthType";
3
- /**
4
- * PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
5
- * function. Mods can signify that data structures handle EntityPlayers by using this type:
6
- *
7
- * ```
8
- * const myPlayerMap = new Map<PlayerIndex, string>();
9
- * ```
10
- *
11
- * This type is branded for extra type safety.
12
- */
13
- export declare type PlayerIndex = int & {
14
- __playerIndexBrand: unknown;
15
- };
3
+ import { PlayerIndex } from "../types/PlayerIndex";
16
4
  export declare function addCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType | int): void;
17
5
  export declare function addTrinketCostume(player: EntityPlayer, trinketType: TrinketType | int): void;
18
6
  /** Iterates over all players and checks if any player is close enough to the specified position. */
@@ -23,15 +23,11 @@ export declare function getCurrentRoomDescriptorReadOnly(): RoomDescriptorReadOn
23
23
  */
24
24
  export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined;
25
25
  /**
26
- * Helper function to get the type of a room from the XML/STB data. The room data type will
27
- * correspond to different things depending on what XML/STB file it draws from. For example, in the
28
- * "00.special rooms.stb" file, a room type of 2 corresponds to a shop, a room type of 3 corresponds
29
- * to an I AM ERROR room, and so on.
26
+ * Helper function for getting the type of the room with the given grid index.
30
27
  *
31
- * @param roomGridIndex Optional. Equal to the current room index by default.
32
28
  * @returns The room data type. Returns -1 if the type was not found.
33
29
  */
34
- export declare function getRoomDataType(roomGridIndex?: int): int;
30
+ export declare function getRoomType(roomGridIndex: int): RoomType;
35
31
  /**
36
32
  * Helper function to get the descriptor for a room.
37
33
  *
@@ -97,13 +93,13 @@ export declare function getRoomSafeGridIndex(roomGridIndex?: int): int;
97
93
  */
98
94
  export declare function getRoomStageID(roomGridIndex?: int): StageID;
99
95
  /**
100
- * Helper function to get the subtype for a room from the XML/STB data. The room subtype will
96
+ * Helper function to get the sub-type for a room from the XML/STB data. The room sub-type will
101
97
  * correspond to different things depending on what XML/STB file it draws from. For example, in the
102
- * "00.special rooms.stb" file, an Angel Room with a subtype of 0 will correspond to a normal Angel
103
- * Room and a subtype of 1 will correspond to an Angel Room shop for The Stairway.
98
+ * "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will correspond to a normal Angel
99
+ * Room and a sub-type of 1 will correspond to an Angel Room shop for The Stairway.
104
100
  *
105
101
  * @param roomGridIndex Optional. Equal to the current room index by default.
106
- * @returns The room subtype. Returns -1 if the subtype was not found.
102
+ * @returns The room sub-type. Returns -1 if the sub-type was not found.
107
103
  */
108
104
  export declare function getRoomSubType(roomGridIndex?: int): int;
109
105
  /**
@@ -151,8 +147,8 @@ export declare function inBeastRoom(): boolean;
151
147
  export declare function inBossRoomOf(bossID: BossID): boolean;
152
148
  /**
153
149
  * Helper function for determining whether the current room is a crawlspace. Use this function over
154
- * comparing to `GridRooms.ROOM_DUNGEON_IDX` directly since there is a special case of the player
155
- * being in The Beast room.
150
+ * comparing to `RoomType.ROOM_DUNGEON` or `GridRooms.ROOM_DUNGEON_IDX` since there is a special
151
+ * case of the player being in a boss fight that take place in a dungeon.
156
152
  */
157
153
  export declare function inCrawlspace(): boolean;
158
154
  /**
@@ -92,7 +92,7 @@ end
92
92
  function ____exports.inDeathCertificateArea(self)
93
93
  local roomStageID = ____exports.getRoomStageID(nil)
94
94
  local roomSubType = ____exports.getRoomSubType(nil)
95
- return roomStageID == 35 and (roomSubType == 33 or roomSubType == 33)
95
+ return roomStageID == 35 and (roomSubType == 33 or roomSubType == 34)
96
96
  end
97
97
  function ____exports.changeRoom(self, roomGridIndex)
98
98
  local game = Game()
@@ -129,7 +129,7 @@ function ____exports.getCurrentDimension(self)
129
129
  end
130
130
  return error("Failed to get the current dimension using the starting room index of: " .. tostring(startingRoomGridIndex))
131
131
  end
132
- function ____exports.getRoomDataType(self, roomGridIndex)
132
+ function ____exports.getRoomType(self, roomGridIndex)
133
133
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
134
134
  return roomData == nil and -1 or roomData.Type
135
135
  end
@@ -195,9 +195,11 @@ function ____exports.inAngelShop(self)
195
195
  return roomType == RoomType.ROOM_ANGEL and roomSubType == 1
196
196
  end
197
197
  function ____exports.inBeastRoom(self)
198
- local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
198
+ local game = Game()
199
+ local room = game:GetRoom()
200
+ local roomType = room:GetType()
199
201
  local roomSubType = ____exports.getRoomSubType(nil)
200
- return roomSafeGridIndex == GridRooms.ROOM_DUNGEON_IDX and roomSubType == 4
202
+ return roomType == RoomType.ROOM_DUNGEON and roomSubType == 4
201
203
  end
202
204
  function ____exports.inBossRoomOf(self, bossID)
203
205
  local game = Game()
@@ -208,9 +210,11 @@ function ____exports.inBossRoomOf(self, bossID)
208
210
  return roomType == RoomType.ROOM_BOSS and roomStageID == 0 and roomSubType == bossID
209
211
  end
210
212
  function ____exports.inCrawlspace(self)
211
- local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
213
+ local game = Game()
214
+ local room = game:GetRoom()
215
+ local roomType = room:GetType()
212
216
  local roomSubType = ____exports.getRoomSubType(nil)
213
- return roomSafeGridIndex == GridRooms.ROOM_DUNGEON_IDX and roomSubType ~= 4
217
+ return roomType == RoomType.ROOM_DUNGEON and roomSubType ~= 4
214
218
  end
215
219
  function ____exports.inDevilsCrownTreasureRoom(self)
216
220
  local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
package/dist/index.d.ts CHANGED
@@ -92,6 +92,7 @@ export * from "./types/PickingUpItem";
92
92
  export * from "./types/PillEffectClass";
93
93
  export * from "./types/PillEffectType";
94
94
  export * from "./types/PlayerHealth";
95
+ export * from "./types/PlayerIndex";
95
96
  export * from "./types/PocketItemDescription";
96
97
  export * from "./types/PocketItemType";
97
98
  export * from "./types/TrinketSituation";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.86",
3
+ "version": "1.2.89",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.0",
29
- "isaac-typescript-definitions": "^1.0.354",
29
+ "isaac-typescript-definitions": "^1.0.355",
30
30
  "isaacscript-lint": "^1.0.81",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.12",