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.
- package/dist/index.d.ts +44 -40
- package/dist/isaacscript-common.lua +262 -416
- package/dist/src/classes/ModFeature.lua +0 -4
- package/dist/src/classes/ModUpgradedBase.lua +3 -9
- package/dist/src/classes/callbacks/PostNewRoomEarly.lua +2 -2
- package/dist/src/classes/features/callbackLogic/CustomRevive.lua +2 -5
- package/dist/src/classes/features/other/CustomStages.lua +4 -16
- package/dist/src/classes/features/other/CustomTrapdoors.lua +1 -4
- package/dist/src/classes/features/other/DeployJSONRoom.lua +8 -14
- package/dist/src/classes/features/other/Pause.lua +2 -2
- package/dist/src/classes/features/other/TaintedLazarusPlayers.lua +1 -1
- package/dist/src/classes/features/other/customStages/utils.lua +4 -16
- package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +4 -4
- package/dist/src/classes/features/other/extraConsoleCommands/subroutines.lua +2 -2
- package/dist/src/classes/features/other/saveDataManager/loadFromDisk.lua +4 -7
- package/dist/src/classes/features/other/saveDataManager/restoreDefaults.lua +2 -2
- package/dist/src/classes/features/other/saveDataManager/saveToDisk.lua +1 -1
- package/dist/src/functions/benchmark.lua +2 -8
- package/dist/src/functions/debugFunctions.d.ts +2 -2
- package/dist/src/functions/debugFunctions.d.ts.map +1 -1
- package/dist/src/functions/debugFunctions.lua +4 -4
- package/dist/src/functions/deepCopy.lua +7 -7
- package/dist/src/functions/deepCopyTests.lua +1 -1
- package/dist/src/functions/globals.lua +3 -6
- package/dist/src/functions/hex.lua +4 -7
- package/dist/src/functions/jsonHelpers.lua +1 -1
- package/dist/src/functions/jsonRoom.lua +4 -16
- package/dist/src/functions/log.d.ts +8 -4
- package/dist/src/functions/log.d.ts.map +1 -1
- package/dist/src/functions/log.lua +18 -5
- package/dist/src/functions/logEntities.d.ts +8 -8
- package/dist/src/functions/logEntities.d.ts.map +1 -1
- package/dist/src/functions/logEntities.lua +24 -27
- package/dist/src/functions/logMisc.d.ts +26 -26
- package/dist/src/functions/logMisc.d.ts.map +1 -1
- package/dist/src/functions/logMisc.lua +114 -226
- package/dist/src/functions/merge.lua +6 -6
- package/dist/src/functions/run.lua +2 -5
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +20 -1
- package/dist/src/lib/jsonLua.lua +16 -7
- package/dist/src/patchErrorFunctions.lua +1 -1
- package/package.json +1 -1
- package/src/classes/ModFeature.ts +0 -6
- package/src/classes/features/other/saveDataManager/saveToDisk.ts +3 -4
- package/src/functions/debugFunctions.ts +2 -2
- package/src/functions/deepCopy.ts +2 -0
- package/src/functions/log.ts +15 -4
- package/src/functions/logEntities.ts +14 -8
- package/src/functions/logMisc.ts +56 -39
- package/src/functions/utils.ts +30 -0
- package/src/lib/jsonLua.lua +16 -7
package/src/lib/jsonLua.lua
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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
|