isaacscript-common 1.2.214 → 1.2.217
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/features/extraConsoleCommands/commands.lua +2 -2
- package/dist/functions/color.lua +2 -1
- package/dist/functions/log.d.ts +7 -2
- package/dist/functions/log.lua +58 -32
- package/dist/functions/rng.lua +2 -1
- package/dist/functions/userdata.d.ts +12 -0
- package/dist/functions/userdata.lua +18 -0
- package/dist/functions/utils.d.ts +0 -5
- package/dist/functions/utils.lua +0 -12
- package/dist/functions/vector.lua +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.lua +8 -0
- package/package.json +1 -1
|
@@ -19,12 +19,12 @@ local getCharacterName = ____character.getCharacterName
|
|
|
19
19
|
local ____gridEntity = require("functions.gridEntity")
|
|
20
20
|
local spawnGridEntityWithVariant = ____gridEntity.spawnGridEntityWithVariant
|
|
21
21
|
local ____log = require("functions.log")
|
|
22
|
+
local logEffects = ____log.logEffects
|
|
22
23
|
local logEntities = ____log.logEntities
|
|
23
24
|
local logGridEntities = ____log.logGridEntities
|
|
24
25
|
local logRoom = ____log.logRoom
|
|
25
26
|
local logSeedEffects = ____log.logSeedEffects
|
|
26
27
|
local logSounds = ____log.logSounds
|
|
27
|
-
local logTemporaryEffects = ____log.logTemporaryEffects
|
|
28
28
|
local ____map = require("functions.map")
|
|
29
29
|
local getMapPartialMatch = ____map.getMapPartialMatch
|
|
30
30
|
local ____npc = require("functions.npc")
|
|
@@ -487,7 +487,7 @@ function ____exports.dungeon(self)
|
|
|
487
487
|
end
|
|
488
488
|
function ____exports.effects(self)
|
|
489
489
|
local player = Isaac.GetPlayer()
|
|
490
|
-
|
|
490
|
+
logEffects(player)
|
|
491
491
|
printConsole(nil, "Logged the player's effects to the \"log.txt\" file.")
|
|
492
492
|
end
|
|
493
493
|
function ____exports.eh(self, params)
|
package/dist/functions/color.lua
CHANGED
|
@@ -8,9 +8,10 @@ local SerializationType = ____SerializationType.SerializationType
|
|
|
8
8
|
local ____table = require("functions.table")
|
|
9
9
|
local copyValuesToTable = ____table.copyValuesToTable
|
|
10
10
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
11
|
+
local ____userdata = require("functions.userdata")
|
|
12
|
+
local isUserdataObject = ____userdata.isUserdataObject
|
|
11
13
|
local ____utils = require("functions.utils")
|
|
12
14
|
local ensureAllCases = ____utils.ensureAllCases
|
|
13
|
-
local isUserdataObject = ____utils.isUserdataObject
|
|
14
15
|
function ____exports.isColor(self, object)
|
|
15
16
|
return isUserdataObject(nil, object, OBJECT_NAME)
|
|
16
17
|
end
|
package/dist/functions/log.d.ts
CHANGED
|
@@ -14,11 +14,12 @@ export declare function logArray<T>(this: void, array: T[]): void;
|
|
|
14
14
|
export declare function logColor(this: void, color: Color): void;
|
|
15
15
|
/** Helper function for printing out every damage flag that is turned on. Useful when debugging. */
|
|
16
16
|
export declare function logDamageFlags(this: void, flags: int): void;
|
|
17
|
+
export declare function logEffects(this: void, player: EntityPlayer): void;
|
|
17
18
|
/** Helper function for printing out every entity (or filtered entity) in the current room. */
|
|
18
19
|
export declare function logEntities(this: void, includeBackgroundEffects: boolean, entityTypeFilter?: EntityType | int): void;
|
|
19
|
-
export declare function logEntity(this: void, entity: Entity): void;
|
|
20
20
|
/** Helper function for printing out every entity flag that is turned on. Useful when debugging. */
|
|
21
21
|
export declare function logEntityFlags(this: void, flags: int): void;
|
|
22
|
+
export declare function logEntityID(this: void, entity: Entity): void;
|
|
22
23
|
/**
|
|
23
24
|
* Helper function to log an error message and also print it to the console for better visibility.
|
|
24
25
|
* This is useful in combination with an early return when invoking the `error` function would be
|
|
@@ -56,9 +57,13 @@ export declare function logSounds(this: void): void;
|
|
|
56
57
|
export declare function logTable(this: void, table: unknown, parentTables?: number): void;
|
|
57
58
|
/** Helper function for printing out every tear flag that is turned on. Useful when debugging. */
|
|
58
59
|
export declare function logTearFlags(this: void, flags: int): void;
|
|
59
|
-
export declare function logTemporaryEffects(this: void, player: EntityPlayer): void;
|
|
60
60
|
/** Helper function for printing out every use flag that is turned on. Useful when debugging. */
|
|
61
61
|
export declare function logUseFlags(this: void, flags: int): void;
|
|
62
|
+
/**
|
|
63
|
+
* Helper function to enumerate all of the properties of a "userdata" object (i.e. an object from
|
|
64
|
+
* the Isaac API).
|
|
65
|
+
*/
|
|
66
|
+
export declare function logUserdata(this: void, userdata: unknown): void;
|
|
62
67
|
export declare function logVector(this: void, vector: Vector): void;
|
|
63
68
|
/**
|
|
64
69
|
* Converts every `isaacscript-common` function that begins with "log" to a global function.
|
package/dist/functions/log.lua
CHANGED
|
@@ -35,6 +35,8 @@ local ____set = require("functions.set")
|
|
|
35
35
|
local getSortedSetValues = ____set.getSortedSetValues
|
|
36
36
|
local ____trinkets = require("functions.trinkets")
|
|
37
37
|
local getTrinketName = ____trinkets.getTrinketName
|
|
38
|
+
local ____userdata = require("functions.userdata")
|
|
39
|
+
local getUserdataType = ____userdata.getUserdataType
|
|
38
40
|
local ____utils = require("functions.utils")
|
|
39
41
|
local printConsole = ____utils.printConsole
|
|
40
42
|
function ____exports.getDebugPrependString(self, msg, numParentFunctions)
|
|
@@ -78,14 +80,14 @@ function ____exports.logFlags(flags, flagEnum, description)
|
|
|
78
80
|
for key, value in pairs(flagEnum) do
|
|
79
81
|
do
|
|
80
82
|
if type(value) ~= "number" then
|
|
81
|
-
goto
|
|
83
|
+
goto __continue42
|
|
82
84
|
end
|
|
83
85
|
if hasFlag(nil, flags, value) then
|
|
84
86
|
____exports.log((((" Has flag: " .. tostring(key)) .. " (") .. tostring(value)) .. ")")
|
|
85
87
|
hasNoFlags = false
|
|
86
88
|
end
|
|
87
89
|
end
|
|
88
|
-
::
|
|
90
|
+
::__continue42::
|
|
89
91
|
end
|
|
90
92
|
if hasNoFlags then
|
|
91
93
|
____exports.log(" n/a (no flags)")
|
|
@@ -112,6 +114,30 @@ end
|
|
|
112
114
|
function ____exports.logDamageFlags(flags)
|
|
113
115
|
____exports.logFlags(flags, DamageFlag, "damage")
|
|
114
116
|
end
|
|
117
|
+
function ____exports.logEffects(player)
|
|
118
|
+
local effects = getEffectsList(nil, player)
|
|
119
|
+
____exports.log("Logging player effects:")
|
|
120
|
+
if #effects == 0 then
|
|
121
|
+
____exports.log(" n/a (no effects)")
|
|
122
|
+
return
|
|
123
|
+
end
|
|
124
|
+
__TS__ArrayForEach(
|
|
125
|
+
effects,
|
|
126
|
+
function(____, effect, i)
|
|
127
|
+
if effect.Item:IsCollectible() then
|
|
128
|
+
local collectibleName = getCollectibleName(nil, effect.Item.ID)
|
|
129
|
+
____exports.log(((" " .. tostring(i + 1)) .. ") Collectible: ") .. collectibleName)
|
|
130
|
+
elseif effect.Item:IsTrinket() then
|
|
131
|
+
local trinketName = getTrinketName(nil, effect.Item.ID)
|
|
132
|
+
____exports.log(((" " .. tostring(i + 1)) .. ") Trinket: ") .. trinketName)
|
|
133
|
+
elseif effect.Item:IsNull() then
|
|
134
|
+
____exports.log(((" " .. tostring(i + 1)) .. ") Null item: ") .. tostring(effect.Item.ID))
|
|
135
|
+
else
|
|
136
|
+
____exports.log(((" " .. tostring(i + 1)) .. ") Unknown type of effect: ") .. tostring(effect.Item.ID))
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
)
|
|
140
|
+
end
|
|
115
141
|
function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
116
142
|
local headerMsg = "Entities in the room"
|
|
117
143
|
if entityTypeFilter ~= nil then
|
|
@@ -190,12 +216,12 @@ function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
|
190
216
|
____exports.log(("(" .. tostring(numMatchedEntities)) .. " total entities)")
|
|
191
217
|
end
|
|
192
218
|
end
|
|
193
|
-
function ____exports.logEntity(entity)
|
|
194
|
-
____exports.log((((("Entity: " .. tostring(entity.Type)) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType))
|
|
195
|
-
end
|
|
196
219
|
function ____exports.logEntityFlags(flags)
|
|
197
220
|
____exports.logFlags(flags, EntityFlag, "entity")
|
|
198
221
|
end
|
|
222
|
+
function ____exports.logEntityID(entity)
|
|
223
|
+
____exports.log((((("Entity: " .. tostring(entity.Type)) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType))
|
|
224
|
+
end
|
|
199
225
|
function ____exports.logError(msg)
|
|
200
226
|
local errorMsg = "Error: " .. msg
|
|
201
227
|
____exports.log(errorMsg)
|
|
@@ -379,7 +405,11 @@ function ____exports.logTable(____table, parentTables)
|
|
|
379
405
|
____exports.log((((indentation .. "Key: ") .. tostring(key)) .. ", Value: ") .. tostring(value))
|
|
380
406
|
local valueType = type(value)
|
|
381
407
|
if valueType == "table" then
|
|
382
|
-
|
|
408
|
+
if key == "__class" then
|
|
409
|
+
____exports.log(indentation .. "(skipping enumerating this key to avoid infinite recursion)")
|
|
410
|
+
else
|
|
411
|
+
____exports.logTable(value, parentTables + 1)
|
|
412
|
+
end
|
|
383
413
|
end
|
|
384
414
|
numKeys = numKeys + 1
|
|
385
415
|
end
|
|
@@ -388,33 +418,28 @@ end
|
|
|
388
418
|
function ____exports.logTearFlags(flags)
|
|
389
419
|
____exports.logFlags(flags, TearFlags, "tear")
|
|
390
420
|
end
|
|
391
|
-
function ____exports.logTemporaryEffects(player)
|
|
392
|
-
local effects = getEffectsList(nil, player)
|
|
393
|
-
____exports.log("Logging player temporary effects:")
|
|
394
|
-
if #effects == 0 then
|
|
395
|
-
____exports.log(" n/a (no temporary effects)")
|
|
396
|
-
return
|
|
397
|
-
end
|
|
398
|
-
__TS__ArrayForEach(
|
|
399
|
-
effects,
|
|
400
|
-
function(____, effect, i)
|
|
401
|
-
if effect.Item:IsCollectible() then
|
|
402
|
-
local collectibleName = getCollectibleName(nil, effect.Item.ID)
|
|
403
|
-
____exports.log(((" " .. tostring(i + 1)) .. ") ") .. collectibleName)
|
|
404
|
-
elseif effect.Item:IsTrinket() then
|
|
405
|
-
local trinketName = getTrinketName(nil, effect.Item.ID)
|
|
406
|
-
____exports.log(((" " .. tostring(i + 1)) .. ") ") .. trinketName)
|
|
407
|
-
elseif effect.Item:IsNull() then
|
|
408
|
-
____exports.log(((" " .. tostring(i + 1)) .. ") Null item: ") .. tostring(effect.Item.ID))
|
|
409
|
-
else
|
|
410
|
-
____exports.log(((" " .. tostring(i + 1)) .. ") Unknown type of temporary effect: ") .. tostring(effect.Item.ID))
|
|
411
|
-
end
|
|
412
|
-
end
|
|
413
|
-
)
|
|
414
|
-
end
|
|
415
421
|
function ____exports.logUseFlags(flags)
|
|
416
422
|
____exports.logFlags(flags, UseFlag, "use")
|
|
417
423
|
end
|
|
424
|
+
function ____exports.logUserdata(userdata)
|
|
425
|
+
local userdataType = type(userdata)
|
|
426
|
+
if userdataType ~= "userdata" then
|
|
427
|
+
____exports.log("Userdata: [not userdata]")
|
|
428
|
+
return
|
|
429
|
+
end
|
|
430
|
+
local metatable = getmetatable(userdata)
|
|
431
|
+
if metatable == nil then
|
|
432
|
+
____exports.log("Userdata: [no metatable]")
|
|
433
|
+
return
|
|
434
|
+
end
|
|
435
|
+
local classType = getUserdataType(nil, userdata)
|
|
436
|
+
if classType == nil then
|
|
437
|
+
____exports.log("Userdata: [no class type]")
|
|
438
|
+
else
|
|
439
|
+
____exports.log("Userdata: " .. classType)
|
|
440
|
+
end
|
|
441
|
+
____exports.logTable(metatable)
|
|
442
|
+
end
|
|
418
443
|
function ____exports.logVector(vector)
|
|
419
444
|
____exports.log(((("Vector: (" .. tostring(vector.X)) .. ", ") .. tostring(vector.Y)) .. ")")
|
|
420
445
|
end
|
|
@@ -424,8 +449,9 @@ function ____exports.setLogFunctionsGlobal(self)
|
|
|
424
449
|
globals.logArray = ____exports.logArray
|
|
425
450
|
globals.logColor = ____exports.logColor
|
|
426
451
|
globals.logDamageFlags = ____exports.logDamageFlags
|
|
452
|
+
globals.logEffects = ____exports.logEffects
|
|
427
453
|
globals.logEntities = ____exports.logEntities
|
|
428
|
-
globals.
|
|
454
|
+
globals.logEntityID = ____exports.logEntityID
|
|
429
455
|
globals.logEntityFlags = ____exports.logEntityFlags
|
|
430
456
|
globals.logError = ____exports.logError
|
|
431
457
|
globals.logFlags = ____exports.logFlags
|
|
@@ -441,8 +467,8 @@ function ____exports.setLogFunctionsGlobal(self)
|
|
|
441
467
|
globals.logSounds = ____exports.logSounds
|
|
442
468
|
globals.logTable = ____exports.logTable
|
|
443
469
|
globals.logTearFlags = ____exports.logTearFlags
|
|
444
|
-
globals.logTemporaryEffects = ____exports.logTemporaryEffects
|
|
445
470
|
globals.logUseFlags = ____exports.logUseFlags
|
|
471
|
+
globals.logUserdata = ____exports.logUserdata
|
|
446
472
|
globals.logVector = ____exports.logVector
|
|
447
473
|
end
|
|
448
474
|
return ____exports
|
package/dist/functions/rng.lua
CHANGED
|
@@ -11,9 +11,10 @@ local SerializationType = ____SerializationType.SerializationType
|
|
|
11
11
|
local ____table = require("functions.table")
|
|
12
12
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
13
13
|
local tableHasKeys = ____table.tableHasKeys
|
|
14
|
+
local ____userdata = require("functions.userdata")
|
|
15
|
+
local isUserdataObject = ____userdata.isUserdataObject
|
|
14
16
|
local ____utils = require("functions.utils")
|
|
15
17
|
local ensureAllCases = ____utils.ensureAllCases
|
|
16
|
-
local isUserdataObject = ____utils.isUserdataObject
|
|
17
18
|
function ____exports.getRandomSeed(self)
|
|
18
19
|
local randomNumber = Random()
|
|
19
20
|
local safeRandomNumber = randomNumber == 0 and 1 or randomNumber
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to get the type of a userdata object from the Isaac API. This is contained within
|
|
3
|
+
* the "__type" metatable key.
|
|
4
|
+
*
|
|
5
|
+
* For example, a `Vector` class is userdata with a type of "Vector".
|
|
6
|
+
*/
|
|
7
|
+
export declare function getUserdataType(object: unknown): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to check if something is an instantiated class from the Isaac API. (All classes
|
|
10
|
+
* from the Isaac API have a type of "userdata" in Lua with a metatable key of "__type".)
|
|
11
|
+
*/
|
|
12
|
+
export declare function isUserdataObject(object: unknown, objectType: string): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
function ____exports.getUserdataType(self, object)
|
|
4
|
+
local objectType = type(object)
|
|
5
|
+
if objectType ~= "userdata" then
|
|
6
|
+
return nil
|
|
7
|
+
end
|
|
8
|
+
local metatable = getmetatable(object)
|
|
9
|
+
if metatable == nil then
|
|
10
|
+
return nil
|
|
11
|
+
end
|
|
12
|
+
return metatable.__type
|
|
13
|
+
end
|
|
14
|
+
function ____exports.isUserdataObject(self, object, objectType)
|
|
15
|
+
local userdataType = ____exports.getUserdataType(nil, object)
|
|
16
|
+
return userdataType == objectType or userdataType == "const " .. objectType
|
|
17
|
+
end
|
|
18
|
+
return ____exports
|
|
@@ -93,11 +93,6 @@ export declare function hexToKColor(hexString: string, alpha: float): KColor;
|
|
|
93
93
|
* is enabled or not.
|
|
94
94
|
*/
|
|
95
95
|
export declare function isLuaDebugEnabled(): boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Helper function to check if the something is an instantiated class from the Isaac API. (All
|
|
98
|
-
* classes from the Isaac API have a type of "userdata" in Lua.)
|
|
99
|
-
*/
|
|
100
|
-
export declare function isUserdataObject(object: unknown, objectName: string): boolean;
|
|
101
96
|
/**
|
|
102
97
|
* Helper function to print something to the in-game console. Use this instead of invoking the
|
|
103
98
|
* `Isaac.ConsoleOutput` method directly because it will automatically insert a newline at the end
|
package/dist/functions/utils.lua
CHANGED
|
@@ -66,18 +66,6 @@ end
|
|
|
66
66
|
function ____exports.isLuaDebugEnabled(self)
|
|
67
67
|
return package ~= nil
|
|
68
68
|
end
|
|
69
|
-
function ____exports.isUserdataObject(self, object, objectName)
|
|
70
|
-
local objectType = type(object)
|
|
71
|
-
if objectType ~= "userdata" then
|
|
72
|
-
return false
|
|
73
|
-
end
|
|
74
|
-
local metatable = getmetatable(object)
|
|
75
|
-
if metatable == nil then
|
|
76
|
-
return false
|
|
77
|
-
end
|
|
78
|
-
local vectorMetatable = metatable
|
|
79
|
-
return vectorMetatable.__type == objectName
|
|
80
|
-
end
|
|
81
69
|
function ____exports.printConsole(self, msg)
|
|
82
70
|
Isaac.ConsoleOutput(msg .. "\n")
|
|
83
71
|
end
|
|
@@ -11,9 +11,10 @@ local ____table = require("functions.table")
|
|
|
11
11
|
local copyValuesToTable = ____table.copyValuesToTable
|
|
12
12
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
13
13
|
local tableHasKeys = ____table.tableHasKeys
|
|
14
|
+
local ____userdata = require("functions.userdata")
|
|
15
|
+
local isUserdataObject = ____userdata.isUserdataObject
|
|
14
16
|
local ____utils = require("functions.utils")
|
|
15
17
|
local ensureAllCases = ____utils.ensureAllCases
|
|
16
|
-
local isUserdataObject = ____utils.isUserdataObject
|
|
17
18
|
function ____exports.isVector(self, object)
|
|
18
19
|
return isUserdataObject(nil, object, OBJECT_NAME)
|
|
19
20
|
end
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export * from "./functions/trinketGive";
|
|
|
88
88
|
export * from "./functions/trinkets";
|
|
89
89
|
export * from "./functions/trinketSet";
|
|
90
90
|
export * from "./functions/ui";
|
|
91
|
+
export * from "./functions/userdata";
|
|
91
92
|
export * from "./functions/utils";
|
|
92
93
|
export * from "./functions/vector";
|
|
93
94
|
export * from "./maps/cardMap";
|
package/dist/index.lua
CHANGED
|
@@ -704,6 +704,14 @@ do
|
|
|
704
704
|
end
|
|
705
705
|
end
|
|
706
706
|
end
|
|
707
|
+
do
|
|
708
|
+
local ____export = require("functions.userdata")
|
|
709
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
710
|
+
if ____exportKey ~= "default" then
|
|
711
|
+
____exports[____exportKey] = ____exportValue
|
|
712
|
+
end
|
|
713
|
+
end
|
|
714
|
+
end
|
|
707
715
|
do
|
|
708
716
|
local ____export = require("functions.utils")
|
|
709
717
|
for ____exportKey, ____exportValue in pairs(____export) do
|