isaacscript-common 1.2.196 → 1.2.197
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.
|
@@ -119,3 +119,8 @@ export declare function printConsole(msg: string): void;
|
|
|
119
119
|
* ```
|
|
120
120
|
*/
|
|
121
121
|
export declare function repeat(n: int, func: (i: int) => void): void;
|
|
122
|
+
/**
|
|
123
|
+
* Helper function to check every value of a custom enum for -1. This is helpful as a run-time check
|
|
124
|
+
* because many methods of the Isaac class return -1 if they fail.
|
|
125
|
+
*/
|
|
126
|
+
export declare function validateCustomEnum(customEnumName: string, customEnum: unknown): void;
|
package/dist/functions/utils.lua
CHANGED
|
@@ -3,6 +3,7 @@ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
|
3
3
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
4
4
|
local __TS__StringReplace = ____lualib.__TS__StringReplace
|
|
5
5
|
local __TS__StringSubstr = ____lualib.__TS__StringSubstr
|
|
6
|
+
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
6
7
|
local ____exports = {}
|
|
7
8
|
local ____directionNames = require("objects.directionNames")
|
|
8
9
|
local DIRECTION_NAMES = ____directionNames.DIRECTION_NAMES
|
|
@@ -76,4 +77,18 @@ ____exports["repeat"] = function(self, n, func)
|
|
|
76
77
|
end
|
|
77
78
|
end
|
|
78
79
|
end
|
|
80
|
+
function ____exports.validateCustomEnum(self, customEnumName, customEnum)
|
|
81
|
+
local customEnumType = type(customEnum)
|
|
82
|
+
if customEnumType ~= "table" then
|
|
83
|
+
return
|
|
84
|
+
end
|
|
85
|
+
local ____table = customEnum
|
|
86
|
+
for ____, ____value in ipairs(__TS__ObjectEntries(____table)) do
|
|
87
|
+
local key = ____value[1]
|
|
88
|
+
local value = ____value[2]
|
|
89
|
+
if value == -1 then
|
|
90
|
+
error((("Failed to find: " .. customEnumName) .. ".") .. key)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
79
94
|
return ____exports
|