isaacscript-common 20.12.1 → 20.12.3

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 (58) hide show
  1. package/dist/index.d.ts +48 -42
  2. package/dist/isaacscript-common.lua +262 -416
  3. package/dist/src/classes/ModFeature.lua +0 -4
  4. package/dist/src/classes/ModUpgradedBase.lua +3 -9
  5. package/dist/src/classes/callbacks/PostNewRoomEarly.lua +2 -2
  6. package/dist/src/classes/features/callbackLogic/CustomRevive.lua +2 -5
  7. package/dist/src/classes/features/other/CustomStages.lua +4 -16
  8. package/dist/src/classes/features/other/CustomTrapdoors.lua +1 -4
  9. package/dist/src/classes/features/other/DeployJSONRoom.lua +8 -14
  10. package/dist/src/classes/features/other/Pause.lua +2 -2
  11. package/dist/src/classes/features/other/TaintedLazarusPlayers.lua +1 -1
  12. package/dist/src/classes/features/other/customStages/utils.lua +4 -16
  13. package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +4 -4
  14. package/dist/src/classes/features/other/extraConsoleCommands/subroutines.lua +2 -2
  15. package/dist/src/classes/features/other/saveDataManager/loadFromDisk.lua +4 -7
  16. package/dist/src/classes/features/other/saveDataManager/restoreDefaults.lua +2 -2
  17. package/dist/src/classes/features/other/saveDataManager/saveToDisk.lua +1 -1
  18. package/dist/src/functions/benchmark.lua +2 -8
  19. package/dist/src/functions/debugFunctions.d.ts +2 -2
  20. package/dist/src/functions/debugFunctions.d.ts.map +1 -1
  21. package/dist/src/functions/debugFunctions.lua +4 -4
  22. package/dist/src/functions/deepCopy.lua +7 -7
  23. package/dist/src/functions/deepCopyTests.lua +1 -1
  24. package/dist/src/functions/globals.lua +3 -6
  25. package/dist/src/functions/hex.lua +4 -7
  26. package/dist/src/functions/jsonHelpers.lua +1 -1
  27. package/dist/src/functions/jsonRoom.lua +4 -16
  28. package/dist/src/functions/log.d.ts +8 -4
  29. package/dist/src/functions/log.d.ts.map +1 -1
  30. package/dist/src/functions/log.lua +18 -5
  31. package/dist/src/functions/logEntities.d.ts +8 -8
  32. package/dist/src/functions/logEntities.d.ts.map +1 -1
  33. package/dist/src/functions/logEntities.lua +24 -27
  34. package/dist/src/functions/logMisc.d.ts +26 -26
  35. package/dist/src/functions/logMisc.d.ts.map +1 -1
  36. package/dist/src/functions/logMisc.lua +114 -226
  37. package/dist/src/functions/merge.lua +6 -6
  38. package/dist/src/functions/modFeatures.d.ts +3 -1
  39. package/dist/src/functions/modFeatures.d.ts.map +1 -1
  40. package/dist/src/functions/run.lua +2 -5
  41. package/dist/src/functions/utils.d.ts.map +1 -1
  42. package/dist/src/functions/utils.lua +20 -1
  43. package/dist/src/lib/jsonLua.lua +16 -7
  44. package/dist/src/patchErrorFunctions.lua +1 -1
  45. package/dist/src/types/AnyClass.d.ts +1 -1
  46. package/dist/src/types/AnyClass.d.ts.map +1 -1
  47. package/package.json +1 -1
  48. package/src/classes/ModFeature.ts +0 -6
  49. package/src/classes/features/other/saveDataManager/saveToDisk.ts +3 -4
  50. package/src/functions/debugFunctions.ts +2 -2
  51. package/src/functions/deepCopy.ts +2 -0
  52. package/src/functions/log.ts +15 -4
  53. package/src/functions/logEntities.ts +14 -8
  54. package/src/functions/logMisc.ts +56 -39
  55. package/src/functions/modFeatures.ts +4 -4
  56. package/src/functions/utils.ts +30 -0
  57. package/src/lib/jsonLua.lua +16 -7
  58. package/src/types/AnyClass.ts +1 -1
package/dist/index.d.ts CHANGED
@@ -787,7 +787,7 @@ export declare enum AmbushType {
787
787
  export declare function angleToDirection(angleDegrees: int): Direction;
788
788
 
789
789
  /** Helper type to represent any class. (This is the same type as any class constructor.) */
790
- export declare type AnyClass = new (...args: unknown[]) => unknown;
790
+ export declare type AnyClass = new () => object;
791
791
 
792
792
  /**
793
793
  * A type union that matches `Entity`, `EntityBomb`, `EntityEffect`, and so on.
@@ -5307,7 +5307,7 @@ export declare function getOtherPlayers(player: EntityPlayer): EntityPlayer[];
5307
5307
  * (because the first level is this function, the second level is the calling
5308
5308
  * function, and the third level is the parent of the calling function).
5309
5309
  */
5310
- export declare function getParentFunctionDescription(levels?: number): string | undefined;
5310
+ export declare function getParentFunctionDescription(this: void, levels?: number): string | undefined;
5311
5311
 
5312
5312
  /**
5313
5313
  * Helper function to get the closest value from an array of strings based on partial search text.
@@ -6459,7 +6459,7 @@ export declare function getTotalPlayerCollectibles(collectibleType: CollectibleT
6459
6459
  * This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
6460
6460
  * enabled.
6461
6461
  */
6462
- export declare function getTraceback(): string;
6462
+ export declare function getTraceback(this: void): string;
6463
6463
 
6464
6464
  /**
6465
6465
  * Helper function to get a transformation name from a PlayerForm enum.
@@ -6965,7 +6965,9 @@ export declare function initArray<T>(defaultValue: T, size: int): T[];
6965
6965
  * @returns An array of the instantiated features in the same order that the constructors were
6966
6966
  * passed in.
6967
6967
  */
6968
- export declare function initModFeatures(mod: ModUpgraded, modFeatures: Array<typeof ModFeature>): ModFeature[];
6968
+ export declare function initModFeatures<T extends ReadonlyArray<typeof ModFeature>>(mod: ModUpgraded, modFeatures: T): {
6969
+ [Key in keyof T]: InstanceType<T[Key]>;
6970
+ };
6969
6971
 
6970
6972
  /** Helper function to determine if the current room shape is one of the four L room shapes. */
6971
6973
  export declare function inLRoom(): boolean;
@@ -8408,8 +8410,8 @@ export declare function lockDoor(door: GridEntityDoor): void;
8408
8410
  /**
8409
8411
  * Helper function to avoid typing out `Isaac.DebugString()`.
8410
8412
  *
8411
- * If you have the "--luadebug" launch flag turned on or the Racing+ sandbox enabled, then this
8412
- * function will also prepend the function name and the line number before the string, like this:
8413
+ * If you have the "--luadebug" launch flag turned on, then this function will also prepend the
8414
+ * function name and the line number before the string, like this:
8413
8415
  *
8414
8416
  * ```text
8415
8417
  * [INFO] - Lua Debug: saveToDisk:42494 - The save data manager wrote data to the "save#.dat" file.
@@ -8417,11 +8419,15 @@ export declare function lockDoor(door: GridEntityDoor): void;
8417
8419
  *
8418
8420
  * Subsequently, it is recommended that you turn on the "--luadebug" launch flag when developing
8419
8421
  * your mod so that debugging becomes a little bit easier.
8422
+ *
8423
+ * @param msg The message to log.
8424
+ * @param includeParentFunction Optional. Whether to prefix the message with the function name and
8425
+ * line number, as shown in the above example. Default is true.
8420
8426
  */
8421
- export declare function log(msg: string): void;
8427
+ export declare function log(this: void, msg: string, includeParentFunction?: boolean): void;
8422
8428
 
8423
8429
  /** Helper function for printing out every entity (or filtered entity) in the current room. */
8424
- export declare function logAllEntities(includeBackgroundEffects: boolean, entityTypeFilter?: EntityType): void;
8430
+ export declare function logAllEntities(this: void, includeBackgroundEffects: boolean, entityTypeFilter?: EntityType): void;
8425
8431
 
8426
8432
  /**
8427
8433
  * Helper function for printing out every grid entity (or filtered grid entity) in the current room.
@@ -8430,7 +8436,7 @@ export declare function logAllEntities(includeBackgroundEffects: boolean, entity
8430
8436
  * @param gridEntityTypeFilter Optional. If specified, will only log the given `GridEntityType`.
8431
8437
  * Default is undefined.
8432
8438
  */
8433
- export declare function logAllGridEntities(includeWalls?: boolean, gridEntityTypeFilter?: GridEntityType): void;
8439
+ export declare function logAllGridEntities(this: void, includeWalls?: boolean, gridEntityTypeFilter?: GridEntityType): void;
8434
8440
 
8435
8441
  /**
8436
8442
  * Helper function to log a message to the "log.txt" file and to print it to the screen at the same
@@ -8439,25 +8445,25 @@ export declare function logAllGridEntities(includeWalls?: boolean, gridEntityTyp
8439
8445
  export declare function logAndPrint(msg: string): void;
8440
8446
 
8441
8447
  /** Helper function to enumerate all of the values in an array. */
8442
- export declare function logArray<T>(array: T[] | readonly T[]): void;
8448
+ export declare function logArray<T>(this: void, array: T[] | readonly T[]): void;
8443
8449
 
8444
- export declare function logCollectibleTypes(collectibleTypes: CollectibleType[]): void;
8450
+ export declare function logCollectibleTypes(this: void, collectibleTypes: CollectibleType[]): void;
8445
8451
 
8446
- export declare function logColor(color: Color): void;
8452
+ export declare function logColor(this: void, color: Color): void;
8447
8453
 
8448
8454
  /** Helper function for printing out every damage flag that is turned on. Useful when debugging. */
8449
- export declare function logDamageFlags(flags: DamageFlag | BitFlags<DamageFlag>): void;
8455
+ export declare function logDamageFlags(this: void, flags: DamageFlag | BitFlags<DamageFlag>): void;
8450
8456
 
8451
8457
  /** Helper function for logging an array of specific entities. */
8452
- export declare function logEntities(entities: Entity[]): void;
8458
+ export declare function logEntities(this: void, entities: Entity[]): void;
8453
8459
 
8454
8460
  /** Helper function to log information about a specific entity. */
8455
- export declare function logEntity(entity: Entity): void;
8461
+ export declare function logEntity(this: void, entity: Entity): void;
8456
8462
 
8457
8463
  /** Helper function for printing out every entity flag that is turned on. Useful when debugging. */
8458
- export declare function logEntityFlags(flags: EntityFlag | BitFlags<EntityFlag>): void;
8464
+ export declare function logEntityFlags(this: void, flags: EntityFlag | BitFlags<EntityFlag>): void;
8459
8465
 
8460
- export declare function logEntityID(entity: Entity): void;
8466
+ export declare function logEntityID(this: void, entity: Entity): void;
8461
8467
 
8462
8468
  /**
8463
8469
  * Helper function to log an error message and also print it to the console for better visibility.
@@ -8465,67 +8471,67 @@ export declare function logEntityID(entity: Entity): void;
8465
8471
  * This is useful in situations where using the `error` function would be dangerous (since it
8466
8472
  * prevents all of the subsequent code in the callback from running).
8467
8473
  */
8468
- export declare function logError(msg: string): void;
8474
+ export declare function logError(this: void, msg: string): void;
8469
8475
 
8470
8476
  /** Helper function for printing out every flag that is turned on. Useful when debugging. */
8471
- export declare function logFlags<T extends BitFlag | BitFlag128>(flags: T | BitFlags<T>, flagEnum: Record<string, T>, description?: string): void;
8477
+ export declare function logFlags<T extends BitFlag | BitFlag128>(this: void, flags: T | BitFlags<T>, flagEnum: Record<string, T>, description?: string): void;
8472
8478
 
8473
8479
  /**
8474
8480
  * Helper function for printing out every game state flag that is turned on. Useful when debugging.
8475
8481
  */
8476
- export declare function logGameStateFlags(): void;
8482
+ export declare function logGameStateFlags(this: void): void;
8477
8483
 
8478
8484
  /** Helper function for logging an array of specific grid entities. */
8479
- export declare function logGridEntities(gridEntities: GridEntity[]): void;
8485
+ export declare function logGridEntities(this: void, gridEntities: GridEntity[]): void;
8480
8486
 
8481
8487
  /** Helper function for log information about a specific grid entity. */
8482
- export declare function logGridEntity(gridEntity: GridEntity): void;
8488
+ export declare function logGridEntity(this: void, gridEntity: GridEntity): void;
8483
8489
 
8484
- export declare function logKColor(kColor: KColor): void;
8490
+ export declare function logKColor(this: void, kColor: KColor): void;
8485
8491
 
8486
8492
  /**
8487
8493
  * Helper function for printing out every level state flag that is turned on. Useful when debugging.
8488
8494
  */
8489
- export declare function logLevelStateFlags(): void;
8495
+ export declare function logLevelStateFlags(this: void): void;
8490
8496
 
8491
- export declare function logMap(map: Map<AnyNotNil, unknown>): void;
8497
+ export declare function logMap(this: void, map: Map<AnyNotNil, unknown>): void;
8492
8498
 
8493
8499
  export declare function logNewGlobals(): void;
8494
8500
 
8495
- export declare function logPlayerEffects(player: EntityPlayer): void;
8501
+ export declare function logPlayerEffects(this: void, player: EntityPlayer): void;
8496
8502
 
8497
- export declare function logPlayerHealth(player: EntityPlayer): void;
8503
+ export declare function logPlayerHealth(this: void, player: EntityPlayer): void;
8498
8504
 
8499
8505
  /**
8500
8506
  * Helper function for printing out every projectile flag that is turned on. Useful when debugging.
8501
8507
  */
8502
- export declare function logProjectileFlags(flags: ProjectileFlag | BitFlags<ProjectileFlag>): void;
8508
+ export declare function logProjectileFlags(this: void, flags: ProjectileFlag | BitFlags<ProjectileFlag>): void;
8503
8509
 
8504
8510
  /**
8505
8511
  * Helper function to log information about the entity that corresponding to a pointer hash. (Only
8506
8512
  * use this when debugging, since retrieving the corresponding entity is expensive.)
8507
8513
  */
8508
- export declare function logPtrHash(ptrHash: PtrHash): void;
8514
+ export declare function logPtrHash(this: void, ptrHash: PtrHash): void;
8509
8515
 
8510
8516
  /**
8511
8517
  * Helper function to log information about the entity that corresponding to one or more pointer
8512
8518
  * hashes. (Only use this when debugging, since retrieving the corresponding entity is expensive.)
8513
8519
  */
8514
- export declare function logPtrHashes(ptrHashes: PtrHash[]): void;
8520
+ export declare function logPtrHashes(this: void, ptrHashes: PtrHash[]): void;
8515
8521
 
8516
8522
  /** Helper function for logging information about the current room. */
8517
- export declare function logRoom(): void;
8523
+ export declare function logRoom(this: void): void;
8518
8524
 
8519
8525
  /**
8520
8526
  * Helper function for printing out every seed effect (i.e. Easter Egg) that is turned on for the
8521
8527
  * particular run.
8522
8528
  */
8523
- export declare function logSeedEffects(): void;
8529
+ export declare function logSeedEffects(this: void): void;
8524
8530
 
8525
- export declare function logSet(set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>): void;
8531
+ export declare function logSet(this: void, set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>): void;
8526
8532
 
8527
8533
  /** Helper function for logging every sound effect that is currently playing. */
8528
- export declare function logSounds(): void;
8534
+ export declare function logSounds(this: void): void;
8529
8535
 
8530
8536
  /**
8531
8537
  * Helper function for logging every key and value of a Lua table. This is a deep log; the function
@@ -8537,13 +8543,13 @@ export declare function logSounds(): void;
8537
8543
  * In order to prevent infinite recursion, this function will not log a sub-table when there are 10
8538
8544
  * or more parent tables.
8539
8545
  */
8540
- export declare function logTable(luaTable: unknown, parentTables?: number): void;
8546
+ export declare function logTable(this: void, luaTable: unknown, parentTables?: number): void;
8541
8547
 
8542
8548
  /**
8543
8549
  * Helper function to print out the differences between the entries of two tables. Note that this
8544
8550
  * will only do a shallow comparison.
8545
8551
  */
8546
- export declare function logTableDifferences<K extends AnyNotNil, V>(table1: LuaMap<K, V>, table2: LuaMap<K, V>): void;
8552
+ export declare function logTableDifferences<K extends AnyNotNil, V>(this: void, table1: LuaMap<K, V>, table2: LuaMap<K, V>): void;
8547
8553
 
8548
8554
  /**
8549
8555
  * Helper function to log the keys of a Lua table. This is not a deep log; only the keys of the
@@ -8551,21 +8557,21 @@ export declare function logTableDifferences<K extends AnyNotNil, V>(table1: LuaM
8551
8557
  *
8552
8558
  * This function is useful for tables that have recursive references.
8553
8559
  */
8554
- export declare function logTableKeys(luaTable: unknown): void;
8560
+ export declare function logTableKeys(this: void, luaTable: unknown): void;
8555
8561
 
8556
8562
  /** Helper function for printing out every tear flag that is turned on. Useful when debugging. */
8557
- export declare function logTearFlags(flags: TearFlag | BitFlags<TearFlag>): void;
8563
+ export declare function logTearFlags(this: void, flags: TearFlag | BitFlags<TearFlag>): void;
8558
8564
 
8559
8565
  /** Helper function for printing out every use flag that is turned on. Useful when debugging. */
8560
- export declare function logUseFlags(flags: UseFlag | BitFlags<UseFlag>): void;
8566
+ export declare function logUseFlags(this: void, flags: UseFlag | BitFlags<UseFlag>): void;
8561
8567
 
8562
8568
  /**
8563
8569
  * Helper function to enumerate all of the properties of a "userdata" object (i.e. an object from
8564
8570
  * the Isaac API).
8565
8571
  */
8566
- export declare function logUserdata(userdata: unknown): void;
8572
+ export declare function logUserdata(this: void, userdata: unknown): void;
8567
8573
 
8568
- export declare function logVector(vector: Vector, round?: boolean): void;
8574
+ export declare function logVector(this: void, vector: Vector, round?: boolean): void;
8569
8575
 
8570
8576
  /** Helper type to match all of the lowercase keys of an object. */
8571
8577
  export declare type LowercaseKeys<T> = StartsWithLowercase<keyof T>;
@@ -15095,7 +15101,7 @@ export declare function todo(...args: unknown[]): void;
15095
15101
  * This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
15096
15102
  * enabled.
15097
15103
  */
15098
- export declare function traceback(): void;
15104
+ export declare function traceback(this: void): void;
15099
15105
 
15100
15106
  /** Maps transformation names to the values of the `PlayerForm` enum. */
15101
15107
  export declare const TRANSFORMATION_NAME_TO_PLAYER_FORM_MAP: ReadonlyMap<string, PlayerForm>;