isaacscript-common 13.2.0 → 13.3.1
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 +37 -8
- package/dist/isaacscript-common.lua +6695 -6631
- package/dist/src/callbacks/customRevive.d.ts.map +1 -1
- package/dist/src/callbacks/customRevive.lua +2 -1
- package/dist/src/callbacks/postNewRoomEarly.lua +2 -2
- package/dist/src/classes/ModUpgraded.d.ts +5 -2
- package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
- package/dist/src/classes/ModUpgraded.lua +39 -3
- package/dist/src/core/upgradeMod.d.ts +6 -1
- package/dist/src/core/upgradeMod.d.ts.map +1 -1
- package/dist/src/core/upgradeMod.lua +9 -2
- package/dist/src/features/customStage/exports.lua +2 -2
- package/dist/src/features/extraConsoleCommands/listCommands.lua +5 -5
- package/dist/src/features/pause.lua +2 -2
- package/dist/src/features/saveDataManager/load.d.ts.map +1 -1
- package/dist/src/features/saveDataManager/load.lua +2 -1
- package/dist/src/features/saveDataManager/main.lua +2 -2
- package/dist/src/features/taintedLazarusPlayers.lua +2 -2
- package/dist/src/functions/benchmark.d.ts +12 -0
- package/dist/src/functions/benchmark.d.ts.map +1 -1
- package/dist/src/functions/benchmark.lua +19 -0
- package/dist/src/functions/debugFunctions.d.ts +1 -0
- package/dist/src/functions/debugFunctions.d.ts.map +1 -1
- package/dist/src/functions/debugFunctions.lua +15 -23
- package/dist/src/functions/globals.lua +1 -1
- package/dist/src/functions/hex.lua +2 -2
- package/dist/src/functions/jsonHelpers.lua +2 -2
- package/dist/src/functions/log.d.ts +9 -70
- package/dist/src/functions/log.d.ts.map +1 -1
- package/dist/src/functions/log.lua +18 -504
- package/dist/src/functions/logMisc.d.ts +69 -0
- package/dist/src/functions/logMisc.d.ts.map +1 -0
- package/dist/src/functions/logMisc.lua +498 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +8 -0
- package/dist/src/indexLua.d.ts +185 -0
- package/dist/src/indexLua.d.ts.map +1 -0
- package/dist/src/indexLua.lua +1314 -0
- package/package.json +2 -2
- package/src/callbacks/customRevive.ts +2 -1
- package/src/callbacks/postNewRoomEarly.ts +1 -1
- package/src/classes/ModUpgraded.ts +50 -4
- package/src/core/upgradeMod.ts +10 -2
- package/src/features/customStage/exports.ts +1 -1
- package/src/features/extraConsoleCommands/listCommands.ts +1 -1
- package/src/features/pause.ts +1 -1
- package/src/features/saveDataManager/load.ts +2 -1
- package/src/features/saveDataManager/main.ts +1 -1
- package/src/features/taintedLazarusPlayers.ts +1 -1
- package/src/functions/benchmark.ts +23 -0
- package/src/functions/debugFunctions.ts +15 -25
- package/src/functions/globals.ts +1 -1
- package/src/functions/hex.ts +1 -1
- package/src/functions/jsonHelpers.ts +1 -1
- package/src/functions/log.ts +24 -455
- package/src/functions/logMisc.ts +441 -0
- package/src/index.ts +1 -0
|
@@ -1,520 +1,34 @@
|
|
|
1
|
-
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Map = ____lualib.Map
|
|
3
|
-
local __TS__Spread = ____lualib.__TS__Spread
|
|
4
|
-
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
5
|
-
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
|
|
6
|
-
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
7
|
-
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
8
|
-
local Set = ____lualib.Set
|
|
9
|
-
local __TS__New = ____lualib.__TS__New
|
|
10
1
|
local ____exports = {}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
local UseFlag = ____isaac_2Dtypescript_2Ddefinitions.UseFlag
|
|
23
|
-
local ____cachedClasses = require("src.core.cachedClasses")
|
|
24
|
-
local game = ____cachedClasses.game
|
|
25
|
-
local sfxManager = ____cachedClasses.sfxManager
|
|
26
|
-
local ____array = require("src.functions.array")
|
|
27
|
-
local arrayToString = ____array.arrayToString
|
|
28
|
-
local ____collectibles = require("src.functions.collectibles")
|
|
29
|
-
local getCollectibleName = ____collectibles.getCollectibleName
|
|
30
|
-
local ____entities = require("src.functions.entities")
|
|
31
|
-
local getEntityID = ____entities.getEntityID
|
|
32
|
-
local ____enums = require("src.functions.enums")
|
|
33
|
-
local getEnumEntries = ____enums.getEnumEntries
|
|
34
|
-
local ____flag = require("src.functions.flag")
|
|
35
|
-
local hasFlag = ____flag.hasFlag
|
|
36
|
-
local ____isaacAPIClass = require("src.functions.isaacAPIClass")
|
|
37
|
-
local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
|
|
38
|
-
local ____playerHealth = require("src.functions.playerHealth")
|
|
39
|
-
local getPlayerHealth = ____playerHealth.getPlayerHealth
|
|
40
|
-
local ____players = require("src.functions.players")
|
|
41
|
-
local getEffectsList = ____players.getEffectsList
|
|
42
|
-
local getPlayerName = ____players.getPlayerName
|
|
43
|
-
local ____roomData = require("src.functions.roomData")
|
|
44
|
-
local getRoomData = ____roomData.getRoomData
|
|
45
|
-
local getRoomGridIndex = ____roomData.getRoomGridIndex
|
|
46
|
-
local getRoomListIndex = ____roomData.getRoomListIndex
|
|
47
|
-
local ____set = require("src.functions.set")
|
|
48
|
-
local combineSets = ____set.combineSets
|
|
49
|
-
local getSortedSetValues = ____set.getSortedSetValues
|
|
50
|
-
local ____table = require("src.functions.table")
|
|
51
|
-
local iterateTableInOrder = ____table.iterateTableInOrder
|
|
52
|
-
local ____trinkets = require("src.functions.trinkets")
|
|
53
|
-
local getTrinketName = ____trinkets.getTrinketName
|
|
54
|
-
local ____types = require("src.functions.types")
|
|
55
|
-
local isTable = ____types.isTable
|
|
56
|
-
local isUserdata = ____types.isUserdata
|
|
57
|
-
local ____utils = require("src.functions.utils")
|
|
58
|
-
local printConsole = ____utils.printConsole
|
|
59
|
-
local ____vector = require("src.functions.vector")
|
|
60
|
-
local vectorToString = ____vector.vectorToString
|
|
61
|
-
--- Helper function to prefix the name of the function and the line number before a debug message.
|
|
62
|
-
function ____exports.getDebugPrependString(self, msg, numParentFunctions)
|
|
63
|
-
if numParentFunctions == nil then
|
|
64
|
-
numParentFunctions = 3
|
|
2
|
+
--- Helper function to get the name and the line number of the current calling function.
|
|
3
|
+
--
|
|
4
|
+
-- For this function to work properly, the "--luadebug" flag must be enabled. Otherwise, it will
|
|
5
|
+
-- always return undefined.
|
|
6
|
+
--
|
|
7
|
+
-- @param levels Optional. The amount of levels to look backwards in the call stack. Default is 3
|
|
8
|
+
-- (because the first level is this function, the second level is the calling
|
|
9
|
+
-- function, and the third level is the parent of the calling function).
|
|
10
|
+
function ____exports.getParentFunctionDescription(self, levels)
|
|
11
|
+
if levels == nil then
|
|
12
|
+
levels = 3
|
|
65
13
|
end
|
|
66
14
|
if debug ~= nil then
|
|
67
|
-
local debugTable = debug.getinfo(
|
|
15
|
+
local debugTable = debug.getinfo(levels)
|
|
68
16
|
if debugTable ~= nil then
|
|
69
|
-
return (
|
|
17
|
+
return (tostring(debugTable.name) .. ":") .. tostring(debugTable.linedefined)
|
|
70
18
|
end
|
|
71
19
|
end
|
|
72
|
-
if
|
|
73
|
-
return (
|
|
20
|
+
if SandboxGetParentFunctionDescription ~= nil then
|
|
21
|
+
return SandboxGetParentFunctionDescription(levels)
|
|
74
22
|
end
|
|
75
|
-
return
|
|
23
|
+
return nil
|
|
76
24
|
end
|
|
77
25
|
--- Helper function to avoid typing out `Isaac.DebugString()`.
|
|
78
26
|
--
|
|
79
27
|
-- If you have the "--luadebug" launch flag turned on or the Racing+ sandbox enabled, then this
|
|
80
28
|
-- function will also prepend the function name and the line number before the string.
|
|
81
29
|
function ____exports.log(self, msg)
|
|
82
|
-
local
|
|
30
|
+
local parentFunctionDescription = ____exports.getParentFunctionDescription(nil)
|
|
31
|
+
local debugMsg = parentFunctionDescription == nil and msg or (parentFunctionDescription .. " - ") .. msg
|
|
83
32
|
Isaac.DebugString(debugMsg)
|
|
84
33
|
end
|
|
85
|
-
--- Helper function for printing out every flag that is turned on. Useful when debugging.
|
|
86
|
-
function ____exports.logFlags(self, flags, flagEnum, description)
|
|
87
|
-
if description == nil then
|
|
88
|
-
description = ""
|
|
89
|
-
end
|
|
90
|
-
if description ~= "" then
|
|
91
|
-
description = "flag"
|
|
92
|
-
end
|
|
93
|
-
____exports.log(
|
|
94
|
-
nil,
|
|
95
|
-
(("Logging " .. description) .. " values for: ") .. tostring(flags)
|
|
96
|
-
)
|
|
97
|
-
local hasNoFlags = true
|
|
98
|
-
for ____, ____value in ipairs(getEnumEntries(nil, flagEnum)) do
|
|
99
|
-
local key = ____value[1]
|
|
100
|
-
local value = ____value[2]
|
|
101
|
-
if hasFlag(nil, flags, value) then
|
|
102
|
-
____exports.log(
|
|
103
|
-
nil,
|
|
104
|
-
(((" Has flag: " .. key) .. " (") .. tostring(value)) .. ")"
|
|
105
|
-
)
|
|
106
|
-
hasNoFlags = false
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
if hasNoFlags then
|
|
110
|
-
____exports.log(nil, " n/a (no flags)")
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
function ____exports.logArray(self, array)
|
|
114
|
-
local arrayString = arrayToString(nil, array)
|
|
115
|
-
____exports.log(nil, "Array: " .. arrayString)
|
|
116
|
-
end
|
|
117
|
-
function ____exports.logCollectibleTypes(self, collectibleTypes)
|
|
118
|
-
____exports.log(nil, "Collectibles:")
|
|
119
|
-
local i = 1
|
|
120
|
-
for ____, collectibleType in ipairs(collectibleTypes) do
|
|
121
|
-
local collectibleName = getCollectibleName(nil, collectibleType)
|
|
122
|
-
____exports.log(
|
|
123
|
-
nil,
|
|
124
|
-
((((tostring(i) .. ") ") .. collectibleName) .. " (") .. tostring(collectibleType)) .. ")"
|
|
125
|
-
)
|
|
126
|
-
i = i + 1
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
function ____exports.logColor(self, color)
|
|
130
|
-
____exports.log(
|
|
131
|
-
nil,
|
|
132
|
-
(((((((((((("Color: R" .. tostring(color.R)) .. ", G") .. tostring(color.G)) .. ", B") .. tostring(color.B)) .. ", A") .. tostring(color.A)) .. ", RO") .. tostring(color.RO)) .. ", BO") .. tostring(color.BO)) .. ", GO") .. tostring(color.GO)
|
|
133
|
-
)
|
|
134
|
-
end
|
|
135
|
-
--- Helper function for printing out every damage flag that is turned on. Useful when debugging.
|
|
136
|
-
function ____exports.logDamageFlags(self, flags)
|
|
137
|
-
____exports.logFlags(nil, flags, DamageFlag, "damage")
|
|
138
|
-
end
|
|
139
|
-
--- Helper function for printing out every entity flag that is turned on. Useful when debugging.
|
|
140
|
-
function ____exports.logEntityFlags(self, flags)
|
|
141
|
-
____exports.logFlags(nil, flags, EntityFlag, "entity")
|
|
142
|
-
end
|
|
143
|
-
function ____exports.logEntityID(self, entity)
|
|
144
|
-
local entityID = getEntityID(nil, entity)
|
|
145
|
-
____exports.log(nil, "Entity: " .. entityID)
|
|
146
|
-
end
|
|
147
|
-
--- Helper function to log an error message and also print it to the console for better visibility.
|
|
148
|
-
--
|
|
149
|
-
-- This is useful in situations where using the `error` function would be dangerous (since it
|
|
150
|
-
-- prevents all of the subsequent code in the callback from running).
|
|
151
|
-
function ____exports.logError(self, msg)
|
|
152
|
-
local errorMsg = "Error: " .. msg
|
|
153
|
-
____exports.log(nil, errorMsg)
|
|
154
|
-
printConsole(nil, errorMsg)
|
|
155
|
-
end
|
|
156
|
-
--- Helper function for printing out every game state flag that is turned on. Useful when debugging.
|
|
157
|
-
function ____exports.logGameStateFlags(self)
|
|
158
|
-
____exports.log(nil, "Logging game state flags:")
|
|
159
|
-
local gameStateFlagEntries = getEnumEntries(nil, GameStateFlag)
|
|
160
|
-
local hasNoFlags = true
|
|
161
|
-
for ____, ____value in ipairs(gameStateFlagEntries) do
|
|
162
|
-
local key = ____value[1]
|
|
163
|
-
local gameStateFlag = ____value[2]
|
|
164
|
-
local flagValue = game:GetStateFlag(gameStateFlag)
|
|
165
|
-
if flagValue then
|
|
166
|
-
____exports.log(
|
|
167
|
-
nil,
|
|
168
|
-
(((" Has flag: " .. key) .. " (") .. tostring(gameStateFlag)) .. ")"
|
|
169
|
-
)
|
|
170
|
-
hasNoFlags = false
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
if hasNoFlags then
|
|
174
|
-
____exports.log(nil, " n/a (no flags)")
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
function ____exports.logKColor(self, kColor)
|
|
178
|
-
____exports.log(
|
|
179
|
-
nil,
|
|
180
|
-
(((((("Color: R" .. tostring(kColor.Red)) .. ", G") .. tostring(kColor.Green)) .. ", B") .. tostring(kColor.Blue)) .. ", A") .. tostring(kColor.Alpha)
|
|
181
|
-
)
|
|
182
|
-
end
|
|
183
|
-
--- Helper function for printing out every level state flag that is turned on. Useful when debugging.
|
|
184
|
-
function ____exports.logLevelStateFlags(self)
|
|
185
|
-
local level = game:GetLevel()
|
|
186
|
-
local levelStateFlagEntries = getEnumEntries(nil, LevelStateFlag)
|
|
187
|
-
____exports.log(nil, "Logging level state flags:")
|
|
188
|
-
local hasNoFlags = true
|
|
189
|
-
for ____, ____value in ipairs(levelStateFlagEntries) do
|
|
190
|
-
local key = ____value[1]
|
|
191
|
-
local levelStateFlag = ____value[2]
|
|
192
|
-
local flagValue = level:GetStateFlag(levelStateFlag)
|
|
193
|
-
if flagValue then
|
|
194
|
-
____exports.log(
|
|
195
|
-
nil,
|
|
196
|
-
(((" Has flag: " .. key) .. " (") .. tostring(levelStateFlag)) .. ")"
|
|
197
|
-
)
|
|
198
|
-
hasNoFlags = false
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
if hasNoFlags then
|
|
202
|
-
____exports.log(nil, " n/a (no flags)")
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
function ____exports.logMap(self, map)
|
|
206
|
-
____exports.log(nil, "Printing out a TSTL Map:")
|
|
207
|
-
local mapKeys = {__TS__Spread(map:keys())}
|
|
208
|
-
__TS__ArraySort(mapKeys)
|
|
209
|
-
for ____, key in ipairs(mapKeys) do
|
|
210
|
-
local value = map:get(key)
|
|
211
|
-
____exports.log(
|
|
212
|
-
nil,
|
|
213
|
-
((" " .. tostring(key)) .. " --> ") .. tostring(value)
|
|
214
|
-
)
|
|
215
|
-
end
|
|
216
|
-
____exports.log(
|
|
217
|
-
nil,
|
|
218
|
-
" The size of the map was: " .. tostring(map.size)
|
|
219
|
-
)
|
|
220
|
-
end
|
|
221
|
-
function ____exports.logPlayerEffects(self, player)
|
|
222
|
-
local effects = getEffectsList(nil, player)
|
|
223
|
-
____exports.log(nil, "Logging player effects:")
|
|
224
|
-
if #effects == 0 then
|
|
225
|
-
____exports.log(nil, " n/a (no effects)")
|
|
226
|
-
return
|
|
227
|
-
end
|
|
228
|
-
__TS__ArrayForEach(
|
|
229
|
-
effects,
|
|
230
|
-
function(____, effect, i)
|
|
231
|
-
local effectDescription
|
|
232
|
-
if effect.Item:IsCollectible() then
|
|
233
|
-
local collectibleName = getCollectibleName(nil, effect.Item.ID)
|
|
234
|
-
effectDescription = "Collectible: " .. collectibleName
|
|
235
|
-
elseif effect.Item:IsTrinket() then
|
|
236
|
-
local trinketName = getTrinketName(nil, effect.Item.ID)
|
|
237
|
-
effectDescription = "Trinket: " .. trinketName
|
|
238
|
-
elseif effect.Item:IsNull() then
|
|
239
|
-
effectDescription = "Null item: " .. tostring(effect.Item.ID)
|
|
240
|
-
else
|
|
241
|
-
effectDescription = "Unknown type of effect: " .. tostring(effect.Item.ID)
|
|
242
|
-
end
|
|
243
|
-
____exports.log(
|
|
244
|
-
nil,
|
|
245
|
-
(((((" " .. tostring(i + 1)) .. ") ") .. effectDescription) .. " (x") .. tostring(effect.Count)) .. ")"
|
|
246
|
-
)
|
|
247
|
-
end
|
|
248
|
-
)
|
|
249
|
-
end
|
|
250
|
-
function ____exports.logPlayerHealth(self, player)
|
|
251
|
-
local playerName = getPlayerName(nil, player)
|
|
252
|
-
local playerHealth = getPlayerHealth(nil, player)
|
|
253
|
-
____exports.log(nil, ("Player health for " .. playerName) .. ":")
|
|
254
|
-
____exports.log(
|
|
255
|
-
nil,
|
|
256
|
-
" Max hearts: " .. tostring(playerHealth.maxHearts)
|
|
257
|
-
)
|
|
258
|
-
____exports.log(
|
|
259
|
-
nil,
|
|
260
|
-
" Hearts: " .. tostring(playerHealth.hearts)
|
|
261
|
-
)
|
|
262
|
-
____exports.log(
|
|
263
|
-
nil,
|
|
264
|
-
" Eternal hearts: " .. tostring(playerHealth.eternalHearts)
|
|
265
|
-
)
|
|
266
|
-
____exports.log(
|
|
267
|
-
nil,
|
|
268
|
-
" Soul hearts: " .. tostring(playerHealth.soulHearts)
|
|
269
|
-
)
|
|
270
|
-
____exports.log(
|
|
271
|
-
nil,
|
|
272
|
-
" Bone hearts: " .. tostring(playerHealth.boneHearts)
|
|
273
|
-
)
|
|
274
|
-
____exports.log(
|
|
275
|
-
nil,
|
|
276
|
-
" Golden hearts: " .. tostring(playerHealth.goldenHearts)
|
|
277
|
-
)
|
|
278
|
-
____exports.log(
|
|
279
|
-
nil,
|
|
280
|
-
" Rotten hearts: " .. tostring(playerHealth.rottenHearts)
|
|
281
|
-
)
|
|
282
|
-
____exports.log(
|
|
283
|
-
nil,
|
|
284
|
-
" Broken hearts: " .. tostring(playerHealth.brokenHearts)
|
|
285
|
-
)
|
|
286
|
-
____exports.log(
|
|
287
|
-
nil,
|
|
288
|
-
" Soul charges: " .. tostring(playerHealth.soulCharges)
|
|
289
|
-
)
|
|
290
|
-
____exports.log(
|
|
291
|
-
nil,
|
|
292
|
-
" Blood charges: " .. tostring(playerHealth.bloodCharges)
|
|
293
|
-
)
|
|
294
|
-
____exports.log(nil, " Soul heart types: [")
|
|
295
|
-
for ____, soulHeartType in ipairs(playerHealth.soulHeartTypes) do
|
|
296
|
-
____exports.log(
|
|
297
|
-
nil,
|
|
298
|
-
" HeartSubType." .. tostring(HeartSubType[soulHeartType])
|
|
299
|
-
)
|
|
300
|
-
end
|
|
301
|
-
____exports.log(nil, " ]")
|
|
302
|
-
end
|
|
303
|
-
--- Helper function for printing out every projectile flag that is turned on. Useful when debugging.
|
|
304
|
-
function ____exports.logProjectileFlags(self, flags)
|
|
305
|
-
____exports.logFlags(nil, flags, ProjectileFlag, "projectile")
|
|
306
|
-
end
|
|
307
|
-
--- Helper function for logging information about the current room.
|
|
308
|
-
function ____exports.logRoom(self)
|
|
309
|
-
local room = game:GetRoom()
|
|
310
|
-
local bossID = room:GetBossID()
|
|
311
|
-
local roomGridIndex = getRoomGridIndex(nil)
|
|
312
|
-
local roomListIndex = getRoomListIndex(nil)
|
|
313
|
-
local roomData = getRoomData(nil)
|
|
314
|
-
____exports.log(nil, "Current room information:")
|
|
315
|
-
if roomData == nil then
|
|
316
|
-
____exports.log(nil, "- Room data is undefined.")
|
|
317
|
-
else
|
|
318
|
-
____exports.log(
|
|
319
|
-
nil,
|
|
320
|
-
"- Room stage ID: " .. tostring(roomData.StageID)
|
|
321
|
-
)
|
|
322
|
-
____exports.log(
|
|
323
|
-
nil,
|
|
324
|
-
(((("- Type/variant/sub-type: " .. tostring(roomData.Type)) .. ".") .. tostring(roomData.Variant)) .. ".") .. tostring(roomData.Subtype)
|
|
325
|
-
)
|
|
326
|
-
____exports.log(nil, "- Name: " .. roomData.Name)
|
|
327
|
-
end
|
|
328
|
-
local roomGridIndexName = GridRoom[roomGridIndex]
|
|
329
|
-
if roomGridIndexName == nil then
|
|
330
|
-
____exports.log(
|
|
331
|
-
nil,
|
|
332
|
-
"- Grid index: " .. tostring(roomGridIndex)
|
|
333
|
-
)
|
|
334
|
-
else
|
|
335
|
-
____exports.log(
|
|
336
|
-
nil,
|
|
337
|
-
((("- Grid index: GridRoom." .. roomGridIndexName) .. " (") .. tostring(roomGridIndex)) .. ")"
|
|
338
|
-
)
|
|
339
|
-
end
|
|
340
|
-
____exports.log(
|
|
341
|
-
nil,
|
|
342
|
-
"- List index: " .. tostring(roomListIndex)
|
|
343
|
-
)
|
|
344
|
-
____exports.log(
|
|
345
|
-
nil,
|
|
346
|
-
"- Boss ID: " .. tostring(bossID)
|
|
347
|
-
)
|
|
348
|
-
end
|
|
349
|
-
--- Helper function for printing out every seed effect (i.e. Easter Egg) that is turned on for the
|
|
350
|
-
-- particular run.
|
|
351
|
-
function ____exports.logSeedEffects(self)
|
|
352
|
-
local seeds = game:GetSeeds()
|
|
353
|
-
local seedEffectEntries = getEnumEntries(nil, SeedEffect)
|
|
354
|
-
____exports.log(nil, "Logging seed effects:")
|
|
355
|
-
local hasNoSeedEffects = true
|
|
356
|
-
for ____, ____value in ipairs(seedEffectEntries) do
|
|
357
|
-
local key = ____value[1]
|
|
358
|
-
local seedEffect = ____value[2]
|
|
359
|
-
if seeds:HasSeedEffect(seedEffect) then
|
|
360
|
-
____exports.log(
|
|
361
|
-
nil,
|
|
362
|
-
(((" " .. key) .. " (") .. tostring(seedEffect)) .. ")"
|
|
363
|
-
)
|
|
364
|
-
hasNoSeedEffects = false
|
|
365
|
-
end
|
|
366
|
-
end
|
|
367
|
-
if hasNoSeedEffects then
|
|
368
|
-
____exports.log(nil, " n/a (no seed effects)")
|
|
369
|
-
end
|
|
370
|
-
end
|
|
371
|
-
function ____exports.logSet(self, set)
|
|
372
|
-
____exports.log(nil, "Printing out a TSTL Set:")
|
|
373
|
-
local setValues = getSortedSetValues(nil, set)
|
|
374
|
-
for ____, value in ipairs(setValues) do
|
|
375
|
-
____exports.log(
|
|
376
|
-
nil,
|
|
377
|
-
" Value: " .. tostring(value)
|
|
378
|
-
)
|
|
379
|
-
end
|
|
380
|
-
____exports.log(
|
|
381
|
-
nil,
|
|
382
|
-
" The size of the set was: " .. tostring(set.size)
|
|
383
|
-
)
|
|
384
|
-
end
|
|
385
|
-
--- Helper function for logging every sound effect that is currently playing.
|
|
386
|
-
function ____exports.logSounds(self)
|
|
387
|
-
local soundEffects = getEnumEntries(nil, SoundEffect)
|
|
388
|
-
for ____, ____value in ipairs(soundEffects) do
|
|
389
|
-
local key = ____value[1]
|
|
390
|
-
local soundEffect = ____value[2]
|
|
391
|
-
if sfxManager:IsPlaying(soundEffect) then
|
|
392
|
-
____exports.log(
|
|
393
|
-
nil,
|
|
394
|
-
((("Currently playing sound effect: " .. key) .. " (") .. tostring(soundEffect)) .. ")"
|
|
395
|
-
)
|
|
396
|
-
end
|
|
397
|
-
end
|
|
398
|
-
end
|
|
399
|
-
--- Helper function for logging every key and value of a table. This is a deep log; the function will
|
|
400
|
-
-- recursively call itself if it counters a table within a table.
|
|
401
|
-
--
|
|
402
|
-
-- This function will only work on tables that have string keys (because it logs the keys in order,
|
|
403
|
-
-- instead of randomly). It will throw a run-time error if it encounters a non-string key.
|
|
404
|
-
function ____exports.logTable(self, luaTable, parentTables)
|
|
405
|
-
if parentTables == nil then
|
|
406
|
-
parentTables = 0
|
|
407
|
-
end
|
|
408
|
-
if parentTables == 0 then
|
|
409
|
-
____exports.log(nil, "Printing out a Lua table:")
|
|
410
|
-
end
|
|
411
|
-
local numSpaces = (parentTables + 1) * 2
|
|
412
|
-
local indentation = string.rep(
|
|
413
|
-
" ",
|
|
414
|
-
math.floor(numSpaces)
|
|
415
|
-
)
|
|
416
|
-
if not isTable(nil, luaTable) then
|
|
417
|
-
(function(self)
|
|
418
|
-
____exports.log(
|
|
419
|
-
nil,
|
|
420
|
-
((indentation .. "n/a (encountered a variable of type \"") .. __TS__TypeOf(luaTable)) .. "\" instead of a table)"
|
|
421
|
-
)
|
|
422
|
-
end)(nil)
|
|
423
|
-
return
|
|
424
|
-
end
|
|
425
|
-
local numElements = 0
|
|
426
|
-
iterateTableInOrder(
|
|
427
|
-
nil,
|
|
428
|
-
luaTable,
|
|
429
|
-
function(____, key, value)
|
|
430
|
-
____exports.log(
|
|
431
|
-
nil,
|
|
432
|
-
((indentation .. tostring(key)) .. " --> ") .. tostring(value)
|
|
433
|
-
)
|
|
434
|
-
if isTable(nil, value) then
|
|
435
|
-
if key == "__class" then
|
|
436
|
-
____exports.log(nil, indentation .. " (skipping enumerating this key to avoid infinite recursion)")
|
|
437
|
-
else
|
|
438
|
-
____exports.logTable(nil, value, parentTables + 1)
|
|
439
|
-
end
|
|
440
|
-
end
|
|
441
|
-
numElements = numElements + 1
|
|
442
|
-
end
|
|
443
|
-
);
|
|
444
|
-
(function(self)
|
|
445
|
-
____exports.log(
|
|
446
|
-
nil,
|
|
447
|
-
(indentation .. "The size of the table was: ") .. tostring(numElements)
|
|
448
|
-
)
|
|
449
|
-
end)(nil)
|
|
450
|
-
end
|
|
451
|
-
--- Helper function to print out the differences between the entries of two tables. Note that this
|
|
452
|
-
-- will only do a shallow comparison.
|
|
453
|
-
function ____exports.logTableDifferences(self, table1, table2)
|
|
454
|
-
____exports.log(nil, "Comparing two Lua tables:")
|
|
455
|
-
local table1Keys = __TS__ObjectKeys(table1)
|
|
456
|
-
local table1KeysSet = __TS__New(Set, table1Keys)
|
|
457
|
-
local table2Keys = __TS__ObjectKeys(table2)
|
|
458
|
-
local table2KeysSet = __TS__New(Set, table2Keys)
|
|
459
|
-
local keysSet = combineSets(nil, table1KeysSet, table2KeysSet)
|
|
460
|
-
local keys = {__TS__Spread(keysSet:values())}
|
|
461
|
-
__TS__ArraySort(keys)
|
|
462
|
-
for ____, key in ipairs(keys) do
|
|
463
|
-
if not table1KeysSet:has(key) then
|
|
464
|
-
____exports.log(
|
|
465
|
-
nil,
|
|
466
|
-
" Table 1 is missing key: " .. tostring(key)
|
|
467
|
-
)
|
|
468
|
-
elseif not table2KeysSet:has(key) then
|
|
469
|
-
____exports.log(
|
|
470
|
-
nil,
|
|
471
|
-
" Table 2 is missing key: " .. tostring(key)
|
|
472
|
-
)
|
|
473
|
-
else
|
|
474
|
-
local value1 = table1[key]
|
|
475
|
-
local value2 = table2[key]
|
|
476
|
-
if value1 ~= value2 then
|
|
477
|
-
____exports.log(
|
|
478
|
-
nil,
|
|
479
|
-
(((((" " .. tostring(key)) .. " --> \"") .. tostring(value1)) .. "\" versus \"") .. tostring(value2)) .. "\""
|
|
480
|
-
)
|
|
481
|
-
end
|
|
482
|
-
end
|
|
483
|
-
end
|
|
484
|
-
end
|
|
485
|
-
--- Helper function for printing out every tear flag that is turned on. Useful when debugging.
|
|
486
|
-
function ____exports.logTearFlags(self, flags)
|
|
487
|
-
____exports.logFlags(nil, flags, TearFlag, "tear")
|
|
488
|
-
end
|
|
489
|
-
--- Helper function for printing out every use flag that is turned on. Useful when debugging.
|
|
490
|
-
function ____exports.logUseFlags(self, flags)
|
|
491
|
-
____exports.logFlags(nil, flags, UseFlag, "use")
|
|
492
|
-
end
|
|
493
|
-
--- Helper function to enumerate all of the properties of a "userdata" object (i.e. an object from
|
|
494
|
-
-- the Isaac API).
|
|
495
|
-
function ____exports.logUserdata(self, userdata)
|
|
496
|
-
if not isUserdata(nil, userdata) then
|
|
497
|
-
____exports.log(nil, "Userdata: [not userdata]")
|
|
498
|
-
return
|
|
499
|
-
end
|
|
500
|
-
local metatable = getmetatable(userdata)
|
|
501
|
-
if metatable == nil then
|
|
502
|
-
____exports.log(nil, "Userdata: [no metatable]")
|
|
503
|
-
return
|
|
504
|
-
end
|
|
505
|
-
local classType = getIsaacAPIClassName(nil, userdata)
|
|
506
|
-
if classType == nil then
|
|
507
|
-
____exports.log(nil, "Userdata: [no class type]")
|
|
508
|
-
else
|
|
509
|
-
____exports.log(nil, "Userdata: " .. classType)
|
|
510
|
-
end
|
|
511
|
-
____exports.logTable(nil, metatable)
|
|
512
|
-
end
|
|
513
|
-
function ____exports.logVector(self, vector, round)
|
|
514
|
-
if round == nil then
|
|
515
|
-
round = false
|
|
516
|
-
end
|
|
517
|
-
local vectorString = vectorToString(nil, vector, round)
|
|
518
|
-
____exports.log(nil, "Vector: " .. vectorString)
|
|
519
|
-
end
|
|
520
34
|
return ____exports
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
2
|
+
import { CollectibleType, DamageFlag, EntityFlag, ProjectileFlag, TearFlag, UseFlag } from "isaac-typescript-definitions";
|
|
3
|
+
export declare function logArray<T>(array: T[] | readonly T[]): void;
|
|
4
|
+
export declare function logCollectibleTypes(collectibleTypes: CollectibleType[]): void;
|
|
5
|
+
export declare function logColor(color: Color): void;
|
|
6
|
+
/** Helper function for printing out every damage flag that is turned on. Useful when debugging. */
|
|
7
|
+
export declare function logDamageFlags(flags: DamageFlag | BitFlags<DamageFlag>): void;
|
|
8
|
+
/** Helper function for printing out every entity flag that is turned on. Useful when debugging. */
|
|
9
|
+
export declare function logEntityFlags(flags: EntityFlag | BitFlags<EntityFlag>): void;
|
|
10
|
+
export declare function logEntityID(entity: Entity): void;
|
|
11
|
+
/**
|
|
12
|
+
* Helper function to log an error message and also print it to the console for better visibility.
|
|
13
|
+
*
|
|
14
|
+
* This is useful in situations where using the `error` function would be dangerous (since it
|
|
15
|
+
* prevents all of the subsequent code in the callback from running).
|
|
16
|
+
*/
|
|
17
|
+
export declare function logError(msg: string): void;
|
|
18
|
+
/** Helper function for printing out every flag that is turned on. Useful when debugging. */
|
|
19
|
+
export declare function logFlags<T extends BitFlag | BitFlag128>(flags: T | BitFlags<T>, flagEnum: Record<string, T>, description?: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Helper function for printing out every game state flag that is turned on. Useful when debugging.
|
|
22
|
+
*/
|
|
23
|
+
export declare function logGameStateFlags(): void;
|
|
24
|
+
export declare function logKColor(kColor: KColor): void;
|
|
25
|
+
/**
|
|
26
|
+
* Helper function for printing out every level state flag that is turned on. Useful when debugging.
|
|
27
|
+
*/
|
|
28
|
+
export declare function logLevelStateFlags(): void;
|
|
29
|
+
export declare function logMap(map: Map<AnyNotNil, unknown>): void;
|
|
30
|
+
export declare function logPlayerEffects(player: EntityPlayer): void;
|
|
31
|
+
export declare function logPlayerHealth(player: EntityPlayer): void;
|
|
32
|
+
/**
|
|
33
|
+
* Helper function for printing out every projectile flag that is turned on. Useful when debugging.
|
|
34
|
+
*/
|
|
35
|
+
export declare function logProjectileFlags(flags: ProjectileFlag | BitFlags<ProjectileFlag>): void;
|
|
36
|
+
/** Helper function for logging information about the current room. */
|
|
37
|
+
export declare function logRoom(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Helper function for printing out every seed effect (i.e. Easter Egg) that is turned on for the
|
|
40
|
+
* particular run.
|
|
41
|
+
*/
|
|
42
|
+
export declare function logSeedEffects(): void;
|
|
43
|
+
export declare function logSet(set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>): void;
|
|
44
|
+
/** Helper function for logging every sound effect that is currently playing. */
|
|
45
|
+
export declare function logSounds(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Helper function for logging every key and value of a table. This is a deep log; the function will
|
|
48
|
+
* recursively call itself if it counters a table within a table.
|
|
49
|
+
*
|
|
50
|
+
* This function will only work on tables that have string keys (because it logs the keys in order,
|
|
51
|
+
* instead of randomly). It will throw a run-time error if it encounters a non-string key.
|
|
52
|
+
*/
|
|
53
|
+
export declare function logTable(luaTable: unknown, parentTables?: number): void;
|
|
54
|
+
/**
|
|
55
|
+
* Helper function to print out the differences between the entries of two tables. Note that this
|
|
56
|
+
* will only do a shallow comparison.
|
|
57
|
+
*/
|
|
58
|
+
export declare function logTableDifferences<K extends AnyNotNil, V>(table1: LuaMap<K, V>, table2: LuaMap<K, V>): void;
|
|
59
|
+
/** Helper function for printing out every tear flag that is turned on. Useful when debugging. */
|
|
60
|
+
export declare function logTearFlags(flags: TearFlag | BitFlags<TearFlag>): void;
|
|
61
|
+
/** Helper function for printing out every use flag that is turned on. Useful when debugging. */
|
|
62
|
+
export declare function logUseFlags(flags: UseFlag | BitFlags<UseFlag>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to enumerate all of the properties of a "userdata" object (i.e. an object from
|
|
65
|
+
* the Isaac API).
|
|
66
|
+
*/
|
|
67
|
+
export declare function logUserdata(userdata: unknown): void;
|
|
68
|
+
export declare function logVector(vector: Vector, round?: boolean): void;
|
|
69
|
+
//# sourceMappingURL=logMisc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logMisc.d.ts","sourceRoot":"","sources":["../../../src/functions/logMisc.ts"],"names":[],"mappings":"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"}
|