isaacscript-common 1.2.118 → 1.2.121
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.
|
@@ -22,7 +22,7 @@ local musicWasEnabled = false
|
|
|
22
22
|
v = {run = {disableSoundSet = __TS__New(Set)}}
|
|
23
23
|
function ____exports.disableSoundsInit(self, mod)
|
|
24
24
|
initialized = true
|
|
25
|
-
saveDataManager(nil, "
|
|
25
|
+
saveDataManager(nil, "disableSounds", v)
|
|
26
26
|
mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
|
|
27
27
|
end
|
|
28
28
|
function ____exports.enableAllSound(self, key)
|
|
@@ -38,6 +38,7 @@ function ____exports.enableAllSound(self, key)
|
|
|
38
38
|
local musicManager = MusicManager()
|
|
39
39
|
musicManager:Enable()
|
|
40
40
|
end
|
|
41
|
+
stopAllSoundEffects(nil)
|
|
41
42
|
end
|
|
42
43
|
function ____exports.disableAllSound(self, key)
|
|
43
44
|
if not initialized then
|
|
@@ -49,5 +50,6 @@ function ____exports.disableAllSound(self, key)
|
|
|
49
50
|
musicWasEnabled = musicManager:IsEnabled()
|
|
50
51
|
end
|
|
51
52
|
v.run.disableSoundSet:add(key)
|
|
53
|
+
stopAllSoundEffects(nil)
|
|
52
54
|
end
|
|
53
55
|
return ____exports
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
2
|
/**
|
|
4
3
|
* Helper function for determining if two arrays contain the exact same elements. Note that this
|
|
5
4
|
* only performs a shallow comparison.
|
|
@@ -88,4 +87,4 @@ export declare function getRandomArrayIndex<T>(array: T[] | readonly T[], seed?:
|
|
|
88
87
|
* - the table contains all numerical indexes that are contiguous, starting at 1
|
|
89
88
|
* - the table has no keys (i.e. an "empty" table)
|
|
90
89
|
*/
|
|
91
|
-
export declare function isArray(
|
|
90
|
+
export declare function isArray(thing: unknown): boolean;
|
package/dist/functions/array.lua
CHANGED
|
@@ -155,6 +155,9 @@ function ____exports.getRandomArrayElement(self, array, seed, exceptions)
|
|
|
155
155
|
if exceptions == nil then
|
|
156
156
|
exceptions = {}
|
|
157
157
|
end
|
|
158
|
+
if #array == 0 then
|
|
159
|
+
error("Failed to get a random array element since the provided array is empty.")
|
|
160
|
+
end
|
|
158
161
|
local arrayWithoutExceptions = ____exports.arrayRemove(
|
|
159
162
|
nil,
|
|
160
163
|
array,
|
|
@@ -174,22 +177,29 @@ function ____exports.getRandomArrayElementAndRemove(self, array, seed, exception
|
|
|
174
177
|
____exports.arrayRemoveInPlace(nil, array, randomArrayElement)
|
|
175
178
|
return randomArrayElement
|
|
176
179
|
end
|
|
177
|
-
function ____exports.isArray(self,
|
|
178
|
-
|
|
180
|
+
function ____exports.isArray(self, thing)
|
|
181
|
+
if type(thing) ~= "table" then
|
|
182
|
+
return false
|
|
183
|
+
end
|
|
184
|
+
local thingTable = thing
|
|
185
|
+
local metatable = getmetatable(thingTable)
|
|
179
186
|
if metatable ~= nil then
|
|
180
187
|
return false
|
|
181
188
|
end
|
|
182
189
|
local numEntries = 0
|
|
183
|
-
for key in pairs(
|
|
190
|
+
for key in pairs(thingTable) do
|
|
184
191
|
numEntries = numEntries + 1
|
|
185
192
|
if type(key) ~= "number" then
|
|
186
193
|
return false
|
|
187
194
|
end
|
|
188
195
|
end
|
|
196
|
+
if numEntries == 0 then
|
|
197
|
+
return true
|
|
198
|
+
end
|
|
189
199
|
do
|
|
190
200
|
local i = 1
|
|
191
201
|
while i <= numEntries do
|
|
192
|
-
local element =
|
|
202
|
+
local element = thingTable[i]
|
|
193
203
|
if element == nil then
|
|
194
204
|
return false
|
|
195
205
|
end
|
|
@@ -48,6 +48,9 @@ export declare const ensureAllCases: (obj: never) => never;
|
|
|
48
48
|
*
|
|
49
49
|
* For a more in depth explanation, see:
|
|
50
50
|
* https://isaacscript.github.io/docs/gotchas#iterating-over-enums
|
|
51
|
+
*
|
|
52
|
+
* You can also use this function for vanilla enums, which can make code easier to read than using
|
|
53
|
+
* `pairs` or `Object.values()`.
|
|
51
54
|
*/
|
|
52
55
|
export declare function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]>;
|
|
53
56
|
/**
|