isaacscript-common 1.2.119 → 1.2.122
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.
|
@@ -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
|
|
@@ -250,6 +250,11 @@ export declare function isBethany(player: EntityPlayer): boolean;
|
|
|
250
250
|
* (For example, the Strawman Keeper.)
|
|
251
251
|
*/
|
|
252
252
|
export declare function isChildPlayer(player: EntityPlayer): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Helper function for detecting when a player is Eden or Tainted Eden. Useful for situations where
|
|
255
|
+
* you want to know if the starting stats were randomized, for example.
|
|
256
|
+
*/
|
|
257
|
+
export declare function isEden(player: EntityPlayer): boolean;
|
|
253
258
|
export declare function isFirstPlayer(player: EntityPlayer): boolean;
|
|
254
259
|
/**
|
|
255
260
|
* Helper function for detecting when a player is Jacob or Esau. This will only match the
|
|
@@ -543,6 +543,10 @@ function ____exports.isBethany(self, player)
|
|
|
543
543
|
local character = player:GetPlayerType()
|
|
544
544
|
return character == PlayerType.PLAYER_BETHANY or character == PlayerType.PLAYER_BETHANY_B
|
|
545
545
|
end
|
|
546
|
+
function ____exports.isEden(self, player)
|
|
547
|
+
local character = player:GetPlayerType()
|
|
548
|
+
return character == PlayerType.PLAYER_EDEN or character == PlayerType.PLAYER_EDEN_B
|
|
549
|
+
end
|
|
546
550
|
function ____exports.isFirstPlayer(self, player)
|
|
547
551
|
return ____exports.getPlayerIndexVanilla(nil, player) == 0
|
|
548
552
|
end
|
|
@@ -603,9 +607,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
603
607
|
itemPool:RemoveCollectible(collectibleType)
|
|
604
608
|
end
|
|
605
609
|
repeat
|
|
606
|
-
local
|
|
607
|
-
local
|
|
608
|
-
if
|
|
610
|
+
local ____switch129 = activeSlot
|
|
611
|
+
local ____cond129 = ____switch129 == ActiveSlot.SLOT_PRIMARY
|
|
612
|
+
if ____cond129 then
|
|
609
613
|
do
|
|
610
614
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
611
615
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -614,8 +618,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
614
618
|
break
|
|
615
619
|
end
|
|
616
620
|
end
|
|
617
|
-
|
|
618
|
-
if
|
|
621
|
+
____cond129 = ____cond129 or ____switch129 == ActiveSlot.SLOT_SECONDARY
|
|
622
|
+
if ____cond129 then
|
|
619
623
|
do
|
|
620
624
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
621
625
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -630,16 +634,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
630
634
|
break
|
|
631
635
|
end
|
|
632
636
|
end
|
|
633
|
-
|
|
634
|
-
if
|
|
637
|
+
____cond129 = ____cond129 or ____switch129 == ActiveSlot.SLOT_POCKET
|
|
638
|
+
if ____cond129 then
|
|
635
639
|
do
|
|
636
640
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
637
641
|
player:SetActiveCharge(charge, activeSlot)
|
|
638
642
|
break
|
|
639
643
|
end
|
|
640
644
|
end
|
|
641
|
-
|
|
642
|
-
if
|
|
645
|
+
____cond129 = ____cond129 or ____switch129 == ActiveSlot.SLOT_POCKET2
|
|
646
|
+
if ____cond129 then
|
|
643
647
|
do
|
|
644
648
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
645
649
|
break
|
|
@@ -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
|
/**
|