isaacscript-common 20.12.2 → 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 (52) hide show
  1. package/dist/index.d.ts +44 -40
  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/run.lua +2 -5
  39. package/dist/src/functions/utils.d.ts.map +1 -1
  40. package/dist/src/functions/utils.lua +20 -1
  41. package/dist/src/lib/jsonLua.lua +16 -7
  42. package/dist/src/patchErrorFunctions.lua +1 -1
  43. package/package.json +1 -1
  44. package/src/classes/ModFeature.ts +0 -6
  45. package/src/classes/features/other/saveDataManager/saveToDisk.ts +3 -4
  46. package/src/functions/debugFunctions.ts +2 -2
  47. package/src/functions/deepCopy.ts +2 -0
  48. package/src/functions/log.ts +15 -4
  49. package/src/functions/logEntities.ts +14 -8
  50. package/src/functions/logMisc.ts +56 -39
  51. package/src/functions/utils.ts +30 -0
  52. package/src/lib/jsonLua.lua +16 -7
@@ -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