isaacscript-common 13.1.1 → 13.3.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.
Files changed (59) hide show
  1. package/dist/index.d.ts +47 -3
  2. package/dist/isaacscript-common.lua +11781 -11710
  3. package/dist/src/callbacks/customRevive.d.ts.map +1 -1
  4. package/dist/src/callbacks/customRevive.lua +2 -1
  5. package/dist/src/callbacks/postNewRoomEarly.lua +2 -2
  6. package/dist/src/classes/ModUpgraded.d.ts +5 -2
  7. package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
  8. package/dist/src/classes/ModUpgraded.lua +39 -3
  9. package/dist/src/core/upgradeMod.d.ts +6 -1
  10. package/dist/src/core/upgradeMod.d.ts.map +1 -1
  11. package/dist/src/core/upgradeMod.lua +9 -2
  12. package/dist/src/features/customStage/exports.lua +2 -2
  13. package/dist/src/features/deployJSONRoom.d.ts +21 -0
  14. package/dist/src/features/deployJSONRoom.d.ts.map +1 -1
  15. package/dist/src/features/deployJSONRoom.lua +33 -9
  16. package/dist/src/features/extraConsoleCommands/listCommands.lua +5 -5
  17. package/dist/src/features/pause.lua +2 -2
  18. package/dist/src/features/saveDataManager/load.d.ts.map +1 -1
  19. package/dist/src/features/saveDataManager/load.lua +2 -1
  20. package/dist/src/features/saveDataManager/main.lua +2 -2
  21. package/dist/src/features/taintedLazarusPlayers.lua +2 -2
  22. package/dist/src/functions/benchmark.d.ts +12 -0
  23. package/dist/src/functions/benchmark.d.ts.map +1 -1
  24. package/dist/src/functions/benchmark.lua +19 -0
  25. package/dist/src/functions/debugFunctions.d.ts +1 -0
  26. package/dist/src/functions/debugFunctions.d.ts.map +1 -1
  27. package/dist/src/functions/debugFunctions.lua +15 -23
  28. package/dist/src/functions/globals.lua +1 -1
  29. package/dist/src/functions/hex.lua +2 -2
  30. package/dist/src/functions/jsonHelpers.lua +2 -2
  31. package/dist/src/functions/log.d.ts +0 -68
  32. package/dist/src/functions/log.d.ts.map +1 -1
  33. package/dist/src/functions/log.lua +3 -496
  34. package/dist/src/functions/logMisc.d.ts +69 -0
  35. package/dist/src/functions/logMisc.d.ts.map +1 -0
  36. package/dist/src/functions/logMisc.lua +498 -0
  37. package/dist/src/index.d.ts +1 -0
  38. package/dist/src/index.d.ts.map +1 -1
  39. package/dist/src/index.lua +8 -0
  40. package/package.json +2 -2
  41. package/src/callbacks/customRevive.ts +2 -1
  42. package/src/callbacks/postNewRoomEarly.ts +1 -1
  43. package/src/classes/ModUpgraded.ts +43 -4
  44. package/src/core/upgradeMod.ts +10 -2
  45. package/src/features/customStage/exports.ts +1 -1
  46. package/src/features/deployJSONRoom.ts +28 -16
  47. package/src/features/extraConsoleCommands/listCommands.ts +1 -1
  48. package/src/features/pause.ts +1 -1
  49. package/src/features/saveDataManager/load.ts +2 -1
  50. package/src/features/saveDataManager/main.ts +1 -1
  51. package/src/features/taintedLazarusPlayers.ts +1 -1
  52. package/src/functions/benchmark.ts +23 -0
  53. package/src/functions/debugFunctions.ts +15 -25
  54. package/src/functions/globals.ts +1 -1
  55. package/src/functions/hex.ts +1 -1
  56. package/src/functions/jsonHelpers.ts +1 -1
  57. package/src/functions/log.ts +5 -443
  58. package/src/functions/logMisc.ts +441 -0
  59. package/src/index.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"customRevive.d.ts","sourceRoot":"","sources":["../../../src/callbacks/customRevive.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AA0CrD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAiBhE"}
1
+ {"version":3,"file":"customRevive.d.ts","sourceRoot":"","sources":["../../../src/callbacks/customRevive.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AA2CrD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAiBhE"}
@@ -20,7 +20,8 @@ local ____entitiesSpecific = require("src.functions.entitiesSpecific")
20
20
  local removeAllFamiliars = ____entitiesSpecific.removeAllFamiliars
21
21
  local ____log = require("src.functions.log")
22
22
  local log = ____log.log
23
- local logError = ____log.logError
23
+ local ____logMisc = require("src.functions.logMisc")
24
+ local logError = ____logMisc.logError
24
25
  local ____playerIndex = require("src.functions.playerIndex")
25
26
  local getPlayerFromIndex = ____playerIndex.getPlayerFromIndex
26
27
  local getPlayerIndex = ____playerIndex.getPlayerIndex
@@ -8,8 +8,8 @@ local game = ____cachedClasses.game
8
8
  local ____gridEntities = require("src.functions.gridEntities")
9
9
  local getTopLeftWallGridIndex = ____gridEntities.getTopLeftWallGridIndex
10
10
  local spawnGridEntity = ____gridEntities.spawnGridEntity
11
- local ____log = require("src.functions.log")
12
- local logError = ____log.logError
11
+ local ____logMisc = require("src.functions.logMisc")
12
+ local logError = ____logMisc.logError
13
13
  local ____postNewRoomEarly = require("src.callbacks.subscriptions.postNewRoomEarly")
14
14
  local postNewRoomEarlyFire = ____postNewRoomEarly.postNewRoomEarlyFire
15
15
  local postNewRoomEarlyHasSubscriptions = ____postNewRoomEarly.postNewRoomEarlyHasSubscriptions
@@ -4,7 +4,8 @@ import { AddCallbackParameterCustom } from "../interfaces/private/AddCallbackPar
4
4
  /**
5
5
  * `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
6
6
  * hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
7
- * extends the base class and adds a new method of `AddCallbackCustom`.
7
+ * extends the base class and adds a new method of `AddCallbackCustom`. (There is no corresponding
8
+ * `RemoveCallbackCustom`.)
8
9
  *
9
10
  * To upgrade your mod, use the `upgradeMod` helper function.
10
11
  */
@@ -16,7 +17,9 @@ export declare class ModUpgraded implements Mod {
16
17
  Name: string;
17
18
  /** We store a copy of the original mod object so that we can re-implement its functions. */
18
19
  Mod: Mod;
19
- constructor(mod: Mod);
20
+ Debug: boolean;
21
+ TimeThreshold: float | undefined;
22
+ constructor(mod: Mod, debug: boolean, timeThreshold?: float);
20
23
  AddCallback<T extends ModCallback>(modCallback: T, ...args: AddCallbackParameter[T]): void;
21
24
  HasData(): boolean;
22
25
  LoadData(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"ModUpgraded.d.ts","sourceRoot":"","sources":["../../../src/classes/ModUpgraded.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAG9F;;;;;;GAMG;AACH,qBAAa,WAAY,YAAW,GAAG;IAKrC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAMb,4FAA4F;IAC5F,GAAG,EAAE,GAAG,CAAC;gBAEG,GAAG,EAAE,GAAG;IAUpB,WAAW,CAAC,CAAC,SAAS,WAAW,EAC/B,WAAW,EAAE,CAAC,EACd,GAAG,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,IAAI;IAIP,OAAO,IAAI,OAAO;IAIlB,QAAQ,IAAI,MAAM;IAIlB;;;OAGG;IACH,cAAc,CAAC,CAAC,SAAS,WAAW,EAClC,WAAW,EAAE,CAAC,EACd,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACnC,IAAI;IAIP,UAAU,IAAI,IAAI;IAIlB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS5B,iBAAiB,CAAC,CAAC,SAAS,iBAAiB,EAC3C,iBAAiB,EAAE,CAAC,EACpB,GAAG,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACrC,IAAI;CAKR"}
1
+ {"version":3,"file":"ModUpgraded.d.ts","sourceRoot":"","sources":["../../../src/classes/ModUpgraded.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAG9F;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,GAAG;IAKrC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAMb,4FAA4F;IAC5F,GAAG,EAAE,GAAG,CAAC;IAET,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,KAAK,GAAG,SAAS,CAAC;gBAErB,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,KAAK;IAW3D,WAAW,CAAC,CAAC,SAAS,WAAW,EAC/B,WAAW,EAAE,CAAC,EACd,GAAG,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,IAAI;IAoCP,OAAO,IAAI,OAAO;IAIlB,QAAQ,IAAI,MAAM;IAIlB;;;OAGG;IACH,cAAc,CAAC,CAAC,SAAS,WAAW,EAClC,WAAW,EAAE,CAAC,EACd,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACnC,IAAI;IAIP,UAAU,IAAI,IAAI;IAIlB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS5B,iBAAiB,CAAC,CAAC,SAAS,iBAAiB,EAC3C,iBAAiB,EAAE,CAAC,EACpB,GAAG,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACrC,IAAI;CAKR"}
@@ -1,22 +1,58 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__Spread = ____lualib.__TS__Spread
3
4
  local ____exports = {}
5
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
+ local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
7
+ local ____benchmark = require("src.functions.benchmark")
8
+ local getTime = ____benchmark.getTime
9
+ local ____log = require("src.functions.log")
10
+ local log = ____log.log
4
11
  local ____callbackRegisterFunctions = require("src.objects.callbackRegisterFunctions")
5
12
  local CALLBACK_REGISTER_FUNCTIONS = ____callbackRegisterFunctions.CALLBACK_REGISTER_FUNCTIONS
6
13
  --- `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
7
14
  -- hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
8
- -- extends the base class and adds a new method of `AddCallbackCustom`.
15
+ -- extends the base class and adds a new method of `AddCallbackCustom`. (There is no corresponding
16
+ -- `RemoveCallbackCustom`.)
9
17
  --
10
18
  -- To upgrade your mod, use the `upgradeMod` helper function.
11
19
  ____exports.ModUpgraded = __TS__Class()
12
20
  local ModUpgraded = ____exports.ModUpgraded
13
21
  ModUpgraded.name = "ModUpgraded"
14
- function ModUpgraded.prototype.____constructor(self, mod)
22
+ function ModUpgraded.prototype.____constructor(self, mod, ____debug, timeThreshold)
15
23
  self.Name = mod.Name
16
24
  self.Mod = mod
25
+ self.Debug = ____debug
26
+ self.TimeThreshold = timeThreshold
17
27
  end
18
28
  function ModUpgraded.prototype.AddCallback(self, modCallback, ...)
19
- self.Mod:AddCallback(modCallback, ...)
29
+ local args = {...}
30
+ if self.Debug then
31
+ local callback = args[1]
32
+ local optionalArg = args[2]
33
+ local callbackName = "ModCallback." .. tostring(ModCallback[modCallback])
34
+ local function callbackWithLogger(____, ...)
35
+ local startTime = getTime(nil)
36
+ log(nil, callbackName .. " - START")
37
+ callback(nil, ...)
38
+ local endTime = getTime(nil)
39
+ local elapsedTime = endTime - startTime
40
+ if self.TimeThreshold == nil or self.TimeThreshold >= elapsedTime then
41
+ log(
42
+ nil,
43
+ (callbackName .. " - END - time: ") .. tostring(elapsedTime)
44
+ )
45
+ else
46
+ log(nil, callbackName .. " - END")
47
+ end
48
+ end
49
+ self.Mod:AddCallback(modCallback, callbackWithLogger, optionalArg)
50
+ else
51
+ self.Mod:AddCallback(
52
+ modCallback,
53
+ __TS__Spread(args)
54
+ )
55
+ end
20
56
  end
21
57
  function ModUpgraded.prototype.HasData(self)
22
58
  return self.Mod:HasData()
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
2
3
  import { ModUpgraded } from "../classes/ModUpgraded";
3
4
  /**
4
5
  * Use this function to enable the custom callbacks and other optional features provided by
@@ -18,7 +19,11 @@ import { ModUpgraded } from "../classes/ModUpgraded";
18
19
  * ```
19
20
  *
20
21
  * @param modVanilla The mod object returned by the `RegisterMod` function.
22
+ * @param debug Optional. Whether to log additional output when a callback is fired. Default is
23
+ * false.
24
+ * @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
25
+ * specified number of seconds.
21
26
  * @returns The upgraded mod object.
22
27
  */
23
- export declare function upgradeMod(modVanilla: Mod): ModUpgraded;
28
+ export declare function upgradeMod(modVanilla: Mod, debug?: boolean, timeThreshold?: float): ModUpgraded;
24
29
  //# sourceMappingURL=upgradeMod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upgradeMod.d.ts","sourceRoot":"","sources":["../../../src/core/upgradeMod.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAWrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,GAAG,GAAG,WAAW,CAwBvD"}
1
+ {"version":3,"file":"upgradeMod.d.ts","sourceRoot":"","sources":["../../../src/core/upgradeMod.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAWrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,GAAG,EACf,KAAK,UAAQ,EACb,aAAa,CAAC,EAAE,KAAK,GACpB,WAAW,CAwBb"}
@@ -35,9 +35,16 @@ local loadShaderCrashFix = ____shaderCrashFix.loadShaderCrashFix
35
35
  -- ```
36
36
  --
37
37
  -- @param modVanilla The mod object returned by the `RegisterMod` function.
38
+ -- @param debug Optional. Whether to log additional output when a callback is fired. Default is
39
+ -- false.
40
+ -- @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
41
+ -- specified number of seconds.
38
42
  -- @returns The upgraded mod object.
39
- function ____exports.upgradeMod(self, modVanilla)
40
- local mod = __TS__New(ModUpgraded, modVanilla)
43
+ function ____exports.upgradeMod(self, modVanilla, ____debug, timeThreshold)
44
+ if ____debug == nil then
45
+ ____debug = false
46
+ end
47
+ local mod = __TS__New(ModUpgraded, modVanilla, ____debug, timeThreshold)
41
48
  if not areFeaturesInitialized(nil) then
42
49
  setFeaturesInitialized(nil)
43
50
  patchErrorFunction(nil)
@@ -15,8 +15,8 @@ local ____cachedClasses = require("src.core.cachedClasses")
15
15
  local game = ____cachedClasses.game
16
16
  local ____doors = require("src.functions.doors")
17
17
  local doorSlotFlagsToDoorSlots = ____doors.doorSlotFlagsToDoorSlots
18
- local ____log = require("src.functions.log")
19
- local logError = ____log.logError
18
+ local ____logMisc = require("src.functions.logMisc")
19
+ local logError = ____logMisc.logError
20
20
  local ____rng = require("src.functions.rng")
21
21
  local newRNG = ____rng.newRNG
22
22
  local ____rooms = require("src.functions.rooms")
@@ -63,4 +63,25 @@ export declare function deployJSONRoom(jsonRoom: JSONRoom | Readonly<JSONRoom>,
63
63
  * what the function is doing. Default is false.
64
64
  */
65
65
  export declare function deployRandomJSONRoom(jsonRooms: JSONRoom[], seedOrRNG?: Seed | RNG, verbose?: boolean): void;
66
+ /**
67
+ * Helper function to prevent any removed grid entities from respawning if the player re-enters the
68
+ * room.
69
+ *
70
+ * This is accomplished by spawning a new grid entity on every tile that does not already have a
71
+ * grid entity. This will force the game to spawn the new grid entity instead of the old one. The
72
+ * natural grid entity to choose for this purpose is a decoration, since it is non-interacting.
73
+ * Then, the decorations are made invisible and any shovel uses are intercepted to avoid creating a
74
+ * crawl space (instead of a trapdoor).
75
+ *
76
+ * Another option besides decorations would be to use a pressure plates with a state of 1, which is
77
+ * a state that is normally unused by the game and makes it invisible & persistent. However, pickups
78
+ * will not be able to spawn on pressure plates, which lead to various bugs (e.g. pickups spawning
79
+ * on top of pits). Thus, using a decoration is preferable.
80
+ *
81
+ * Yet another option to accomplish this would be to replace the room data with that of an empty
82
+ * room. However, the room data must exactly match the room type, the room shape, and the doors, so
83
+ * this is not possible to do in a robust way without adding empty rooms to the mod's `content`
84
+ * folder to draw the data from.
85
+ */
86
+ export declare function preventGridEntityRespawn(): void;
66
87
  //# sourceMappingURL=deployJSONRoom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deployJSONRoom.d.ts","sourceRoot":"","sources":["../../../src/features/deployJSONRoom.ts"],"names":[],"mappings":";;AAgDA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAwKvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,EACvC,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CA4BN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,EACrB,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CAaN"}
1
+ {"version":3,"file":"deployJSONRoom.d.ts","sourceRoot":"","sources":["../../../src/features/deployJSONRoom.ts"],"names":[],"mappings":";;AAiDA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA6KvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,EACvC,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CA4BN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,EACrB,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,IAAI,CAaN;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CA0B/C"}
@@ -4,7 +4,7 @@ local __TS__New = ____lualib.__TS__New
4
4
  local Map = ____lualib.Map
5
5
  local __TS__Iterator = ____lualib.__TS__Iterator
6
6
  local ____exports = {}
7
- local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, PERSISTENT_ENTITY_TYPES, GRID_ENTITY_XML_TYPE_SET, v
7
+ local preUseItemWeNeedToGoDeeper, postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, PERSISTENT_ENTITY_TYPES, GRID_ENTITY_XML_TYPE_SET, v
8
8
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
9
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
10
10
  local EntityCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityCollisionClass
@@ -40,6 +40,7 @@ local getAllGridIndexes = ____gridEntities.getAllGridIndexes
40
40
  local getGridEntities = ____gridEntities.getGridEntities
41
41
  local removeGridEntity = ____gridEntities.removeGridEntity
42
42
  local setGridEntityInvisible = ____gridEntities.setGridEntityInvisible
43
+ local spawnGridEntity = ____gridEntities.spawnGridEntity
43
44
  local spawnGridEntityWithVariant = ____gridEntities.spawnGridEntityWithVariant
44
45
  local ____jsonRoom = require("src.functions.jsonRoom")
45
46
  local getRandomJSONEntity = ____jsonRoom.getRandomJSONEntity
@@ -90,12 +91,16 @@ function preUseItemWeNeedToGoDeeper(self, _collectibleType, _rng, player, _useFl
90
91
  if futurePlayer == nil then
91
92
  return
92
93
  end
94
+ local futureRoomListIndex = getRoomListIndex(nil)
95
+ if futureRoomListIndex ~= roomListIndex then
96
+ return
97
+ end
93
98
  v.room.manuallyUsingShovel = true
94
99
  futurePlayer:UseActiveItem(CollectibleType.WE_NEED_TO_GO_DEEPER)
95
100
  v.room.manuallyUsingShovel = false
96
101
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
97
102
  emptyArray(nil, decorationGridIndexes)
98
- fillRoomWithDecorations(nil)
103
+ ____exports.preventGridEntityRespawn(nil)
99
104
  end
100
105
  )
101
106
  return true
@@ -137,24 +142,43 @@ function respawnPersistentEntities(self)
137
142
  )
138
143
  end
139
144
  end
140
- function fillRoomWithDecorations(self)
145
+ --- Helper function to prevent any removed grid entities from respawning if the player re-enters the
146
+ -- room.
147
+ --
148
+ -- This is accomplished by spawning a new grid entity on every tile that does not already have a
149
+ -- grid entity. This will force the game to spawn the new grid entity instead of the old one. The
150
+ -- natural grid entity to choose for this purpose is a decoration, since it is non-interacting.
151
+ -- Then, the decorations are made invisible and any shovel uses are intercepted to avoid creating a
152
+ -- crawl space (instead of a trapdoor).
153
+ --
154
+ -- Another option besides decorations would be to use a pressure plates with a state of 1, which is
155
+ -- a state that is normally unused by the game and makes it invisible & persistent. However, pickups
156
+ -- will not be able to spawn on pressure plates, which lead to various bugs (e.g. pickups spawning
157
+ -- on top of pits). Thus, using a decoration is preferable.
158
+ --
159
+ -- Yet another option to accomplish this would be to replace the room data with that of an empty
160
+ -- room. However, the room data must exactly match the room type, the room shape, and the doors, so
161
+ -- this is not possible to do in a robust way without adding empty rooms to the mod's `content`
162
+ -- folder to draw the data from.
163
+ function ____exports.preventGridEntityRespawn(self)
164
+ errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
141
165
  local room = game:GetRoom()
142
166
  local roomListIndex = getRoomListIndex(nil)
167
+ v.level.deployedRoomListIndexes:add(roomListIndex)
143
168
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
144
169
  for ____, gridIndex in ipairs(getAllGridIndexes(nil)) do
145
170
  do
146
171
  local existingGridEntity = room:GetGridEntity(gridIndex)
147
172
  if existingGridEntity ~= nil then
148
- goto __continue31
173
+ goto __continue32
149
174
  end
150
- local position = room:GetGridPosition(gridIndex)
151
- local decoration = Isaac.GridSpawn(GridEntityType.DECORATION, 0, position)
175
+ local decoration = spawnGridEntity(nil, GridEntityType.DECORATION, gridIndex)
152
176
  if decoration ~= nil then
153
177
  setGridEntityInvisible(nil, decoration)
154
178
  end
155
179
  decorationGridIndexes[#decorationGridIndexes + 1] = gridIndex
156
180
  end
157
- ::__continue31::
181
+ ::__continue32::
158
182
  end
159
183
  end
160
184
  function spawnAllEntities(self, jsonRoom, rng, verbose)
@@ -411,7 +435,7 @@ function getPitFrame(self, L, R, U, D, UL, UR, DL, DR)
411
435
  end
412
436
  return F
413
437
  end
414
- local FEATURE_NAME = "deployJSONRoom"
438
+ FEATURE_NAME = "deployJSONRoom"
415
439
  PERSISTENT_ENTITY_TYPES = __TS__New(Set, {EntityType.WALL_HUGGER})
416
440
  local gridEntityXMLTypes = getEnumValues(nil, GridEntityXMLType)
417
441
  GRID_ENTITY_XML_TYPE_SET = __TS__New(Set, gridEntityXMLTypes)
@@ -489,7 +513,7 @@ function ____exports.deployJSONRoom(self, jsonRoom, seedOrRNG, verbose)
489
513
  log(nil, "Finished spawning all of the new entities and grid entities.")
490
514
  end
491
515
  fixPitGraphics(nil)
492
- fillRoomWithDecorations(nil)
516
+ ____exports.preventGridEntityRespawn(nil)
493
517
  end
494
518
  --- Helper function to deconstruct a vanilla room and set up a custom room in its place.
495
519
  -- Specifically, this will clear the current room of all entities and grid entities, and then spawn
@@ -59,11 +59,11 @@ local ____gridEntities = require("src.functions.gridEntities")
59
59
  local spawnGridEntity = ____gridEntities.spawnGridEntity
60
60
  local ____levelGrid = require("src.functions.levelGrid")
61
61
  local getRoomGridIndexesForType = ____levelGrid.getRoomGridIndexesForType
62
- local ____log = require("src.functions.log")
63
- local logPlayerEffects = ____log.logPlayerEffects
64
- local logRoom = ____log.logRoom
65
- local logSeedEffects = ____log.logSeedEffects
66
- local logSounds = ____log.logSounds
62
+ local ____logMisc = require("src.functions.logMisc")
63
+ local logPlayerEffects = ____logMisc.logPlayerEffects
64
+ local logRoom = ____logMisc.logRoom
65
+ local logSeedEffects = ____logMisc.logSeedEffects
66
+ local logSounds = ____logMisc.logSounds
67
67
  local ____map = require("src.functions.map")
68
68
  local getMapPartialMatch = ____map.getMapPartialMatch
69
69
  local ____mergeTests = require("src.functions.mergeTests")
@@ -21,8 +21,8 @@ local removeAllProjectiles = ____entitiesSpecific.removeAllProjectiles
21
21
  local removeAllTears = ____entitiesSpecific.removeAllTears
22
22
  local ____isaacAPIClass = require("src.functions.isaacAPIClass")
23
23
  local isTear = ____isaacAPIClass.isTear
24
- local ____log = require("src.functions.log")
25
- local logError = ____log.logError
24
+ local ____logMisc = require("src.functions.logMisc")
25
+ local logError = ____logMisc.logError
26
26
  local ____playerIndex = require("src.functions.playerIndex")
27
27
  local getAllPlayers = ____playerIndex.getAllPlayers
28
28
  local ____players = require("src.functions.players")
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/load.ts"],"names":[],"mappings":";;AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AASrD,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GACpC,IAAI,CAuDN"}
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/load.ts"],"names":[],"mappings":";;AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AASrD,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GACpC,IAAI,CAuDN"}
@@ -6,7 +6,8 @@ local ____jsonHelpers = require("src.functions.jsonHelpers")
6
6
  local jsonDecode = ____jsonHelpers.jsonDecode
7
7
  local ____log = require("src.functions.log")
8
8
  local log = ____log.log
9
- local logError = ____log.logError
9
+ local ____logMisc = require("src.functions.logMisc")
10
+ local logError = ____logMisc.logError
10
11
  local ____table = require("src.functions.table")
11
12
  local iterateTableInOrder = ____table.iterateTableInOrder
12
13
  local ____types = require("src.functions.types")
@@ -16,8 +16,8 @@ local ____SerializationType = require("src.enums.SerializationType")
16
16
  local SerializationType = ____SerializationType.SerializationType
17
17
  local ____deepCopy = require("src.functions.deepCopy")
18
18
  local deepCopy = ____deepCopy.deepCopy
19
- local ____log = require("src.functions.log")
20
- local logError = ____log.logError
19
+ local ____logMisc = require("src.functions.logMisc")
20
+ local logError = ____logMisc.logError
21
21
  local ____stage = require("src.functions.stage")
22
22
  local onFirstFloor = ____stage.onFirstFloor
23
23
  local ____table = require("src.functions.table")
@@ -8,8 +8,8 @@ local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
8
8
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
9
9
  local ____featuresInitialized = require("src.featuresInitialized")
10
10
  local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
11
- local ____log = require("src.functions.log")
12
- local logError = ____log.logError
11
+ local ____logMisc = require("src.functions.logMisc")
12
+ local logError = ____logMisc.logError
13
13
  local ____exports = require("src.features.saveDataManager.exports")
14
14
  local saveDataManager = ____exports.saveDataManager
15
15
  function postPlayerInit(self, player)
@@ -13,4 +13,16 @@
13
13
  * be printed to the log.)
14
14
  */
15
15
  export declare function benchmark(numTrials: int, ...functions: Array<() => void>): int[];
16
+ /**
17
+ * Helper function to get the current time in seconds for benchmarking / profiling purposes.
18
+ *
19
+ * - If the "--luadebug" flag is enabled, then this function will use the `socket.gettime` method,
20
+ * which returns the epoch timestamp in seconds (e.g. "1640320492.5779"). This is preferable over
21
+ * the `Isaac.GetTime` method, since it has one extra decimal point of precision.
22
+ * - If the "--luadebug" flag is disabled, then this function will use the `Isaac.GetTime` method,
23
+ * which returns the number of seconds since the computer's operating system was started (e.g.
24
+ * "739454.963"). (The milliseconds return value of `Isaac.GetTime` is converted to seconds to
25
+ * align with the return value of `socket.gettime`.)
26
+ */
27
+ export declare function getTime(): float;
16
28
  //# sourceMappingURL=benchmark.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"benchmark.d.ts","sourceRoot":"","sources":["../../../src/functions/benchmark.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,GAAG,EACd,GAAG,SAAS,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAC9B,GAAG,EAAE,CAsBP"}
1
+ {"version":3,"file":"benchmark.d.ts","sourceRoot":"","sources":["../../../src/functions/benchmark.ts"],"names":[],"mappings":";AAGA;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,GAAG,EACd,GAAG,SAAS,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAC9B,GAAG,EAAE,CAsBP;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,IAAI,KAAK,CAS/B"}
@@ -1,6 +1,8 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
3
3
  local ____exports = {}
4
+ local ____constants = require("src.core.constants")
5
+ local SECOND_IN_MILLISECONDS = ____constants.SECOND_IN_MILLISECONDS
4
6
  local ____log = require("src.functions.log")
5
7
  local log = ____log.log
6
8
  --- Helper function to benchmark the performance of a function.
@@ -46,4 +48,21 @@ function ____exports.benchmark(self, numTrials, ...)
46
48
  )
47
49
  return averages
48
50
  end
51
+ --- Helper function to get the current time in seconds for benchmarking / profiling purposes.
52
+ --
53
+ -- - If the "--luadebug" flag is enabled, then this function will use the `socket.gettime` method,
54
+ -- which returns the epoch timestamp in seconds (e.g. "1640320492.5779"). This is preferable over
55
+ -- the `Isaac.GetTime` method, since it has one extra decimal point of precision.
56
+ -- - If the "--luadebug" flag is disabled, then this function will use the `Isaac.GetTime` method,
57
+ -- which returns the number of seconds since the computer's operating system was started (e.g.
58
+ -- "739454.963"). (The milliseconds return value of `Isaac.GetTime` is converted to seconds to
59
+ -- align with the return value of `socket.gettime`.)
60
+ function ____exports.getTime(self)
61
+ local ok, requiredSocket = pcall(require, "socket")
62
+ if ok then
63
+ local socket = requiredSocket
64
+ return socket.gettime()
65
+ end
66
+ return Isaac.GetTime() / SECOND_IN_MILLISECONDS
67
+ end
49
68
  return ____exports
@@ -46,6 +46,7 @@ export declare function isLuaDebugEnabled(): boolean;
46
46
  * This is useful when printing out variables from the in-game debug console.
47
47
  */
48
48
  export declare function setLogFunctionsGlobal(): void;
49
+ export declare function setTracebackFunctionsGlobal(): void;
49
50
  /**
50
51
  * Helper function to print a stack trace to the "log.txt" file, similar to JavaScript's
51
52
  * `console.trace` function.
@@ -1 +1 @@
1
- {"version":3,"file":"debugFunctions.d.ts","sourceRoot":"","sources":["../../../src/functions/debugFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AASrD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAYrC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAI3C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAU5C;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAGhC"}
1
+ {"version":3,"file":"debugFunctions.d.ts","sourceRoot":"","sources":["../../../src/functions/debugFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAUrD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAOxD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAYrC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAI3C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAS5C;AAED,wBAAgB,2BAA2B,IAAI,IAAI,CAKlD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAGhC"}
@@ -1,7 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
3
3
  local ____exports = {}
4
- local setDebugFunctionsGlobal
5
4
  local ____exports = require("src.features.extraConsoleCommands.exports")
6
5
  local enableExtraConsoleCommands = ____exports.enableExtraConsoleCommands
7
6
  local ____fadeInRemover = require("src.features.fadeInRemover")
@@ -14,6 +13,7 @@ local logExports = require("src.functions.log")
14
13
  local ____log = require("src.functions.log")
15
14
  local log = ____log.log
16
15
  local logEntitiesExports = require("src.functions.logEntities")
16
+ local logMiscExports = require("src.functions.logMisc")
17
17
  --- Helper function to get a stack trace.
18
18
  --
19
19
  -- This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
@@ -22,8 +22,8 @@ function ____exports.getTraceback(self)
22
22
  if debug ~= nil then
23
23
  return debug.traceback()
24
24
  end
25
- if sandboxGetTraceback ~= nil then
26
- return sandboxGetTraceback()
25
+ if SandboxGetTraceback ~= nil then
26
+ return SandboxGetTraceback()
27
27
  end
28
28
  return "stack traceback:\n(the \"--luadebug\" flag is not enabled)"
29
29
  end
@@ -32,17 +32,19 @@ end
32
32
  -- This is useful when printing out variables from the in-game debug console.
33
33
  function ____exports.setLogFunctionsGlobal(self)
34
34
  local globals = _G
35
- for ____, ____value in ipairs(__TS__ObjectEntries(logExports)) do
36
- local logFuncName = ____value[1]
37
- local logFunc = ____value[2]
38
- globals[logFuncName] = logFunc
39
- end
40
- for ____, ____value in ipairs(__TS__ObjectEntries(logEntitiesExports)) do
41
- local logFuncName = ____value[1]
42
- local logFunc = ____value[2]
43
- globals[logFuncName] = logFunc
35
+ for ____, exports in ipairs({logExports, logMiscExports, logEntitiesExports}) do
36
+ for ____, ____value in ipairs(__TS__ObjectEntries(exports)) do
37
+ local logFuncName = ____value[1]
38
+ local logFunc = ____value[2]
39
+ globals[logFuncName] = logFunc
40
+ end
44
41
  end
45
42
  end
43
+ function ____exports.setTracebackFunctionsGlobal(self)
44
+ local globals = _G
45
+ globals.getTraceback = ____exports.getTraceback
46
+ globals.traceback = ____exports.traceback
47
+ end
46
48
  --- Helper function to print a stack trace to the "log.txt" file, similar to JavaScript's
47
49
  -- `console.trace` function.
48
50
  --
@@ -52,14 +54,6 @@ function ____exports.traceback(self)
52
54
  local tracebackOutput = ____exports.getTraceback(nil)
53
55
  log(nil, tracebackOutput)
54
56
  end
55
- function setDebugFunctionsGlobal(self)
56
- if _G.debug == nil and sandboxGetTraceback == nil then
57
- return
58
- end
59
- local globals = _G
60
- globals.getTraceback = ____exports.getTraceback
61
- globals.traceback = ____exports.traceback
62
- end
63
57
  --- Helper function to enable some IsaacScript features that are useful when developing a mod. They
64
58
  -- should not be enabled when your mod goes to production (i.e. when it is uploaded to the Steam
65
59
  -- Workshop).
@@ -78,6 +72,7 @@ end
78
72
  function ____exports.enableDevFeatures(self, mod)
79
73
  saveDataManagerSetGlobal(nil)
80
74
  ____exports.setLogFunctionsGlobal(nil)
75
+ ____exports.setTracebackFunctionsGlobal(nil)
81
76
  enableExtraConsoleCommands(nil, mod)
82
77
  enableFastReset(nil)
83
78
  removeFadeIn(nil)
@@ -98,7 +93,4 @@ end
98
93
  function ____exports.isLuaDebugEnabled(self)
99
94
  return _G.package ~= nil
100
95
  end
101
- if ____exports.isLuaDebugEnabled(nil) or sandboxGetTraceback ~= nil then
102
- setDebugFunctionsGlobal(nil)
103
- end
104
96
  return ____exports
@@ -15,7 +15,7 @@ local copySet = ____set.copySet
15
15
  local ____utils = require("src.functions.utils")
16
16
  local twoDimensionalSort = ____utils.twoDimensionalSort
17
17
  function isRacingPlusSandboxEnabled(self)
18
- return getParentFunctionDescription ~= nil
18
+ return SandboxGetParentFunctionDescription ~= nil
19
19
  end
20
20
  local DEFAULT_GLOBALS = __TS__New(Set, {
21
21
  "ActionTriggers",
@@ -3,8 +3,8 @@ local __TS__StringReplace = ____lualib.__TS__StringReplace
3
3
  local __TS__StringSubstring = ____lualib.__TS__StringSubstring
4
4
  local ____exports = {}
5
5
  local hexToRGB, HEX_STRING_LENGTH
6
- local ____log = require("src.functions.log")
7
- local logError = ____log.logError
6
+ local ____logMisc = require("src.functions.logMisc")
7
+ local logError = ____logMisc.logError
8
8
  function hexToRGB(self, hexString)
9
9
  hexString = __TS__StringReplace(hexString, "#", "")
10
10
  if #hexString ~= HEX_STRING_LENGTH then
@@ -1,7 +1,7 @@
1
1
  local ____exports = {}
2
2
  local jsonLua = require("src.lib.jsonLua")
3
- local ____log = require("src.functions.log")
4
- local logError = ____log.logError
3
+ local ____logMisc = require("src.functions.logMisc")
4
+ local logError = ____logMisc.logError
5
5
  local function tryDecode(jsonString)
6
6
  return jsonLua.decode(jsonString)
7
7
  end