isaacscript-common 1.0.542 → 1.0.543
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/revive.lua +2 -2
- package/dist/functions/trinketGive.d.ts +15 -12
- package/dist/functions/trinketGive.lua +15 -1
- package/dist/functions/trinkets.d.ts +11 -0
- package/dist/functions/trinkets.lua +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/types/TrinketSituation.d.ts +7 -0
- package/dist/types/TrinketSituation.lua +3 -0
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ local ____sprite = require("functions.sprite")
|
|
|
6
6
|
local getFinalFrameOfAnimation = ____sprite.getFinalFrameOfAnimation
|
|
7
7
|
local ____trinketGive = require("functions.trinketGive")
|
|
8
8
|
local giveTrinketsBack = ____trinketGive.giveTrinketsBack
|
|
9
|
-
local
|
|
9
|
+
local temporarilyRemoveTrinket = ____trinketGive.temporarilyRemoveTrinket
|
|
10
10
|
function ____exports.willMysteriousPaperRevive(self, player)
|
|
11
11
|
local game = Game()
|
|
12
12
|
local gameFrameCount = game:GetFrameCount()
|
|
@@ -17,7 +17,7 @@ function ____exports.willMysteriousPaperRevive(self, player)
|
|
|
17
17
|
return (frameOfDeath % 4) == 3
|
|
18
18
|
end
|
|
19
19
|
function ____exports.willPlayerRevive(self, player)
|
|
20
|
-
local trinketSituation =
|
|
20
|
+
local trinketSituation = temporarilyRemoveTrinket(nil, player, TrinketType.TRINKET_MYSTERIOUS_PAPER)
|
|
21
21
|
local willRevive = player:WillPlayerRevive() or ((trinketSituation ~= nil) and ____exports.willMysteriousPaperRevive(nil, player))
|
|
22
22
|
giveTrinketsBack(nil, player, trinketSituation)
|
|
23
23
|
return willRevive
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
|
|
3
|
-
trinketTypeRemoved: TrinketType | int;
|
|
4
|
-
trinket1: TrinketType | int;
|
|
5
|
-
trinket2: TrinketType | int;
|
|
6
|
-
numSmeltedTrinkets: int;
|
|
7
|
-
}
|
|
2
|
+
import { TrinketSituation } from "../types/TrinketSituation";
|
|
8
3
|
/**
|
|
9
|
-
* Helper function to temporarily remove a trinket from the player. Use this in
|
|
10
|
-
* `giveTrinketBack` function to take away and give back a trinket on the same
|
|
11
|
-
* correctly handles multiple trinket slots and ensures that all copies of the
|
|
12
|
-
* including smelted trinkets.
|
|
4
|
+
* Helper function to temporarily remove a specific kind of trinket from the player. Use this in
|
|
5
|
+
* combination with the `giveTrinketBack` function to take away and give back a trinket on the same
|
|
6
|
+
* frame. This function correctly handles multiple trinket slots and ensures that all copies of the
|
|
7
|
+
* trinket are removed, including smelted trinkets.
|
|
13
8
|
*
|
|
14
9
|
* Note that for simplicity, this function assumes that all smelted trinkets are non-golden.
|
|
15
10
|
*
|
|
16
|
-
* @returns
|
|
11
|
+
* @returns Undefined if the player does not have the trinket, or TrinketSituation if they do.
|
|
17
12
|
*/
|
|
18
|
-
export declare function
|
|
13
|
+
export declare function temporarilyRemoveTrinket(player: EntityPlayer, trinketType: TrinketType | int): TrinketSituation | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to temporarily removes a player's held trinkets, if any. This will not remove any
|
|
16
|
+
* smelted trinkets. Use this in combination with the `giveTrinketBack` function to take away and
|
|
17
|
+
* give back trinkets on the same frame.
|
|
18
|
+
*
|
|
19
|
+
* @returns Undefined if the player does not have any trinkets, or TrinketSituation if they do.
|
|
20
|
+
*/
|
|
21
|
+
export declare function temporarilyRemoveTrinkets(player: EntityPlayer): TrinketSituation | undefined;
|
|
19
22
|
/**
|
|
20
23
|
* Helper function to restore the player's trinkets back to the way they were before the
|
|
21
24
|
* `temporarilyRemoveTrinket` function was used. It will re-smelt any smelted trinkets that were
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____constants = require("constants")
|
|
4
4
|
local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
|
|
5
|
-
function ____exports.
|
|
5
|
+
function ____exports.temporarilyRemoveTrinket(self, player, trinketType)
|
|
6
6
|
if not player:HasTrinket(trinketType) then
|
|
7
7
|
return nil
|
|
8
8
|
end
|
|
@@ -24,6 +24,20 @@ function ____exports.temporarilyRemoveTrinkets(self, player, trinketType)
|
|
|
24
24
|
end
|
|
25
25
|
return {trinketTypeRemoved = trinketType, trinket1 = trinket1, trinket2 = trinket2, numSmeltedTrinkets = numSmeltedTrinkets}
|
|
26
26
|
end
|
|
27
|
+
function ____exports.temporarilyRemoveTrinkets(self, player)
|
|
28
|
+
local trinket1 = player:GetTrinket(0)
|
|
29
|
+
local trinket2 = player:GetTrinket(1)
|
|
30
|
+
if (trinket1 == TrinketType.TRINKET_NULL) and (trinket2 == TrinketType.TRINKET_NULL) then
|
|
31
|
+
return nil
|
|
32
|
+
end
|
|
33
|
+
if trinket1 ~= TrinketType.TRINKET_NULL then
|
|
34
|
+
player:TryRemoveTrinket(trinket1)
|
|
35
|
+
end
|
|
36
|
+
if trinket2 ~= TrinketType.TRINKET_NULL then
|
|
37
|
+
player:TryRemoveTrinket(trinket2)
|
|
38
|
+
end
|
|
39
|
+
return {trinketTypeRemoved = TrinketType.TRINKET_NULL, trinket1 = trinket1, trinket2 = trinket2, numSmeltedTrinkets = 0}
|
|
40
|
+
end
|
|
27
41
|
function ____exports.giveTrinketsBack(self, player, trinketSituation)
|
|
28
42
|
if trinketSituation == nil then
|
|
29
43
|
return
|
|
@@ -41,3 +41,14 @@ export declare function getTrinketName(trinketType: TrinketType | int): string;
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function hasOpenTrinketSlot(player: EntityPlayer): boolean;
|
|
43
43
|
export declare function isGoldenTrinket(trinketType: TrinketType | int): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Helper function to smelt a trinket. Before smelting, this function will automatically remove the
|
|
46
|
+
* trinkets that the player is holding, if any, and then give them back after the new trinket is
|
|
47
|
+
* smelted.
|
|
48
|
+
*
|
|
49
|
+
* @param player The player to smelt the trinkets to.
|
|
50
|
+
* @param trinketType The trinket type to smelt.
|
|
51
|
+
* @param numTrinkets Optional. If specified, will smelt the given number of trinkets. Use this to
|
|
52
|
+
* avoid calling this function multiple times. 1 by default.
|
|
53
|
+
*/
|
|
54
|
+
export declare function smeltTrinket(player: EntityPlayer, trinketType: TrinketType | int, numTrinkets?: number): void;
|
|
@@ -7,6 +7,9 @@ local ____trinketDescriptionMap = require("maps.trinketDescriptionMap")
|
|
|
7
7
|
local TRINKET_DESCRIPTION_MAP = ____trinketDescriptionMap.TRINKET_DESCRIPTION_MAP
|
|
8
8
|
local ____trinketNameMap = require("maps.trinketNameMap")
|
|
9
9
|
local TRINKET_NAME_MAP = ____trinketNameMap.TRINKET_NAME_MAP
|
|
10
|
+
local ____trinketGive = require("functions.trinketGive")
|
|
11
|
+
local giveTrinketsBack = ____trinketGive.giveTrinketsBack
|
|
12
|
+
local temporarilyRemoveTrinkets = ____trinketGive.temporarilyRemoveTrinkets
|
|
10
13
|
function ____exports.getMaxTrinketID(self)
|
|
11
14
|
local itemConfig = Isaac.GetItemConfig()
|
|
12
15
|
return itemConfig:GetTrinkets().Size - 1
|
|
@@ -86,4 +89,19 @@ end
|
|
|
86
89
|
function ____exports.isGoldenTrinket(self, trinketType)
|
|
87
90
|
return trinketType > GOLDEN_TRINKET_SHIFT
|
|
88
91
|
end
|
|
92
|
+
function ____exports.smeltTrinket(self, player, trinketType, numTrinkets)
|
|
93
|
+
if numTrinkets == nil then
|
|
94
|
+
numTrinkets = 1
|
|
95
|
+
end
|
|
96
|
+
local trinketSituation = temporarilyRemoveTrinkets(nil, player)
|
|
97
|
+
do
|
|
98
|
+
local i = 0
|
|
99
|
+
while i < numTrinkets do
|
|
100
|
+
player:AddTrinket(trinketType)
|
|
101
|
+
player:UseActiveItem(CollectibleType.COLLECTIBLE_SMELTER, false, false, true, false)
|
|
102
|
+
i = i + 1
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
giveTrinketsBack(nil, player, trinketSituation)
|
|
106
|
+
end
|
|
89
107
|
return ____exports
|
package/dist/index.d.ts
CHANGED