isaacscript-common 6.7.0 → 6.9.0
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.
- package/dist/features/extraConsoleCommands/commandsSubroutines.lua +4 -4
- package/dist/functions/log.d.ts +14 -6
- package/dist/functions/log.d.ts.map +1 -1
- package/dist/functions/log.lua +193 -155
- package/dist/functions/pickupsSpecific.d.ts +15 -15
- package/dist/functions/pickupsSpecific.d.ts.map +1 -1
- package/dist/functions/pickupsSpecific.lua +26 -26
- package/dist/functions/run.d.ts +8 -0
- package/dist/functions/run.d.ts.map +1 -1
- package/dist/functions/run.lua +15 -0
- package/package.json +1 -1
- package/src/features/extraConsoleCommands/commandsSubroutines.ts +3 -3
- package/src/functions/log.ts +225 -179
- package/src/functions/pickupsSpecific.ts +29 -29
- package/src/functions/run.ts +14 -0
package/src/functions/log.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { getCollectibleName } from "./collectibles";
|
|
|
19
19
|
import { getEntities, getEntityID } from "./entities";
|
|
20
20
|
import { getEnumEntries } from "./enums";
|
|
21
21
|
import { hasFlag } from "./flag";
|
|
22
|
-
import { getGridEntities } from "./gridEntities";
|
|
22
|
+
import { getGridEntities, getGridEntityID } from "./gridEntities";
|
|
23
23
|
import { getIsaacAPIClassName } from "./isaacAPIClass";
|
|
24
24
|
import { getPlayerHealth } from "./playerHealth";
|
|
25
25
|
import { getEffectsList, getPlayerName } from "./players";
|
|
@@ -83,6 +83,106 @@ export function log(this: void, msg: string): void {
|
|
|
83
83
|
Isaac.DebugString(debugMsg);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/** Helper function for printing out every entity (or filtered entity) in the current room. */
|
|
87
|
+
export function logAllEntities(
|
|
88
|
+
this: void,
|
|
89
|
+
includeBackgroundEffects: boolean,
|
|
90
|
+
entityTypeFilter?: EntityType,
|
|
91
|
+
): void {
|
|
92
|
+
let msg = "Entities in the room";
|
|
93
|
+
if (entityTypeFilter !== undefined) {
|
|
94
|
+
msg += ` (filtered to entity type ${entityTypeFilter})`;
|
|
95
|
+
} else if (!includeBackgroundEffects) {
|
|
96
|
+
msg += " (not including background effects)";
|
|
97
|
+
}
|
|
98
|
+
msg += ":\n";
|
|
99
|
+
|
|
100
|
+
const entities = getEntities();
|
|
101
|
+
let numMatchedEntities = 0;
|
|
102
|
+
entities.forEach((entity, i) => {
|
|
103
|
+
// If a filter was specified, exclude all entities outside of the filter.
|
|
104
|
+
if (entityTypeFilter !== undefined && entity.Type !== entityTypeFilter) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const effect = entity.ToEffect();
|
|
109
|
+
if (
|
|
110
|
+
!includeBackgroundEffects &&
|
|
111
|
+
effect !== undefined &&
|
|
112
|
+
IGNORE_EFFECT_VARIANTS.has(effect.Variant)
|
|
113
|
+
) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
msg += getEntityLogLine(entity, i + 1);
|
|
118
|
+
numMatchedEntities++;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (numMatchedEntities === 0) {
|
|
122
|
+
msg += "(no entities matched)\n";
|
|
123
|
+
} else {
|
|
124
|
+
msg += `(${numMatchedEntities} total ${
|
|
125
|
+
numMatchedEntities === 1 ? "entity" : "entities"
|
|
126
|
+
})\n`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
log(msg);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Helper function for printing out every grid entity (or filtered grid entity) in the current room.
|
|
134
|
+
*/
|
|
135
|
+
export function logAllGridEntities(
|
|
136
|
+
this: void,
|
|
137
|
+
includeWalls: boolean,
|
|
138
|
+
gridEntityTypeFilter?: GridEntityType,
|
|
139
|
+
): void {
|
|
140
|
+
let msg = "Grid entities in the room";
|
|
141
|
+
if (gridEntityTypeFilter !== undefined) {
|
|
142
|
+
msg += ` (filtered to grid entity type ${gridEntityTypeFilter})`;
|
|
143
|
+
} else if (!includeWalls) {
|
|
144
|
+
msg += " (not including walls)";
|
|
145
|
+
}
|
|
146
|
+
msg += ":\n";
|
|
147
|
+
|
|
148
|
+
const gridEntities = getGridEntities();
|
|
149
|
+
let numMatchedEntities = 0;
|
|
150
|
+
gridEntities.forEach((gridEntity) => {
|
|
151
|
+
const gridEntityIndex = gridEntity.GetGridIndex();
|
|
152
|
+
const gridEntityType = gridEntity.GetType();
|
|
153
|
+
|
|
154
|
+
// If a filter was specified, exclude all entities outside of the filter.
|
|
155
|
+
if (
|
|
156
|
+
gridEntityTypeFilter !== undefined &&
|
|
157
|
+
gridEntityType !== gridEntityTypeFilter
|
|
158
|
+
) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (
|
|
163
|
+
!includeWalls &&
|
|
164
|
+
gridEntityType === GridEntityType.WALL &&
|
|
165
|
+
gridEntityTypeFilter !== GridEntityType.WALL
|
|
166
|
+
) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
msg += getGridEntityLogLine(gridEntity, gridEntityIndex);
|
|
171
|
+
|
|
172
|
+
numMatchedEntities++;
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (numMatchedEntities === 0) {
|
|
176
|
+
msg += "(no grid entities matched)\n";
|
|
177
|
+
} else {
|
|
178
|
+
msg += `(${numMatchedEntities} total grid ${
|
|
179
|
+
numMatchedEntities === 1 ? "entity" : "entities"
|
|
180
|
+
})\n`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
log(msg);
|
|
184
|
+
}
|
|
185
|
+
|
|
86
186
|
export function logArray<T>(this: void, array: T[] | readonly T[]): void {
|
|
87
187
|
const arrayString = arrayToString(array);
|
|
88
188
|
log(`Array: ${arrayString}`);
|
|
@@ -130,116 +230,90 @@ export function logEffects(this: void, player: EntityPlayer): void {
|
|
|
130
230
|
});
|
|
131
231
|
}
|
|
132
232
|
|
|
133
|
-
/** Helper function for
|
|
134
|
-
export function logEntities(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
entityTypeFilter?: EntityType,
|
|
138
|
-
): void {
|
|
139
|
-
let msg = "Entities in the room";
|
|
140
|
-
if (entityTypeFilter !== undefined) {
|
|
141
|
-
msg += ` (filtered to entity type ${entityTypeFilter})`;
|
|
142
|
-
} else if (!includeBackgroundEffects) {
|
|
143
|
-
msg += " (not including background effects)";
|
|
233
|
+
/** Helper function for logging an array of specific entities. */
|
|
234
|
+
export function logEntities(this: void, entities: Entity[]): void {
|
|
235
|
+
for (const entity of entities) {
|
|
236
|
+
logEntity(entity);
|
|
144
237
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const entities = getEntities();
|
|
148
|
-
let numMatchedEntities = 0;
|
|
149
|
-
entities.forEach((entity, i) => {
|
|
150
|
-
// If a filter was specified, exclude all entities outside of the filter.
|
|
151
|
-
if (entityTypeFilter !== undefined && entity.Type !== entityTypeFilter) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const effect = entity.ToEffect();
|
|
156
|
-
if (
|
|
157
|
-
!includeBackgroundEffects &&
|
|
158
|
-
effect !== undefined &&
|
|
159
|
-
IGNORE_EFFECT_VARIANTS.has(effect.Variant)
|
|
160
|
-
) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
238
|
+
}
|
|
163
239
|
|
|
164
|
-
|
|
165
|
-
|
|
240
|
+
/** Helper function to log information about a specific entity. */
|
|
241
|
+
export function logEntity(this: void, entity: Entity): void {
|
|
242
|
+
const msg = getEntityLogLine(entity);
|
|
243
|
+
log(msg);
|
|
244
|
+
}
|
|
166
245
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
msg += " (bomb)";
|
|
170
|
-
}
|
|
246
|
+
function getEntityLogLine(entity: Entity, num?: int): string {
|
|
247
|
+
let msg = num === undefined ? "" : `${num}) `;
|
|
171
248
|
|
|
172
|
-
|
|
173
|
-
msg += ` (effect) (State: ${effect.State})`;
|
|
174
|
-
}
|
|
249
|
+
msg += getEntityID(entity);
|
|
175
250
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
251
|
+
const bomb = entity.ToBomb();
|
|
252
|
+
if (bomb !== undefined) {
|
|
253
|
+
msg += " (bomb)";
|
|
254
|
+
}
|
|
180
255
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
256
|
+
const effect = entity.ToEffect();
|
|
257
|
+
if (effect !== undefined) {
|
|
258
|
+
msg += ` (effect) (State: ${effect.State})`;
|
|
259
|
+
}
|
|
185
260
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
261
|
+
const familiar = entity.ToFamiliar();
|
|
262
|
+
if (familiar !== undefined) {
|
|
263
|
+
msg += ` (familiar) (State: ${familiar.State})`;
|
|
264
|
+
}
|
|
190
265
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
266
|
+
const knife = entity.ToKnife();
|
|
267
|
+
if (knife !== undefined) {
|
|
268
|
+
msg += " (knife)";
|
|
269
|
+
}
|
|
195
270
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
271
|
+
const laser = entity.ToLaser();
|
|
272
|
+
if (laser !== undefined) {
|
|
273
|
+
msg += " (laser)";
|
|
274
|
+
}
|
|
200
275
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
276
|
+
const npc = entity.ToNPC();
|
|
277
|
+
if (npc !== undefined) {
|
|
278
|
+
msg += ` (NPC) (State: ${npc.State})`;
|
|
279
|
+
}
|
|
205
280
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
281
|
+
const pickup = entity.ToPickup();
|
|
282
|
+
if (pickup !== undefined) {
|
|
283
|
+
msg += ` (pickup) (State: ${pickup.State})`;
|
|
284
|
+
}
|
|
210
285
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
286
|
+
const player = entity.ToPlayer();
|
|
287
|
+
if (player !== undefined) {
|
|
288
|
+
msg += " (player)";
|
|
289
|
+
}
|
|
215
290
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
msg +=
|
|
219
|
-
|
|
220
|
-
msg += ` - Position: (${entity.Position.X}, ${entity.Position.Y})\n`;
|
|
221
|
-
msg += ` - Velocity: (${entity.Velocity.X}, ${entity.Velocity.Y})\n`;
|
|
222
|
-
msg += ` - HP: ${entity.HitPoints} / ${entity.MaxHitPoints}\n`;
|
|
223
|
-
msg += ` - Parent: ${entity.Parent}\n`;
|
|
224
|
-
msg += ` - Child: ${entity.Child}\n`;
|
|
225
|
-
msg += ` - SpawnerEntity: ${entity.SpawnerEntity}\n`;
|
|
226
|
-
msg += ` - SpawnerType / SpawnerVariant: ${entity.SpawnerType}.${entity.SpawnerVariant}\n`;
|
|
227
|
-
if (npc !== undefined) {
|
|
228
|
-
msg += ` - CanShutDoors: ${npc.CanShutDoors}\n`;
|
|
229
|
-
}
|
|
291
|
+
const projectile = entity.ToProjectile();
|
|
292
|
+
if (projectile !== undefined) {
|
|
293
|
+
msg += " (projectile)";
|
|
294
|
+
}
|
|
230
295
|
|
|
231
|
-
|
|
232
|
-
|
|
296
|
+
const tear = entity.ToTear();
|
|
297
|
+
if (tear !== undefined) {
|
|
298
|
+
msg += " (tear)";
|
|
299
|
+
}
|
|
233
300
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
301
|
+
msg += "\n";
|
|
302
|
+
msg += ` - Index: ${entity.Index}\n`;
|
|
303
|
+
msg += ` - InitSeed: ${entity.InitSeed}\n`;
|
|
304
|
+
msg += ` - DropSeed: ${entity.DropSeed}\n`;
|
|
305
|
+
msg += ` - Position: (${entity.Position.X}, ${entity.Position.Y})\n`;
|
|
306
|
+
msg += ` - Velocity: (${entity.Velocity.X}, ${entity.Velocity.Y})\n`;
|
|
307
|
+
msg += ` - HP: ${entity.HitPoints} / ${entity.MaxHitPoints}\n`;
|
|
308
|
+
msg += ` - Parent: ${entity.Parent}\n`;
|
|
309
|
+
msg += ` - Child: ${entity.Child}\n`;
|
|
310
|
+
msg += ` - SpawnerEntity: ${entity.SpawnerEntity}\n`;
|
|
311
|
+
msg += ` - SpawnerType / SpawnerVariant: ${entity.SpawnerType}.${entity.SpawnerVariant}\n`;
|
|
312
|
+
if (npc !== undefined) {
|
|
313
|
+
msg += ` - CanShutDoors: ${npc.CanShutDoors}\n`;
|
|
240
314
|
}
|
|
241
315
|
|
|
242
|
-
|
|
316
|
+
return msg;
|
|
243
317
|
}
|
|
244
318
|
|
|
245
319
|
/** Helper function for printing out every entity flag that is turned on. Useful when debugging. */
|
|
@@ -316,106 +390,74 @@ export function logGameStateFlags(this: void): void {
|
|
|
316
390
|
}
|
|
317
391
|
}
|
|
318
392
|
|
|
319
|
-
/**
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
this: void,
|
|
324
|
-
includeWalls: boolean,
|
|
325
|
-
gridEntityTypeFilter?: GridEntityType,
|
|
326
|
-
): void {
|
|
327
|
-
let msg = "Grid entities in the room";
|
|
328
|
-
if (gridEntityTypeFilter !== undefined) {
|
|
329
|
-
msg += ` (filtered to grid entity type ${gridEntityTypeFilter})`;
|
|
330
|
-
} else if (!includeWalls) {
|
|
331
|
-
msg += " (not including walls)";
|
|
393
|
+
/** Helper function for logging an array of specific grid entities. */
|
|
394
|
+
export function logGridEntities(this: void, gridEntities: GridEntity[]): void {
|
|
395
|
+
for (const gridEntity of gridEntities) {
|
|
396
|
+
logGridEntity(gridEntity);
|
|
332
397
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
const gridEntities = getGridEntities();
|
|
336
|
-
let numMatchedEntities = 0;
|
|
337
|
-
gridEntities.forEach((gridEntity) => {
|
|
338
|
-
const gridEntityIndex = gridEntity.GetGridIndex();
|
|
339
|
-
const gridEntityType = gridEntity.GetType();
|
|
340
|
-
const gridEntityVariant = gridEntity.GetVariant();
|
|
341
|
-
const gridEntityDesc = gridEntity.GetSaveState();
|
|
342
|
-
|
|
343
|
-
// If a filter was specified, exclude all entities outside of the filter.
|
|
344
|
-
if (
|
|
345
|
-
gridEntityTypeFilter !== undefined &&
|
|
346
|
-
gridEntityType !== gridEntityTypeFilter
|
|
347
|
-
) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
398
|
+
}
|
|
350
399
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
400
|
+
/** Helper function for log information about a specific grid entity. */
|
|
401
|
+
export function logGridEntity(this: void, gridEntity: GridEntity): void {
|
|
402
|
+
const msg = getGridEntityLogLine(gridEntity);
|
|
403
|
+
log(msg);
|
|
404
|
+
}
|
|
358
405
|
|
|
359
|
-
|
|
406
|
+
function getGridEntityLogLine(gridEntity: GridEntity, num?: int): string {
|
|
407
|
+
const gridEntityDesc = gridEntity.GetSaveState();
|
|
360
408
|
|
|
361
|
-
|
|
362
|
-
if (door !== undefined) {
|
|
363
|
-
msg += " (door)";
|
|
364
|
-
}
|
|
409
|
+
let msg = num === undefined ? "" : `${num}) `;
|
|
365
410
|
|
|
366
|
-
|
|
367
|
-
if (pit !== undefined) {
|
|
368
|
-
msg += " (pit)";
|
|
369
|
-
}
|
|
411
|
+
msg += getGridEntityID(gridEntity);
|
|
370
412
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
413
|
+
const door = gridEntity.ToDoor();
|
|
414
|
+
if (door !== undefined) {
|
|
415
|
+
msg += " (door)";
|
|
416
|
+
}
|
|
375
417
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
418
|
+
const pit = gridEntity.ToPit();
|
|
419
|
+
if (pit !== undefined) {
|
|
420
|
+
msg += " (pit)";
|
|
421
|
+
}
|
|
380
422
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
423
|
+
const poop = gridEntity.ToPoop();
|
|
424
|
+
if (poop !== undefined) {
|
|
425
|
+
msg += " (poop)";
|
|
426
|
+
}
|
|
385
427
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
428
|
+
const pressurePlate = gridEntity.ToPressurePlate();
|
|
429
|
+
if (pressurePlate !== undefined) {
|
|
430
|
+
msg += " (pressurePlate)";
|
|
431
|
+
}
|
|
390
432
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
433
|
+
const rock = gridEntity.ToRock();
|
|
434
|
+
if (rock !== undefined) {
|
|
435
|
+
msg += " (rock)";
|
|
436
|
+
}
|
|
395
437
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
msg +=
|
|
399
|
-
|
|
400
|
-
if (door !== undefined) {
|
|
401
|
-
msg += ` - Slot: ${door.Slot}\n`;
|
|
402
|
-
msg += ` - Direction: ${door.Direction}\n`;
|
|
403
|
-
msg += ` - TargetRoomIndex: ${door.TargetRoomIndex}\n`;
|
|
404
|
-
msg += ` - TargetRoomType: ${door.TargetRoomType}\n`;
|
|
405
|
-
}
|
|
438
|
+
const spikes = gridEntity.ToSpikes();
|
|
439
|
+
if (spikes !== undefined) {
|
|
440
|
+
msg += " (spikes)";
|
|
441
|
+
}
|
|
406
442
|
|
|
407
|
-
|
|
408
|
-
|
|
443
|
+
const tnt = gridEntity.ToTNT();
|
|
444
|
+
if (tnt !== undefined) {
|
|
445
|
+
msg += " (TNT)";
|
|
446
|
+
}
|
|
409
447
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
448
|
+
msg += ` - State: ${gridEntity.State}\n`;
|
|
449
|
+
msg += ` - VarData: ${gridEntity.VarData}\n`;
|
|
450
|
+
msg += ` - Position: (${gridEntity.Position.X}, ${gridEntity.Position.Y})\n`;
|
|
451
|
+
msg += ` - SpawnSeed: ${gridEntityDesc.SpawnSeed}\n`;
|
|
452
|
+
msg += ` - VariableSeed: ${gridEntityDesc.VariableSeed})\n`;
|
|
453
|
+
if (door !== undefined) {
|
|
454
|
+
msg += ` - Slot: ${door.Slot}\n`;
|
|
455
|
+
msg += ` - Direction: ${door.Direction}\n`;
|
|
456
|
+
msg += ` - TargetRoomIndex: ${door.TargetRoomIndex}\n`;
|
|
457
|
+
msg += ` - TargetRoomType: ${door.TargetRoomType}\n`;
|
|
416
458
|
}
|
|
417
459
|
|
|
418
|
-
|
|
460
|
+
return msg;
|
|
419
461
|
}
|
|
420
462
|
|
|
421
463
|
export function logKColor(this: void, kColor: KColor): void {
|
|
@@ -714,17 +756,21 @@ export function setLogFunctionsGlobal(): void {
|
|
|
714
756
|
const globals = _G as Record<string, unknown>;
|
|
715
757
|
|
|
716
758
|
globals["log"] = log;
|
|
759
|
+
globals["logAllEntities"] = logAllEntities;
|
|
760
|
+
globals["logAllGridEntities"] = logAllGridEntities;
|
|
717
761
|
globals["logArray"] = logArray;
|
|
718
762
|
globals["logColor"] = logColor;
|
|
719
763
|
globals["logDamageFlags"] = logDamageFlags;
|
|
720
764
|
globals["logEffects"] = logEffects;
|
|
721
765
|
globals["logEntities"] = logEntities;
|
|
766
|
+
globals["logEntity"] = logEntity;
|
|
722
767
|
globals["logEntityID"] = logEntityID;
|
|
723
768
|
globals["logEntityFlags"] = logEntityFlags;
|
|
724
769
|
globals["logError"] = logError;
|
|
725
770
|
globals["logFlags"] = logFlags;
|
|
726
771
|
globals["logGameStateFlags"] = logGameStateFlags;
|
|
727
772
|
globals["logGridEntities"] = logGridEntities;
|
|
773
|
+
globals["logGridEntity"] = logGridEntity;
|
|
728
774
|
globals["logKColor"] = logKColor;
|
|
729
775
|
globals["logLevelStateFlags"] = logLevelStateFlags;
|
|
730
776
|
globals["logMap"] = logMap;
|