isaacscript-common 20.12.2 → 20.13.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 (67) hide show
  1. package/dist/index.d.ts +79 -40
  2. package/dist/isaacscript-common.lua +315 -419
  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/enums/MysteriousPaperEffect.d.ts +13 -0
  19. package/dist/src/enums/MysteriousPaperEffect.d.ts.map +1 -0
  20. package/dist/src/enums/MysteriousPaperEffect.lua +15 -0
  21. package/dist/src/functions/benchmark.lua +2 -8
  22. package/dist/src/functions/debugFunctions.d.ts +2 -2
  23. package/dist/src/functions/debugFunctions.d.ts.map +1 -1
  24. package/dist/src/functions/debugFunctions.lua +4 -4
  25. package/dist/src/functions/deepCopy.lua +7 -7
  26. package/dist/src/functions/deepCopyTests.lua +1 -1
  27. package/dist/src/functions/globals.lua +3 -6
  28. package/dist/src/functions/hex.lua +4 -7
  29. package/dist/src/functions/jsonHelpers.lua +1 -1
  30. package/dist/src/functions/jsonRoom.lua +4 -16
  31. package/dist/src/functions/log.d.ts +8 -4
  32. package/dist/src/functions/log.d.ts.map +1 -1
  33. package/dist/src/functions/log.lua +18 -5
  34. package/dist/src/functions/logEntities.d.ts +8 -8
  35. package/dist/src/functions/logEntities.d.ts.map +1 -1
  36. package/dist/src/functions/logEntities.lua +24 -27
  37. package/dist/src/functions/logMisc.d.ts +26 -26
  38. package/dist/src/functions/logMisc.d.ts.map +1 -1
  39. package/dist/src/functions/logMisc.lua +114 -226
  40. package/dist/src/functions/merge.lua +6 -6
  41. package/dist/src/functions/revive.d.ts.map +1 -1
  42. package/dist/src/functions/revive.lua +10 -3
  43. package/dist/src/functions/run.lua +2 -5
  44. package/dist/src/functions/trinkets.d.ts +22 -0
  45. package/dist/src/functions/trinkets.d.ts.map +1 -1
  46. package/dist/src/functions/trinkets.lua +32 -0
  47. package/dist/src/functions/utils.d.ts.map +1 -1
  48. package/dist/src/functions/utils.lua +20 -1
  49. package/dist/src/index.d.ts +1 -0
  50. package/dist/src/index.d.ts.map +1 -1
  51. package/dist/src/index.lua +8 -0
  52. package/dist/src/lib/jsonLua.lua +16 -7
  53. package/dist/src/patchErrorFunctions.lua +1 -1
  54. package/package.json +1 -1
  55. package/src/classes/ModFeature.ts +0 -6
  56. package/src/classes/features/other/saveDataManager/saveToDisk.ts +3 -4
  57. package/src/enums/MysteriousPaperEffect.ts +12 -0
  58. package/src/functions/debugFunctions.ts +2 -2
  59. package/src/functions/deepCopy.ts +2 -0
  60. package/src/functions/log.ts +15 -4
  61. package/src/functions/logEntities.ts +14 -8
  62. package/src/functions/logMisc.ts +56 -39
  63. package/src/functions/revive.ts +12 -4
  64. package/src/functions/trinkets.ts +39 -0
  65. package/src/functions/utils.ts +30 -0
  66. package/src/index.ts +1 -0
  67. package/src/lib/jsonLua.lua +16 -7
@@ -44,7 +44,7 @@ end
44
44
  function ____exports.restart(self, character)
45
45
  if character == nil then
46
46
  local command = "restart"
47
- log(nil, "Restarting the run with a console command of: " .. command)
47
+ log("Restarting the run with a console command of: " .. command)
48
48
  Isaac.ExecuteCommand(command)
49
49
  return
50
50
  end
@@ -52,10 +52,7 @@ function ____exports.restart(self, character)
52
52
  error(("Restarting as a character of " .. tostring(character)) .. " would crash the game.")
53
53
  end
54
54
  local command = "restart " .. tostring(character)
55
- log(
56
- nil,
57
- (((("Restarting the run as PlayerType." .. PlayerType[character]) .. " (") .. tostring(character)) .. ") with a console command of: ") .. command
58
- )
55
+ log((((("Restarting the run as PlayerType." .. PlayerType[character]) .. " (") .. tostring(character)) .. ") with a console command of: ") .. command)
59
56
  Isaac.ExecuteCommand(command)
60
57
  end
61
58
  --- Helper function to change the run status to that of an unseeded run with a new random seed.
@@ -1,4 +1,5 @@
1
1
  import { CacheFlag, TrinketType } from "isaac-typescript-definitions";
2
+ import { MysteriousPaperEffect } from "../enums/MysteriousPaperEffect";
2
3
  /**
3
4
  * Helper function to get the corresponding golden trinket type from a normal trinket type.
4
5
  *
@@ -6,6 +7,27 @@ import { CacheFlag, TrinketType } from "isaac-typescript-definitions";
6
7
  * corresponds to the golden trinket sub-type for Swallowed Penny.
7
8
  */
8
9
  export declare function getGoldenTrinketType(trinketType: TrinketType): TrinketType;
10
+ /**
11
+ * Helper function to get the current effect that the Mysterious Paper trinket is providing to the
12
+ * player. Returns undefined if the player does not have the Mysterious Paper trinket.
13
+ *
14
+ * The Mysterious Paper trinket has four different effects:
15
+ *
16
+ * - The Polaroid (collectible)
17
+ * - The Negative (collectible)
18
+ * - A Missing Page (trinket)
19
+ * - Missing Poster (trinket)
20
+ *
21
+ * It rotates between these four effects on every frame. Note that Mysterious Paper will cause the
22
+ * `EntityPlayer.HasCollectible` and `EntityPlayer.HasTrinket` methods to return true for the
23
+ * respective items on the particular frame, with the exception of the Missing Poster. (The player
24
+ * will never "have" the Missing Poster, even on the correct corresponding frame.)
25
+ *
26
+ * @param player The player to look at.
27
+ * @param frameCount Optional. The frame count that corresponds to time the effect will be active.
28
+ * Default is the current frame.
29
+ */
30
+ export declare function getMysteriousPaperEffectForFrame(player: EntityPlayer, frameCount?: int): MysteriousPaperEffect | undefined;
9
31
  /**
10
32
  * Returns the slot number corresponding to where a trinket can be safely inserted.
11
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"trinkets.d.ts","sourceRoot":"","sources":["../../../src/functions/trinkets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAGT,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAmCtC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAE1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,GAAG,GAAG,SAAS,CAkBxE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CActE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAOtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAc/D;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,IAAI,WAAW,EAAE,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAOhE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAYjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OA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E,WAAW,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAYjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAiBN;AAED,6FAA6F;AAC7F,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,OAAO,CAOT"}
@@ -10,6 +10,8 @@ local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
10
10
  local ____constantsFirstLast = require("src.core.constantsFirstLast")
11
11
  local FIRST_TRINKET_TYPE = ____constantsFirstLast.FIRST_TRINKET_TYPE
12
12
  local LAST_VANILLA_TRINKET_TYPE = ____constantsFirstLast.LAST_VANILLA_TRINKET_TYPE
13
+ local ____MysteriousPaperEffect = require("src.enums.MysteriousPaperEffect")
14
+ local MysteriousPaperEffect = ____MysteriousPaperEffect.MysteriousPaperEffect
13
15
  local ____trinketDescriptionMap = require("src.maps.trinketDescriptionMap")
14
16
  local DEFAULT_TRINKET_DESCRIPTION = ____trinketDescriptionMap.DEFAULT_TRINKET_DESCRIPTION
15
17
  local TRINKET_DESCRIPTION_MAP = ____trinketDescriptionMap.TRINKET_DESCRIPTION_MAP
@@ -18,6 +20,8 @@ local DEFAULT_TRINKET_NAME = ____trinketTypeToNameMap.DEFAULT_TRINKET_NAME
18
20
  local TRINKET_TYPE_TO_NAME_MAP = ____trinketTypeToNameMap.TRINKET_TYPE_TO_NAME_MAP
19
21
  local ____entities = require("src.functions.entities")
20
22
  local getEntityID = ____entities.getEntityID
23
+ local ____enums = require("src.functions.enums")
24
+ local getEnumLength = ____enums.getEnumLength
21
25
  local ____flag = require("src.functions.flag")
22
26
  local hasFlag = ____flag.hasFlag
23
27
  local ____pickupVariants = require("src.functions.pickupVariants")
@@ -39,6 +43,7 @@ end
39
43
  --
40
44
  -- 1 << 15
41
45
  local GOLDEN_TRINKET_ADJUSTMENT = 32768
46
+ local NUM_MYSTERIOUS_PAPER_EFFECTS = getEnumLength(nil, MysteriousPaperEffect)
42
47
  local TRINKET_ANM2_PATH = "gfx/005.350_trinket.anm2"
43
48
  local TRINKET_SPRITE_LAYER = 0
44
49
  --- Helper function to get the corresponding golden trinket type from a normal trinket type.
@@ -48,6 +53,33 @@ local TRINKET_SPRITE_LAYER = 0
48
53
  function ____exports.getGoldenTrinketType(self, trinketType)
49
54
  return asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
50
55
  end
56
+ --- Helper function to get the current effect that the Mysterious Paper trinket is providing to the
57
+ -- player. Returns undefined if the player does not have the Mysterious Paper trinket.
58
+ --
59
+ -- The Mysterious Paper trinket has four different effects:
60
+ --
61
+ -- - The Polaroid (collectible)
62
+ -- - The Negative (collectible)
63
+ -- - A Missing Page (trinket)
64
+ -- - Missing Poster (trinket)
65
+ --
66
+ -- It rotates between these four effects on every frame. Note that Mysterious Paper will cause the
67
+ -- `EntityPlayer.HasCollectible` and `EntityPlayer.HasTrinket` methods to return true for the
68
+ -- respective items on the particular frame, with the exception of the Missing Poster. (The player
69
+ -- will never "have" the Missing Poster, even on the correct corresponding frame.)
70
+ --
71
+ -- @param player The player to look at.
72
+ -- @param frameCount Optional. The frame count that corresponds to time the effect will be active.
73
+ -- Default is the current frame.
74
+ function ____exports.getMysteriousPaperEffectForFrame(self, player, frameCount)
75
+ if frameCount == nil then
76
+ frameCount = player.FrameCount
77
+ end
78
+ if not player:HasTrinket(TrinketType.MYSTERIOUS_PAPER) then
79
+ return nil
80
+ end
81
+ return frameCount % NUM_MYSTERIOUS_PAPER_EFFECTS
82
+ end
51
83
  --- Returns the slot number corresponding to where a trinket can be safely inserted.
52
84
  --
53
85
  -- For example:
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/functions/utils.ts"],"names":[],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AAI,GAAG,IAAI,CAI3D;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAG;AAEjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAmD1E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAE1C,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAC/B,IAAI,SAAS,MAAM,GAAG,MAAM,KACzB,IAAI,CAAG"}
@@ -94,7 +94,7 @@ end
94
94
  --- Helper function to log a message to the "log.txt" file and to print it to the screen at the same
95
95
  -- time.
96
96
  function ____exports.logAndPrint(self, msg)
97
- log(nil, msg)
97
+ log(msg)
98
98
  print(msg)
99
99
  end
100
100
  --- Helper function to print whether something was enabled or disabled to the in-game console.
@@ -154,6 +154,20 @@ end
154
154
  -- From:
155
155
  -- https://stackoverflow.com/questions/16096872/how-to-sort-2-dimensional-array-by-column-value
156
156
  function ____exports.twoDimensionalSort(self, array1, array2)
157
+ local type1 = type(array1)
158
+ local type2 = type(array2)
159
+ if type1 ~= type2 then
160
+ error(((((((("Failed to two-dimensional sort since the two elements were disparate types: " .. tostring(array1)) .. " & ") .. tostring(array2)) .. " (") .. type1) .. " & ") .. type2) .. ")")
161
+ end
162
+ if type1 == "string" or type1 == "number" then
163
+ if array1 == array2 then
164
+ return 0
165
+ end
166
+ return array1 < array2 and -1 or 1
167
+ end
168
+ if type1 ~= "table" then
169
+ error("Failed to two-dimensional sort since the elements were not a string, number, or table.")
170
+ end
157
171
  local firstElement1 = array1[1]
158
172
  local firstElement2 = array2[1]
159
173
  if firstElement1 == nil or firstElement1 == nil then
@@ -162,6 +176,11 @@ function ____exports.twoDimensionalSort(self, array1, array2)
162
176
  if firstElement2 == nil or firstElement2 == nil then
163
177
  error("Failed to two-dimensional sort since the first element of the second array was undefined.")
164
178
  end
179
+ local elementType1 = type(firstElement1)
180
+ local elementType2 = type(firstElement2)
181
+ if elementType1 ~= elementType2 then
182
+ error(((((((("Failed to two-dimensional sort since the first element of each array were disparate types: " .. tostring(firstElement1)) .. " & ") .. tostring(firstElement2)) .. " (") .. elementType1) .. " & ") .. elementType2) .. ")")
183
+ end
165
184
  if firstElement1 == firstElement2 then
166
185
  return 0
167
186
  end
@@ -11,6 +11,7 @@ export * from "./enums/HealthType";
11
11
  export * from "./enums/ISCFeature";
12
12
  export * from "./enums/LadderSubTypeCustom";
13
13
  export * from "./enums/ModCallbackCustom";
14
+ export * from "./enums/MysteriousPaperEffect";
14
15
  export * from "./enums/PocketItemType";
15
16
  export * from "./enums/RockAltType";
16
17
  export * from "./enums/SaveDataKey";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC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AAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
@@ -103,6 +103,14 @@ do
103
103
  end
104
104
  end
105
105
  end
106
+ do
107
+ local ____export = require("src.enums.MysteriousPaperEffect")
108
+ for ____exportKey, ____exportValue in pairs(____export) do
109
+ if ____exportKey ~= "default" then
110
+ ____exports[____exportKey] = ____exportValue
111
+ end
112
+ end
113
+ end
106
114
  do
107
115
  local ____export = require("src.enums.PocketItemType")
108
116
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -24,6 +24,9 @@
24
24
  -- SOFTWARE.
25
25
  --
26
26
 
27
+ -- The IsaacScript version of this file contains modifications for better error messages, which
28
+ -- assist when debugging.
29
+
27
30
  local json = { _version = "0.1.2" }
28
31
 
29
32
  -------------------------------------------------------------------------------
@@ -58,9 +61,10 @@ local function encode_nil(val)
58
61
  end
59
62
 
60
63
 
61
- local function encode_table(val, stack)
64
+ local function encode_table(val, stack, traversalDescription)
62
65
  local res = {}
63
66
  stack = stack or {}
67
+ traversalDescription = traversalDescription or ""
64
68
 
65
69
  -- Circular reference?
66
70
  if stack[val] then error("circular reference") end
@@ -72,7 +76,7 @@ local function encode_table(val, stack)
72
76
  local n = 0
73
77
  for k in pairs(val) do
74
78
  if type(k) ~= "number" then
75
- error("invalid table: mixed or invalid key types")
79
+ error("invalid table: mixed or invalid key types for array, excepted number, got: " .. tostring(type(k)))
76
80
  end
77
81
  n = n + 1
78
82
  end
@@ -81,7 +85,8 @@ local function encode_table(val, stack)
81
85
  end
82
86
  -- Encode
83
87
  for i, v in ipairs(val) do
84
- table.insert(res, encode(v, stack))
88
+ local newTraversalDescription = traversalDescription .. tostring(i) .. " - "
89
+ table.insert(res, encode(v, stack, newTraversalDescription))
85
90
  end
86
91
  stack[val] = nil
87
92
  return "[" .. table.concat(res, ",") .. "]"
@@ -89,10 +94,14 @@ local function encode_table(val, stack)
89
94
  else
90
95
  -- Treat as an object
91
96
  for k, v in pairs(val) do
97
+ local newTraversalDescription = traversalDescription .. tostring(k) .. " - "
92
98
  if type(k) ~= "string" then
93
- error("invalid table: mixed or invalid key types")
99
+ error(
100
+ "invalid table: mixed or invalid key types for object \"" .. newTraversalDescription .. "\", "
101
+ .. "excepted string, got: " .. tostring(type(k))
102
+ )
94
103
  end
95
- table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
104
+ table.insert(res, encode(k, stack, newTraversalDescription) .. ":" .. encode(v, stack, newTraversalDescription))
96
105
  end
97
106
  stack[val] = nil
98
107
  return "{" .. table.concat(res, ",") .. "}"
@@ -123,11 +132,11 @@ local type_func_map = {
123
132
  }
124
133
 
125
134
 
126
- encode = function(val, stack)
135
+ encode = function(val, stack, traversalDescription)
127
136
  local t = type(val)
128
137
  local f = type_func_map[t]
129
138
  if f then
130
- return f(val, stack)
139
+ return f(val, stack, traversalDescription)
131
140
  end
132
141
  error("unexpected type '" .. t .. "'")
133
142
  end
@@ -14,7 +14,7 @@ function errorWithTraceback(message, level)
14
14
  if level == nil then
15
15
  level = 1
16
16
  end
17
- local tracebackOutput = getTraceback(nil)
17
+ local tracebackOutput = getTraceback()
18
18
  local slimmedTracebackOutput = slimTracebackOutput(nil, tracebackOutput)
19
19
  message = message .. "\n"
20
20
  message = message .. slimmedTracebackOutput
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "20.12.2",
3
+ "version": "20.13.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -330,18 +330,12 @@ function initSaveDataManager(
330
330
  tstlClassName: string,
331
331
  init: boolean,
332
332
  ) {
333
- if (tstlClassName === "AtePoopBaby") {
334
- Isaac.DebugString("GETTING HERE 1");
335
- }
336
-
337
333
  // Do nothing if this class does not have any variables.
338
334
  const { v } = modFeature as unknown as Record<string, unknown>;
339
335
  if (v === undefined) {
340
336
  return;
341
337
  }
342
338
 
343
- Isaac.DebugString("GETTING HERE 2");
344
-
345
339
  if (!isTable(v)) {
346
340
  error(
347
341
  'Failed to initialize a mod feature class due to having a "v" property that is not an object. (The "v" property is supposed to be an object that holds the variables for the class, managed by the save data manager.)',
@@ -16,7 +16,7 @@ export function saveToDisk(
16
16
  saveDataConditionalFuncMap,
17
17
  );
18
18
  const jsonString = jsonEncode(allSaveData);
19
- mod.SaveData(jsonString); // Write it to the "save#.dat" file
19
+ mod.SaveData(jsonString);
20
20
  log('The save data manager wrote data to the "save#.dat" file.');
21
21
  }
22
22
 
@@ -52,9 +52,8 @@ function getAllSaveDataToWriteToDisk(
52
52
  return;
53
53
  }
54
54
 
55
- // If we encode TypeScriptToLua Maps into JSON, it will result in a lot of extraneous data
56
- // that is unnecessary. Make a copy of the data and recursively convert all TypeScriptToLua
57
- // Maps into Lua tables.
55
+ // We need to serialize TypeScriptToLua maps and Isaac API objects such as `Color`.
56
+ // Recursively convert all such objects to Lua tables.
58
57
  const saveDataCopy = deepCopy(
59
58
  saveDataWithoutRoom,
60
59
  SerializationType.SERIALIZE,
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The possible effects that the Mysterious Paper trinket can grant.
3
+ *
4
+ * This enum has hard-coded values because they correspond to the specific in-game frame count of
5
+ * the player.
6
+ */
7
+ export enum MysteriousPaperEffect {
8
+ POLAROID = 0,
9
+ NEGATIVE = 1,
10
+ MISSING_PAGE = 2,
11
+ MISSING_POSTER = 3,
12
+ }
@@ -45,7 +45,7 @@ export function getTime(useSocketIfAvailable = true): float {
45
45
  * This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
46
46
  * enabled.
47
47
  */
48
- export function getTraceback(): string {
48
+ export function getTraceback(this: void): string {
49
49
  if (SandboxGetTraceback !== undefined) {
50
50
  return SandboxGetTraceback();
51
51
  }
@@ -88,7 +88,7 @@ export function isLuaDebugEnabled(): boolean {
88
88
  * This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
89
89
  * enabled.
90
90
  */
91
- export function traceback(): void {
91
+ export function traceback(this: void): void {
92
92
  const tracebackOutput = getTraceback();
93
93
  log(tracebackOutput);
94
94
  }
@@ -615,6 +615,8 @@ function deepCopyNormalLuaTable(
615
615
  /**
616
616
  * Recursively clones the object's entries, automatically converting number keys to strings, if
617
617
  * necessary.
618
+ *
619
+ * This should work on objects/tables, maps, sets, default maps, and classes.
618
620
  */
619
621
  function getCopiedEntries(
620
622
  object: unknown,
@@ -9,6 +9,7 @@
9
9
  * function, and the third level is the parent of the calling function).
10
10
  */
11
11
  export function getParentFunctionDescription(
12
+ this: void,
12
13
  // We use 3 as a default because:
13
14
  // - The first level is this function.
14
15
  // - The second level is the calling function.
@@ -36,8 +37,8 @@ export function getParentFunctionDescription(
36
37
  /**
37
38
  * Helper function to avoid typing out `Isaac.DebugString()`.
38
39
  *
39
- * If you have the "--luadebug" launch flag turned on or the Racing+ sandbox enabled, then this
40
- * function will also prepend the function name and the line number before the string, like this:
40
+ * If you have the "--luadebug" launch flag turned on, then this function will also prepend the
41
+ * function name and the line number before the string, like this:
41
42
  *
42
43
  * ```text
43
44
  * [INFO] - Lua Debug: saveToDisk:42494 - The save data manager wrote data to the "save#.dat" file.
@@ -45,9 +46,19 @@ export function getParentFunctionDescription(
45
46
  *
46
47
  * Subsequently, it is recommended that you turn on the "--luadebug" launch flag when developing
47
48
  * your mod so that debugging becomes a little bit easier.
49
+ *
50
+ * @param msg The message to log.
51
+ * @param includeParentFunction Optional. Whether to prefix the message with the function name and
52
+ * line number, as shown in the above example. Default is true.
48
53
  */
49
- export function log(msg: string): void {
50
- const parentFunctionDescription = getParentFunctionDescription();
54
+ export function log(
55
+ this: void,
56
+ msg: string,
57
+ includeParentFunction = true,
58
+ ): void {
59
+ const parentFunctionDescription = includeParentFunction
60
+ ? getParentFunctionDescription()
61
+ : undefined;
51
62
  const debugMsg =
52
63
  parentFunctionDescription === undefined
53
64
  ? msg
@@ -29,6 +29,7 @@ const IGNORE_EFFECT_VARIANTS: ReadonlySet<EffectVariant> = new Set([
29
29
 
30
30
  /** Helper function for printing out every entity (or filtered entity) in the current room. */
31
31
  export function logAllEntities(
32
+ this: void,
32
33
  includeBackgroundEffects: boolean,
33
34
  entityTypeFilter?: EntityType,
34
35
  ): void {
@@ -83,6 +84,7 @@ export function logAllEntities(
83
84
  * Default is undefined.
84
85
  */
85
86
  export function logAllGridEntities(
87
+ this: void,
86
88
  includeWalls = false,
87
89
  gridEntityTypeFilter?: GridEntityType,
88
90
  ): void {
@@ -136,19 +138,19 @@ export function logAllGridEntities(
136
138
  }
137
139
 
138
140
  /** Helper function for logging an array of specific entities. */
139
- export function logEntities(entities: Entity[]): void {
141
+ export function logEntities(this: void, entities: Entity[]): void {
140
142
  for (const entity of entities) {
141
143
  logEntity(entity);
142
144
  }
143
145
  }
144
146
 
145
147
  /** Helper function to log information about a specific entity. */
146
- export function logEntity(entity: Entity): void {
148
+ export function logEntity(this: void, entity: Entity): void {
147
149
  const msg = getEntityLogLine(entity);
148
150
  log(msg);
149
151
  }
150
152
 
151
- function getEntityLogLine(entity: Entity, num?: int): string {
153
+ function getEntityLogLine(this: void, entity: Entity, num?: int): string {
152
154
  let msg = num === undefined ? "" : `${num}) `;
153
155
 
154
156
  msg += getEntityID(entity);
@@ -230,19 +232,23 @@ function getEntityLogLine(entity: Entity, num?: int): string {
230
232
  }
231
233
 
232
234
  /** Helper function for logging an array of specific grid entities. */
233
- export function logGridEntities(gridEntities: GridEntity[]): void {
235
+ export function logGridEntities(this: void, gridEntities: GridEntity[]): void {
234
236
  for (const gridEntity of gridEntities) {
235
237
  logGridEntity(gridEntity);
236
238
  }
237
239
  }
238
240
 
239
241
  /** Helper function for log information about a specific grid entity. */
240
- export function logGridEntity(gridEntity: GridEntity): void {
242
+ export function logGridEntity(this: void, gridEntity: GridEntity): void {
241
243
  const msg = getGridEntityLogLine(gridEntity);
242
244
  log(msg);
243
245
  }
244
246
 
245
- function getGridEntityLogLine(gridEntity: GridEntity, num?: int): string {
247
+ function getGridEntityLogLine(
248
+ this: void,
249
+ gridEntity: GridEntity,
250
+ num?: int,
251
+ ): string {
246
252
  const gridEntityDesc = gridEntity.GetSaveState();
247
253
 
248
254
  let msg = num === undefined ? "" : `${num}) `;
@@ -303,7 +309,7 @@ function getGridEntityLogLine(gridEntity: GridEntity, num?: int): string {
303
309
  * Helper function to log information about the entity that corresponding to a pointer hash. (Only
304
310
  * use this when debugging, since retrieving the corresponding entity is expensive.)
305
311
  */
306
- export function logPtrHash(ptrHash: PtrHash): void {
312
+ export function logPtrHash(this: void, ptrHash: PtrHash): void {
307
313
  log(`PtrHash: ${ptrHash}`);
308
314
  const entity = getEntityFromPtrHash(ptrHash);
309
315
  if (entity === undefined) {
@@ -317,7 +323,7 @@ export function logPtrHash(ptrHash: PtrHash): void {
317
323
  * Helper function to log information about the entity that corresponding to one or more pointer
318
324
  * hashes. (Only use this when debugging, since retrieving the corresponding entity is expensive.)
319
325
  */
320
- export function logPtrHashes(ptrHashes: PtrHash[]): void {
326
+ export function logPtrHashes(this: void, ptrHashes: PtrHash[]): void {
321
327
  for (const ptrHash of ptrHashes) {
322
328
  logPtrHash(ptrHash);
323
329
  }