isaacscript-common 1.2.277 → 1.2.280
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.
|
@@ -5,9 +5,9 @@ import { AnyEntity } from "../types/AnyEntity";
|
|
|
5
5
|
* `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
|
|
6
6
|
* enemies.
|
|
7
7
|
*
|
|
8
|
-
* @param entityType Default is -1.
|
|
9
|
-
* @param variant Default is -1.
|
|
10
|
-
* @param subType Default is -1.
|
|
8
|
+
* @param entityType Default is -1. -1 matches every entity type.
|
|
9
|
+
* @param variant Default is -1. -1 matches every variant.
|
|
10
|
+
* @param subType Default is -1. -1 matches every sub-type.
|
|
11
11
|
* @param ignoreFriendly Default is false.
|
|
12
12
|
*/
|
|
13
13
|
export declare function countEntities(entityType?: EntityType | int, variant?: number, subType?: number, ignoreFriendly?: boolean): int;
|
|
@@ -41,8 +41,10 @@ export declare function getClosestEntityTo<T extends AnyEntity>(referenceEntity:
|
|
|
41
41
|
*
|
|
42
42
|
* @param entityType Optional. If specified, will only return NPCs that match this entity
|
|
43
43
|
* type.
|
|
44
|
-
* @param variant Optional. If specified, will only return NPCs that match this variant.
|
|
45
|
-
*
|
|
44
|
+
* @param variant Optional. If specified, will only return NPCs that match this variant. Default is
|
|
45
|
+
* -1. -1 matches every variant.
|
|
46
|
+
* @param subType Optional. If specified, will only return NPCs that match this sub-type. Default is
|
|
47
|
+
* -1. -1 matches every sub-type.
|
|
46
48
|
* @param ignoreFriendly Optional. If set to true, it will exclude friendly NPCs from being
|
|
47
49
|
* returned. Default is false. Will only be taken into account if `matchingEntityType` is specified.
|
|
48
50
|
*/
|
|
@@ -89,10 +91,8 @@ export declare function parseEntityTypeVariantString(entityTypeVariantString: st
|
|
|
89
91
|
* Helper function to remove all of the matching entities in the room.
|
|
90
92
|
*
|
|
91
93
|
* @param entityType The entity type to match.
|
|
92
|
-
* @param entityVariant Optional. The variant to match. Default is -1
|
|
93
|
-
*
|
|
94
|
-
* @param entitySubType Optional. The sub-type to match. Default is -1 (which will match every
|
|
95
|
-
* sub-type).
|
|
94
|
+
* @param entityVariant Optional. The variant to match. Default is -1. -1 matches every variant.
|
|
95
|
+
* @param entitySubType Optional. The sub-type to match. Default is -1. -1 matches every sub-type.
|
|
96
96
|
* @param cap Optional. If specified, will only remove the given amount of collectibles.
|
|
97
97
|
* @returns True if one or more entities were removed, false otherwise.
|
|
98
98
|
*/
|
package/dist/functions/log.lua
CHANGED
|
@@ -82,14 +82,14 @@ function ____exports.logFlags(flags, flagEnum, description)
|
|
|
82
82
|
for key, value in pairs(flagEnum) do
|
|
83
83
|
do
|
|
84
84
|
if type(value) ~= "number" then
|
|
85
|
-
goto
|
|
85
|
+
goto __continue43
|
|
86
86
|
end
|
|
87
87
|
if hasFlag(nil, flags, value) then
|
|
88
88
|
____exports.log((((" Has flag: " .. tostring(key)) .. " (") .. tostring(value)) .. ")")
|
|
89
89
|
hasNoFlags = false
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
|
-
::
|
|
92
|
+
::__continue43::
|
|
93
93
|
end
|
|
94
94
|
if hasNoFlags then
|
|
95
95
|
____exports.log(" n/a (no flags)")
|
|
@@ -143,15 +143,13 @@ function ____exports.logEffects(player)
|
|
|
143
143
|
)
|
|
144
144
|
end
|
|
145
145
|
function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
146
|
-
local
|
|
146
|
+
local msg = "Entities in the room"
|
|
147
147
|
if entityTypeFilter ~= nil then
|
|
148
|
-
|
|
148
|
+
msg = msg .. (" (filtered to entity type " .. tostring(entityTypeFilter)) .. ")"
|
|
149
|
+
elseif not includeBackgroundEffects then
|
|
150
|
+
msg = msg .. " (not including background effects)"
|
|
149
151
|
end
|
|
150
|
-
|
|
151
|
-
headerMsg = headerMsg .. " (not excluding background effects)"
|
|
152
|
-
end
|
|
153
|
-
headerMsg = headerMsg .. ":"
|
|
154
|
-
____exports.log(headerMsg)
|
|
152
|
+
msg = msg .. ":\n"
|
|
155
153
|
local entities = getEntities(nil)
|
|
156
154
|
local numMatchedEntities = 0
|
|
157
155
|
__TS__ArrayForEach(
|
|
@@ -164,62 +162,70 @@ function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
|
164
162
|
return
|
|
165
163
|
end
|
|
166
164
|
local entityID = getEntityID(nil, entity)
|
|
167
|
-
|
|
165
|
+
msg = msg .. (tostring(i + 1) .. ") ") .. entityID
|
|
168
166
|
local bomb = entity:ToBomb()
|
|
169
167
|
if bomb ~= nil then
|
|
170
|
-
|
|
168
|
+
msg = msg .. " (bomb)"
|
|
171
169
|
end
|
|
172
170
|
local effect = entity:ToEffect()
|
|
173
171
|
if effect ~= nil then
|
|
174
|
-
|
|
172
|
+
msg = msg .. (" (effect) (State: " .. tostring(effect.State)) .. ")"
|
|
175
173
|
end
|
|
176
174
|
local familiar = entity:ToFamiliar()
|
|
177
175
|
if familiar ~= nil then
|
|
178
|
-
|
|
176
|
+
msg = msg .. (" (familiar) (State: " .. tostring(familiar.State)) .. ")"
|
|
179
177
|
end
|
|
180
178
|
local knife = entity:ToKnife()
|
|
181
179
|
if knife ~= nil then
|
|
182
|
-
|
|
180
|
+
msg = msg .. " (knife)"
|
|
183
181
|
end
|
|
184
182
|
local laser = entity:ToLaser()
|
|
185
183
|
if laser ~= nil then
|
|
186
|
-
|
|
184
|
+
msg = msg .. " (laser)"
|
|
187
185
|
end
|
|
188
186
|
local npc = entity:ToNPC()
|
|
189
187
|
if npc ~= nil then
|
|
190
|
-
|
|
188
|
+
msg = msg .. (" (NPC) (State: " .. tostring(npc.State)) .. ")"
|
|
191
189
|
end
|
|
192
190
|
local pickup = entity:ToPickup()
|
|
193
191
|
if pickup ~= nil then
|
|
194
|
-
|
|
192
|
+
msg = msg .. (" (pickup) (State: " .. tostring(pickup.State)) .. ")"
|
|
195
193
|
end
|
|
196
194
|
local player = entity:ToPlayer()
|
|
197
195
|
if player ~= nil then
|
|
198
|
-
|
|
196
|
+
msg = msg .. " (player)"
|
|
199
197
|
end
|
|
200
198
|
local projectile = entity:ToProjectile()
|
|
201
199
|
if projectile ~= nil then
|
|
202
|
-
|
|
200
|
+
msg = msg .. " (projectile)"
|
|
203
201
|
end
|
|
204
202
|
local tear = entity:ToTear()
|
|
205
203
|
if tear ~= nil then
|
|
206
|
-
|
|
204
|
+
msg = msg .. " (tear)"
|
|
205
|
+
end
|
|
206
|
+
msg = msg .. "\n"
|
|
207
|
+
msg = msg .. (" - Index: " .. tostring(entity.Index)) .. "\n"
|
|
208
|
+
msg = msg .. (" - InitSeed: " .. tostring(entity.InitSeed)) .. "\n"
|
|
209
|
+
msg = msg .. (" - DropSeed: " .. tostring(entity.DropSeed)) .. "\n"
|
|
210
|
+
msg = msg .. (((" - Position: (" .. tostring(entity.Position.X)) .. ", ") .. tostring(entity.Position.Y)) .. ")\n"
|
|
211
|
+
msg = msg .. (((" - Velocity: (" .. tostring(entity.Velocity.X)) .. ", ") .. tostring(entity.Velocity.Y)) .. ")\n"
|
|
212
|
+
msg = msg .. (((" - HP: " .. tostring(entity.HitPoints)) .. " / ") .. tostring(entity.MaxHitPoints)) .. "\n"
|
|
213
|
+
msg = msg .. (" - Parent: " .. tostring(entity.Parent)) .. "\n"
|
|
214
|
+
msg = msg .. (" - Child: " .. tostring(entity.Child)) .. "\n"
|
|
215
|
+
msg = msg .. (" - SpawnerEntity: " .. tostring(entity.SpawnerEntity)) .. "\n"
|
|
216
|
+
msg = msg .. (((" - SpawnerType / SpawnerVariant: " .. tostring(entity.SpawnerType)) .. ".") .. tostring(entity.SpawnerVariant)) .. "\n"
|
|
217
|
+
if npc ~= nil then
|
|
218
|
+
msg = msg .. (" - CanShutDoors: " .. tostring(npc.CanShutDoors)) .. "\n"
|
|
207
219
|
end
|
|
208
|
-
debugString = debugString .. (" (Index: " .. tostring(entity.Index)) .. ")"
|
|
209
|
-
debugString = debugString .. (" (InitSeed: " .. tostring(entity.InitSeed)) .. ")"
|
|
210
|
-
debugString = debugString .. (" (DropSeed: " .. tostring(entity.DropSeed)) .. ")"
|
|
211
|
-
debugString = debugString .. (((" (Position: " .. tostring(entity.Position.X)) .. ", ") .. tostring(entity.Position.Y)) .. ")"
|
|
212
|
-
debugString = debugString .. (((" (Velocity: " .. tostring(entity.Velocity.X)) .. ", ") .. tostring(entity.Velocity.Y)) .. ")"
|
|
213
|
-
debugString = debugString .. (((" (HP: " .. tostring(entity.HitPoints)) .. " / ") .. tostring(entity.MaxHitPoints)) .. ")"
|
|
214
|
-
____exports.log(debugString)
|
|
215
220
|
numMatchedEntities = numMatchedEntities + 1
|
|
216
221
|
end
|
|
217
222
|
)
|
|
218
223
|
if numMatchedEntities == 0 then
|
|
219
|
-
|
|
224
|
+
msg = msg .. "(no entities matched)\n"
|
|
220
225
|
else
|
|
221
|
-
|
|
226
|
+
msg = msg .. ("(" .. tostring(numMatchedEntities)) .. " total entities)\n"
|
|
222
227
|
end
|
|
228
|
+
____exports.log(msg)
|
|
223
229
|
end
|
|
224
230
|
function ____exports.logEntityFlags(flags)
|
|
225
231
|
____exports.logFlags(flags, EntityFlag, "entity")
|
|
@@ -248,14 +254,13 @@ function ____exports.logGameStateFlags()
|
|
|
248
254
|
end
|
|
249
255
|
end
|
|
250
256
|
function ____exports.logGridEntities(includeWalls, gridEntityTypeFilter)
|
|
251
|
-
local
|
|
257
|
+
local msg = "Grid entities in the room"
|
|
252
258
|
if gridEntityTypeFilter ~= nil then
|
|
253
|
-
|
|
259
|
+
msg = msg .. (" (filtered to grid entity type " .. tostring(gridEntityTypeFilter)) .. ")"
|
|
260
|
+
elseif not includeWalls then
|
|
261
|
+
msg = msg .. " (not including walls)"
|
|
254
262
|
end
|
|
255
|
-
|
|
256
|
-
headerMsg = headerMsg .. " (not including walls)"
|
|
257
|
-
end
|
|
258
|
-
____exports.log(headerMsg)
|
|
263
|
+
msg = msg .. ":\n"
|
|
259
264
|
local gridEntities = getGridEntities(nil)
|
|
260
265
|
local numMatchedEntities = 0
|
|
261
266
|
__TS__ArrayForEach(
|
|
@@ -271,47 +276,54 @@ function ____exports.logGridEntities(includeWalls, gridEntityTypeFilter)
|
|
|
271
276
|
if not includeWalls and gridEntityType == GridEntityType.GRID_WALL and gridEntityTypeFilter ~= GridEntityType.GRID_WALL then
|
|
272
277
|
return
|
|
273
278
|
end
|
|
274
|
-
|
|
279
|
+
msg = msg .. (((((tostring(gridEntityIndex) .. ") ") .. tostring(gridEntityType)) .. ".") .. tostring(gridEntityVariant)) .. ".") .. tostring(gridEntity.State)
|
|
275
280
|
local door = gridEntity:ToDoor()
|
|
276
281
|
if door ~= nil then
|
|
277
|
-
|
|
282
|
+
msg = msg .. " (door)"
|
|
278
283
|
end
|
|
279
284
|
local pit = gridEntity:ToPit()
|
|
280
285
|
if pit ~= nil then
|
|
281
|
-
|
|
286
|
+
msg = msg .. " (pit)"
|
|
282
287
|
end
|
|
283
288
|
local poop = gridEntity:ToPoop()
|
|
284
289
|
if poop ~= nil then
|
|
285
|
-
|
|
290
|
+
msg = msg .. " (poop)"
|
|
286
291
|
end
|
|
287
292
|
local pressurePlate = gridEntity:ToPressurePlate()
|
|
288
293
|
if pressurePlate ~= nil then
|
|
289
|
-
|
|
294
|
+
msg = msg .. " (pressurePlate)"
|
|
290
295
|
end
|
|
291
296
|
local rock = gridEntity:ToRock()
|
|
292
297
|
if rock ~= nil then
|
|
293
|
-
|
|
298
|
+
msg = msg .. " (rock)"
|
|
294
299
|
end
|
|
295
300
|
local spikes = gridEntity:ToSpikes()
|
|
296
301
|
if spikes ~= nil then
|
|
297
|
-
|
|
302
|
+
msg = msg .. " (spikes)"
|
|
298
303
|
end
|
|
299
304
|
local tnt = gridEntity:ToTNT()
|
|
300
305
|
if tnt ~= nil then
|
|
301
|
-
|
|
306
|
+
msg = msg .. " (TNT)"
|
|
307
|
+
end
|
|
308
|
+
msg = msg .. (" - VarData: " .. tostring(gridEntity.VarData)) .. "\n"
|
|
309
|
+
msg = msg .. (((" - Position: (" .. tostring(gridEntity.Position.X)) .. ", ") .. tostring(gridEntity.Position.Y)) .. ")\n"
|
|
310
|
+
msg = msg .. (" - SpawnSeed: " .. tostring(gridEntityDesc.SpawnSeed)) .. "\n"
|
|
311
|
+
msg = msg .. (" - VariableSeed: " .. tostring(gridEntityDesc.VariableSeed)) .. ")\n"
|
|
312
|
+
if door ~= nil then
|
|
313
|
+
msg = msg .. (" - Slot: " .. tostring(door.Slot)) .. "\n"
|
|
314
|
+
msg = msg .. (" - Direction: " .. tostring(door.Direction)) .. "\n"
|
|
315
|
+
msg = msg .. (" - TargetRoomIndex: " .. tostring(door.TargetRoomIndex)) .. "\n"
|
|
316
|
+
msg = msg .. (" - TargetRoomType: " .. tostring(door.TargetRoomType)) .. "\n"
|
|
302
317
|
end
|
|
303
|
-
debugString = debugString .. (" (VarData: " .. tostring(gridEntity.VarData)) .. ")"
|
|
304
|
-
debugString = debugString .. (((" (Position: " .. tostring(gridEntity.Position.X)) .. ", ") .. tostring(gridEntity.Position.Y)) .. ")"
|
|
305
|
-
debugString = debugString .. (((" (SpawnSeed: " .. tostring(gridEntityDesc.SpawnSeed)) .. ", VariableSeed: ") .. tostring(gridEntityDesc.VariableSeed)) .. ")"
|
|
306
|
-
____exports.log(debugString)
|
|
307
318
|
numMatchedEntities = numMatchedEntities + 1
|
|
308
319
|
end
|
|
309
320
|
)
|
|
310
321
|
if numMatchedEntities == 0 then
|
|
311
|
-
|
|
322
|
+
msg = msg .. "(no grid entities matched)\n"
|
|
312
323
|
else
|
|
313
|
-
|
|
324
|
+
msg = msg .. ("(" .. tostring(numMatchedEntities)) .. " total grid entities)\n"
|
|
314
325
|
end
|
|
326
|
+
____exports.log(msg)
|
|
315
327
|
end
|
|
316
328
|
function ____exports.logKColor(kColor)
|
|
317
329
|
____exports.log((((((("Color: R" .. tostring(kColor.Red)) .. ", G") .. tostring(kColor.Green)) .. ", B") .. tostring(kColor.Blue)) .. ", A") .. tostring(kColor.Alpha))
|
|
@@ -32,13 +32,20 @@ export declare function getRoomGridIndexesForType(...roomTypes: RoomType[]): int
|
|
|
32
32
|
export declare function getRoomItemPoolType(): ItemPoolType;
|
|
33
33
|
/**
|
|
34
34
|
* Helper function to get the room descriptor for every room on the level. Uses the `Level.GetRooms`
|
|
35
|
-
* method to accomplish this.
|
|
35
|
+
* method to accomplish this. Rooms without data are assumed to be non-existent and are not added to
|
|
36
|
+
* the list.
|
|
36
37
|
*
|
|
37
38
|
* @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
38
39
|
* extra-dimensional rooms are automatically be generated and can be seen when you iterate over the
|
|
39
40
|
* `RoomList`. Default is false.
|
|
40
41
|
*/
|
|
41
42
|
export declare function getRooms(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
|
|
43
|
+
/**
|
|
44
|
+
* Helper function to get the room descriptor for every room on the level in a specific dimension.
|
|
45
|
+
* Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
|
|
46
|
+
* non-existent and are not added to the list.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getRoomsOfDimension(dimension: Dimension): RoomDescriptor[];
|
|
42
49
|
/**
|
|
43
50
|
* Helper function to determine if the current room shape is equal to `RoomShape.ROOMSHAPE_1x2` or
|
|
44
51
|
* `RoomShape.ROOMSHAPE_2x1`.
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -53,7 +53,7 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
|
53
53
|
local i = 0
|
|
54
54
|
while i < roomList.Size do
|
|
55
55
|
local roomDescriptor = roomList:Get(i)
|
|
56
|
-
if roomDescriptor ~= nil then
|
|
56
|
+
if roomDescriptor ~= nil and roomDescriptor.Data ~= nil then
|
|
57
57
|
rooms[#rooms + 1] = roomDescriptor
|
|
58
58
|
end
|
|
59
59
|
i = i + 1
|
|
@@ -64,7 +64,7 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
|
64
64
|
local i = 0
|
|
65
65
|
while i <= MAX_ROOM_INDEX do
|
|
66
66
|
local roomDescriptor = level:GetRoomByIdx(i)
|
|
67
|
-
if roomDescriptor ~= nil then
|
|
67
|
+
if roomDescriptor.Data ~= nil then
|
|
68
68
|
rooms[#rooms + 1] = roomDescriptor
|
|
69
69
|
end
|
|
70
70
|
i = i + 1
|
|
@@ -134,6 +134,21 @@ function ____exports.getRoomItemPoolType(self)
|
|
|
134
134
|
local roomSeed = room:GetSpawnSeed()
|
|
135
135
|
return itemPool:GetPoolForRoom(roomType, roomSeed)
|
|
136
136
|
end
|
|
137
|
+
function ____exports.getRoomsOfDimension(self, dimension)
|
|
138
|
+
local level = game:GetLevel()
|
|
139
|
+
local rooms = {}
|
|
140
|
+
do
|
|
141
|
+
local i = 0
|
|
142
|
+
while i <= MAX_ROOM_INDEX do
|
|
143
|
+
local roomDescriptor = level:GetRoomByIdx(i, dimension)
|
|
144
|
+
if roomDescriptor.Data ~= nil then
|
|
145
|
+
rooms[#rooms + 1] = roomDescriptor
|
|
146
|
+
end
|
|
147
|
+
i = i + 1
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
return rooms
|
|
151
|
+
end
|
|
137
152
|
function ____exports.in2x1Room(self)
|
|
138
153
|
local room = game:GetRoom()
|
|
139
154
|
local roomShape = room:GetRoomShape()
|
|
@@ -274,12 +289,12 @@ function ____exports.setRoomCleared(self)
|
|
|
274
289
|
for ____, door in ipairs(getDoors(nil)) do
|
|
275
290
|
do
|
|
276
291
|
if isHiddenSecretRoomDoor(nil, door) then
|
|
277
|
-
goto
|
|
292
|
+
goto __continue55
|
|
278
293
|
end
|
|
279
294
|
openDoorFast(nil, door)
|
|
280
295
|
door.ExtraVisible = false
|
|
281
296
|
end
|
|
282
|
-
::
|
|
297
|
+
::__continue55::
|
|
283
298
|
end
|
|
284
299
|
sfxManager:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
|
|
285
300
|
game:ShakeScreen(0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.280",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.393",
|
|
29
29
|
"isaacscript-lint": "^1.0.99",
|
|
30
|
-
"isaacscript-tsconfig": "^1.1.
|
|
30
|
+
"isaacscript-tsconfig": "^1.1.9",
|
|
31
31
|
"typedoc": "^0.22.15",
|
|
32
32
|
"typescript": "4.6.3",
|
|
33
33
|
"typescript-to-lua": "^1.4.3"
|