isaacscript-common 1.0.483 → 1.0.484
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/functions/player.d.ts +16 -0
- package/dist/functions/player.lua +69 -0
- package/package.json +1 -1
|
@@ -198,6 +198,22 @@ export declare function removeCollectibleCostume(player: EntityPlayer, collectib
|
|
|
198
198
|
*/
|
|
199
199
|
export declare function removeDeadEyeMultiplier(player: EntityPlayer): void;
|
|
200
200
|
export declare function removeTrinketCostume(player: EntityPlayer, trinketType: TrinketType | int): void;
|
|
201
|
+
/**
|
|
202
|
+
* Helper function to set an active collectible to a particular slot. This has different behavior
|
|
203
|
+
* than calling `player.AddCollectible()` with the `activeSlot` argument, because this function will
|
|
204
|
+
* not shift existing items into the Schoolbag and it handles `ActiveSlot.SLOT_POCKET2`.
|
|
205
|
+
*
|
|
206
|
+
* Note that if an item is set to `ActiveSlot.SLOT_POCKET2`, it will disappear after being used and
|
|
207
|
+
* will be automatically removed upon entering a new room.
|
|
208
|
+
*
|
|
209
|
+
* @param player The player to give the item to.
|
|
210
|
+
* @param collectibleType The collectible type of the item to give.
|
|
211
|
+
* @param activeSlot The slot to set.
|
|
212
|
+
* @param charge Optional. The argument of charges to set. If not specified, the item will be set
|
|
213
|
+
* with maximum charges.
|
|
214
|
+
* @param keepInPools Optional. Whether or not to remove the item from pools. False by default.
|
|
215
|
+
*/
|
|
216
|
+
export declare function setActiveItem(player: EntityPlayer, collectibleType: CollectibleType, activeSlot: ActiveSlot, charge?: int, keepInPools?: boolean): void;
|
|
201
217
|
/**
|
|
202
218
|
* If you want to stop the player from shooting without the blindfold costume, then simply call
|
|
203
219
|
* `player.TryRemoveNullCostume(NullItemID.ID_BLINDFOLD)` after invoking this function.
|
|
@@ -11,8 +11,12 @@ local PocketItemType = ____PocketItemType.PocketItemType
|
|
|
11
11
|
local ____bitwise = require("functions.bitwise")
|
|
12
12
|
local getKBitOfN = ____bitwise.getKBitOfN
|
|
13
13
|
local getNumBitsOfN = ____bitwise.getNumBitsOfN
|
|
14
|
+
local ____collectibles = require("functions.collectibles")
|
|
15
|
+
local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
|
|
14
16
|
local ____collectibleSet = require("functions.collectibleSet")
|
|
15
17
|
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
18
|
+
local ____util = require("functions.util")
|
|
19
|
+
local ensureAllCases = ____util.ensureAllCases
|
|
16
20
|
function ____exports.getPlayers(self, performExclusions)
|
|
17
21
|
if performExclusions == nil then
|
|
18
22
|
performExclusions = false
|
|
@@ -436,6 +440,71 @@ function ____exports.removeTrinketCostume(self, player, trinketType)
|
|
|
436
440
|
end
|
|
437
441
|
player:RemoveCostume(itemConfigTrinket)
|
|
438
442
|
end
|
|
443
|
+
function ____exports.setActiveItem(self, player, collectibleType, activeSlot, charge, keepInPools)
|
|
444
|
+
if keepInPools == nil then
|
|
445
|
+
keepInPools = false
|
|
446
|
+
end
|
|
447
|
+
local game = Game()
|
|
448
|
+
local itemPool = game:GetItemPool()
|
|
449
|
+
local primaryCollectibleType = player:GetActiveItem(ActiveSlot.SLOT_PRIMARY)
|
|
450
|
+
local primaryCharge = player:GetActiveCharge(ActiveSlot.SLOT_PRIMARY)
|
|
451
|
+
local secondaryCollectibleType = player:GetActiveItem(ActiveSlot.SLOT_SECONDARY)
|
|
452
|
+
if charge == nil then
|
|
453
|
+
charge = getCollectibleMaxCharges(nil, collectibleType)
|
|
454
|
+
end
|
|
455
|
+
if not keepInPools then
|
|
456
|
+
itemPool:RemoveCollectible(collectibleType)
|
|
457
|
+
end
|
|
458
|
+
repeat
|
|
459
|
+
local ____switch106 = activeSlot
|
|
460
|
+
local ____cond106 = ____switch106 == ActiveSlot.SLOT_PRIMARY
|
|
461
|
+
if ____cond106 then
|
|
462
|
+
do
|
|
463
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
464
|
+
player:RemoveCollectible(primaryCollectibleType)
|
|
465
|
+
end
|
|
466
|
+
player:AddCollectible(collectibleType, charge, false)
|
|
467
|
+
break
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_SECONDARY)
|
|
471
|
+
if ____cond106 then
|
|
472
|
+
do
|
|
473
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
474
|
+
player:RemoveCollectible(primaryCollectibleType)
|
|
475
|
+
end
|
|
476
|
+
if secondaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
477
|
+
player:RemoveCollectible(secondaryCollectibleType)
|
|
478
|
+
end
|
|
479
|
+
player:AddCollectible(secondaryCollectibleType, charge, false)
|
|
480
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
481
|
+
player:AddCollectible(primaryCollectibleType, primaryCharge, false)
|
|
482
|
+
end
|
|
483
|
+
break
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_POCKET)
|
|
487
|
+
if ____cond106 then
|
|
488
|
+
do
|
|
489
|
+
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
490
|
+
player:SetActiveCharge(charge, activeSlot)
|
|
491
|
+
break
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_POCKET2)
|
|
495
|
+
if ____cond106 then
|
|
496
|
+
do
|
|
497
|
+
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
498
|
+
break
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
do
|
|
502
|
+
do
|
|
503
|
+
ensureAllCases(nil, activeSlot)
|
|
504
|
+
end
|
|
505
|
+
end
|
|
506
|
+
until true
|
|
507
|
+
end
|
|
439
508
|
function ____exports.setBlindfold(self, player, enabled)
|
|
440
509
|
local game = Game()
|
|
441
510
|
local character = player:GetPlayerType()
|