isaacscript-common 1.0.485 → 1.0.486
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 +0 -43
- package/dist/functions/player.lua +15 -93
- package/dist/functions/pocketItems.d.ts +16 -14
- package/dist/functions/pocketItems.lua +56 -30
- package/dist/functions/trinkets.d.ts +23 -1
- package/dist/functions/trinkets.lua +26 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.lua +8 -0
- package/package.json +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
import { HealthType } from "../types/HealthType";
|
|
3
|
-
import { PocketItemDescription } from "../types/PocketItemDescription";
|
|
4
3
|
/**
|
|
5
4
|
* PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
|
|
6
5
|
* function. Mods can signify that data structures handle EntityPlayers by using this type:
|
|
@@ -47,20 +46,6 @@ export declare function getLastHeart(player: EntityPlayer): HealthType;
|
|
|
47
46
|
*/
|
|
48
47
|
export declare function getNewestPlayer(): EntityPlayer;
|
|
49
48
|
export declare function getFinalPlayer(): EntityPlayer;
|
|
50
|
-
/**
|
|
51
|
-
* Returns the slot number corresponding to where a trinket can be safely inserted.
|
|
52
|
-
*
|
|
53
|
-
* Example:
|
|
54
|
-
* ```
|
|
55
|
-
* const player = Isaac.GetPlayer();
|
|
56
|
-
* const trinketSlot = getOpenTrinketSlotNum(player);
|
|
57
|
-
* if (trinketSlot !== undefined) {
|
|
58
|
-
* // They have one or more open trinket slots
|
|
59
|
-
* player.AddTrinket(TrinketType.TRINKET_SWALLOWED_PENNY);
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export declare function getOpenTrinketSlot(player: EntityPlayer): int | undefined;
|
|
64
49
|
/**
|
|
65
50
|
* Iterates over all players and checks if any are close enough to the specified position.
|
|
66
51
|
*
|
|
@@ -115,17 +100,6 @@ export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int |
|
|
|
115
100
|
* This is equivalent to the number of hits that the player can currently take.
|
|
116
101
|
*/
|
|
117
102
|
export declare function getPlayerNumAllHearts(player: EntityPlayer): int;
|
|
118
|
-
/**
|
|
119
|
-
* Use this helper function as a workaround for `EntityPlayer.GetPocketItem()` not working
|
|
120
|
-
* correctly.
|
|
121
|
-
*
|
|
122
|
-
* Note that due to API limitations, there is no way to determine the location of a Dice Bag trinket
|
|
123
|
-
* dice. Furthermore, when the player has a Dice Bag trinket dice and a pocket active at the same
|
|
124
|
-
* time, there is no way to determine the location of the pocket active item. If this function
|
|
125
|
-
* cannot determine the identity of a particular slot, it will mark the type of the slot as
|
|
126
|
-
* `PocketItemType.UNDETERMINABLE`.
|
|
127
|
-
*/
|
|
128
|
-
export declare function getPocketItems(player: EntityPlayer): PocketItemDescription[];
|
|
129
103
|
/**
|
|
130
104
|
* Helper function to return the active charge and the battery charge combined. This is useful
|
|
131
105
|
* because you are not able to set the battery charge directly.
|
|
@@ -146,23 +120,6 @@ export declare function hasLostCurse(player: EntityPlayer): boolean;
|
|
|
146
120
|
* items. (Only Tainted Forgotten can pick up items.)
|
|
147
121
|
*/
|
|
148
122
|
export declare function hasOpenActiveItemSlot(player: EntityPlayer): boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Returns whether or not the player can hold an additional pocket item, beyond what they are
|
|
151
|
-
* currently carrying. This takes into account items that modify the max number of pocket items,
|
|
152
|
-
* like Starter Deck.
|
|
153
|
-
*
|
|
154
|
-
* If the player is the Tainted Soul, this always returns false, since that character cannot pick up
|
|
155
|
-
* items. (Only Tainted Forgotten can pick up items.)
|
|
156
|
-
*/
|
|
157
|
-
export declare function hasOpenPocketItemSlot(player: EntityPlayer): boolean;
|
|
158
|
-
/**
|
|
159
|
-
* Returns whether or not the player can hold an additional trinket, beyond what they are currently
|
|
160
|
-
* carrying. This takes into account items that modify the max number of trinkets, like Mom's Purse.
|
|
161
|
-
*
|
|
162
|
-
* If the player is the Tainted Soul, this always returns false, since that character cannot pick up
|
|
163
|
-
* items. (Only Tainted Forgotten can pick up items.)
|
|
164
|
-
*/
|
|
165
|
-
export declare function hasOpenTrinketSlot(player: EntityPlayer): boolean;
|
|
166
123
|
/**
|
|
167
124
|
* Helper function for detecting when a player is Bethany or Tainted Bethany. This is useful if you
|
|
168
125
|
* need to adjust UI elements to account for Bethany's soul charges or Tainted Bethany's blood
|
|
@@ -6,8 +6,6 @@ local ____constants = require("constants")
|
|
|
6
6
|
local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
|
|
7
7
|
local ____HealthType = require("types.HealthType")
|
|
8
8
|
local HealthType = ____HealthType.HealthType
|
|
9
|
-
local ____PocketItemType = require("types.PocketItemType")
|
|
10
|
-
local PocketItemType = ____PocketItemType.PocketItemType
|
|
11
9
|
local ____bitwise = require("functions.bitwise")
|
|
12
10
|
local getKBitOfN = ____bitwise.getKBitOfN
|
|
13
11
|
local getNumBitsOfN = ____bitwise.getNumBitsOfN
|
|
@@ -29,18 +27,18 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
29
27
|
do
|
|
30
28
|
local player = Isaac.GetPlayer(i)
|
|
31
29
|
if player == nil then
|
|
32
|
-
goto
|
|
30
|
+
goto __continue51
|
|
33
31
|
end
|
|
34
32
|
if ____exports.isChildPlayer(nil, player) then
|
|
35
|
-
goto
|
|
33
|
+
goto __continue51
|
|
36
34
|
end
|
|
37
35
|
local character = player:GetPlayerType()
|
|
38
36
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
39
|
-
goto
|
|
37
|
+
goto __continue51
|
|
40
38
|
end
|
|
41
39
|
__TS__ArrayPush(players, player)
|
|
42
40
|
end
|
|
43
|
-
::
|
|
41
|
+
::__continue51::
|
|
44
42
|
i = i + 1
|
|
45
43
|
end
|
|
46
44
|
end
|
|
@@ -210,24 +208,6 @@ function ____exports.getFinalPlayer(self)
|
|
|
210
208
|
local players = ____exports.getPlayers(nil)
|
|
211
209
|
return players[#players]
|
|
212
210
|
end
|
|
213
|
-
function ____exports.getOpenTrinketSlot(self, player)
|
|
214
|
-
local maxTrinkets = player:GetMaxTrinkets()
|
|
215
|
-
local trinket0 = player:GetTrinket(0)
|
|
216
|
-
local trinket1 = player:GetTrinket(1)
|
|
217
|
-
if maxTrinkets == 1 then
|
|
218
|
-
return ((trinket0 == TrinketType.TRINKET_NULL) and 0) or nil
|
|
219
|
-
end
|
|
220
|
-
if maxTrinkets == 2 then
|
|
221
|
-
if trinket0 == TrinketType.TRINKET_NULL then
|
|
222
|
-
return 0
|
|
223
|
-
end
|
|
224
|
-
return ((trinket1 == TrinketType.TRINKET_NULL) and 1) or nil
|
|
225
|
-
end
|
|
226
|
-
error(
|
|
227
|
-
"The player has an unknown number of trinket slots: " .. tostring(maxTrinkets)
|
|
228
|
-
)
|
|
229
|
-
return nil
|
|
230
|
-
end
|
|
231
211
|
function ____exports.getPlayerCloserThan(self, position, distance)
|
|
232
212
|
for ____, player in ipairs(
|
|
233
213
|
____exports.getPlayers(nil)
|
|
@@ -283,14 +263,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
283
263
|
do
|
|
284
264
|
local player = Isaac.GetPlayer(i)
|
|
285
265
|
if player == nil then
|
|
286
|
-
goto
|
|
266
|
+
goto __continue60
|
|
287
267
|
end
|
|
288
268
|
local playerHash = GetPtrHash(player)
|
|
289
269
|
if playerHash == playerToFindHash then
|
|
290
270
|
return i
|
|
291
271
|
end
|
|
292
272
|
end
|
|
293
|
-
::
|
|
273
|
+
::__continue60::
|
|
294
274
|
i = i + 1
|
|
295
275
|
end
|
|
296
276
|
end
|
|
@@ -303,43 +283,6 @@ function ____exports.getPlayerNumAllHearts(self, player)
|
|
|
303
283
|
local eternalHearts = player:GetEternalHearts()
|
|
304
284
|
return ((hearts + soulHearts) + boneHearts) + eternalHearts
|
|
305
285
|
end
|
|
306
|
-
function ____exports.getPocketItems(self, player)
|
|
307
|
-
local pocketItem = player:GetActiveItem(ActiveSlot.SLOT_POCKET)
|
|
308
|
-
local hasPocketItem = pocketItem ~= CollectibleType.COLLECTIBLE_NULL
|
|
309
|
-
local pocketItem2 = player:GetActiveItem(ActiveSlot.SLOT_POCKET2)
|
|
310
|
-
local hasPocketItem2 = pocketItem2 ~= CollectibleType.COLLECTIBLE_NULL
|
|
311
|
-
local maxPocketItems = player:GetMaxPocketItems()
|
|
312
|
-
local pocketItems = {}
|
|
313
|
-
local pocketItemIdentified = false
|
|
314
|
-
local pocketItem2Identified = false
|
|
315
|
-
do
|
|
316
|
-
local slot = 0
|
|
317
|
-
while slot < 4 do
|
|
318
|
-
local card = player:GetCard(slot)
|
|
319
|
-
local pill = player:GetPill(slot)
|
|
320
|
-
if card ~= Card.CARD_NULL then
|
|
321
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.CARD, id = card})
|
|
322
|
-
elseif pill ~= PillColor.PILL_NULL then
|
|
323
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.PILL, id = pill})
|
|
324
|
-
elseif (hasPocketItem and (not hasPocketItem2)) and (not pocketItemIdentified) then
|
|
325
|
-
pocketItemIdentified = true
|
|
326
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.ACTIVE_ITEM, id = pocketItem})
|
|
327
|
-
elseif ((not hasPocketItem) and hasPocketItem2) and (not pocketItem2Identified) then
|
|
328
|
-
pocketItem2Identified = true
|
|
329
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.DICE_BAG_DICE, id = pocketItem2})
|
|
330
|
-
elseif hasPocketItem and hasPocketItem2 then
|
|
331
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.UNDETERMINABLE, id = 0})
|
|
332
|
-
else
|
|
333
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.EMPTY, id = 0})
|
|
334
|
-
end
|
|
335
|
-
if (slot + 1) == maxPocketItems then
|
|
336
|
-
break
|
|
337
|
-
end
|
|
338
|
-
slot = slot + 1
|
|
339
|
-
end
|
|
340
|
-
end
|
|
341
|
-
return pocketItems
|
|
342
|
-
end
|
|
343
286
|
function ____exports.getTotalCharge(self, player, activeSlot)
|
|
344
287
|
local activeCharge = player:GetActiveCharge(activeSlot)
|
|
345
288
|
local batteryCharge = player:GetBatteryCharge(activeSlot)
|
|
@@ -371,27 +314,6 @@ function ____exports.hasOpenActiveItemSlot(self, player)
|
|
|
371
314
|
end
|
|
372
315
|
return activeItemPrimary == CollectibleType.COLLECTIBLE_NULL
|
|
373
316
|
end
|
|
374
|
-
function ____exports.hasOpenPocketItemSlot(self, player)
|
|
375
|
-
local character = player:GetPlayerType()
|
|
376
|
-
if character == PlayerType.PLAYER_THESOUL_B then
|
|
377
|
-
return false
|
|
378
|
-
end
|
|
379
|
-
local pocketItems = ____exports.getPocketItems(nil, player)
|
|
380
|
-
for ____, pocketItem in ipairs(pocketItems) do
|
|
381
|
-
if pocketItem.type == PocketItemType.EMPTY then
|
|
382
|
-
return true
|
|
383
|
-
end
|
|
384
|
-
end
|
|
385
|
-
return false
|
|
386
|
-
end
|
|
387
|
-
function ____exports.hasOpenTrinketSlot(self, player)
|
|
388
|
-
local character = player:GetPlayerType()
|
|
389
|
-
if character == PlayerType.PLAYER_THESOUL_B then
|
|
390
|
-
return false
|
|
391
|
-
end
|
|
392
|
-
local openTrinketSlot = ____exports.getOpenTrinketSlot(nil, player)
|
|
393
|
-
return openTrinketSlot ~= nil
|
|
394
|
-
end
|
|
395
317
|
function ____exports.isBethany(self, player)
|
|
396
318
|
local character = player:GetPlayerType()
|
|
397
319
|
return (character == PlayerType.PLAYER_BETHANY) or (character == PlayerType.PLAYER_BETHANY_B)
|
|
@@ -456,9 +378,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
456
378
|
itemPool:RemoveCollectible(collectibleType)
|
|
457
379
|
end
|
|
458
380
|
repeat
|
|
459
|
-
local
|
|
460
|
-
local
|
|
461
|
-
if
|
|
381
|
+
local ____switch87 = activeSlot
|
|
382
|
+
local ____cond87 = ____switch87 == ActiveSlot.SLOT_PRIMARY
|
|
383
|
+
if ____cond87 then
|
|
462
384
|
do
|
|
463
385
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
464
386
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -467,8 +389,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
467
389
|
break
|
|
468
390
|
end
|
|
469
391
|
end
|
|
470
|
-
|
|
471
|
-
if
|
|
392
|
+
____cond87 = ____cond87 or (____switch87 == ActiveSlot.SLOT_SECONDARY)
|
|
393
|
+
if ____cond87 then
|
|
472
394
|
do
|
|
473
395
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
474
396
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -483,16 +405,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
483
405
|
break
|
|
484
406
|
end
|
|
485
407
|
end
|
|
486
|
-
|
|
487
|
-
if
|
|
408
|
+
____cond87 = ____cond87 or (____switch87 == ActiveSlot.SLOT_POCKET)
|
|
409
|
+
if ____cond87 then
|
|
488
410
|
do
|
|
489
411
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
490
412
|
player:SetActiveCharge(charge, activeSlot)
|
|
491
413
|
break
|
|
492
414
|
end
|
|
493
415
|
end
|
|
494
|
-
|
|
495
|
-
if
|
|
416
|
+
____cond87 = ____cond87 or (____switch87 == ActiveSlot.SLOT_POCKET2)
|
|
417
|
+
if ____cond87 then
|
|
496
418
|
do
|
|
497
419
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
498
420
|
break
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { PocketItemDescription } from "../types/PocketItemDescription";
|
|
3
|
+
export declare function getFirstCardOrPill(player: EntityPlayer): PocketItemDescription | undefined;
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
5
|
+
* Use this helper function as a workaround for `EntityPlayer.GetPocketItem()` not working
|
|
6
|
+
* correctly.
|
|
4
7
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Note that due to API limitations, there is no way to determine the location of a Dice Bag trinket
|
|
9
|
+
* dice. Furthermore, when the player has a Dice Bag trinket dice and a pocket active at the same
|
|
10
|
+
* time, there is no way to determine the location of the pocket active item. If this function
|
|
11
|
+
* cannot determine the identity of a particular slot, it will mark the type of the slot as
|
|
12
|
+
* `PocketItemType.UNDETERMINABLE`.
|
|
10
13
|
*/
|
|
11
|
-
export declare function
|
|
14
|
+
export declare function getPocketItems(player: EntityPlayer): PocketItemDescription[];
|
|
12
15
|
/**
|
|
13
|
-
*
|
|
16
|
+
* Returns whether or not the player can hold an additional pocket item, beyond what they are
|
|
17
|
+
* currently carrying. This takes into account items that modify the max number of pocket items,
|
|
18
|
+
* like Starter Deck.
|
|
14
19
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* const pillEffect = PillEffect.PILLEFFECT_BAD_GAS;
|
|
18
|
-
* const pillEffectName = getPillEffectName(pillEffect); // trinketName is "Bad Gas"
|
|
19
|
-
* ```
|
|
20
|
+
* If the player is the Tainted Soul, this always returns false, since that character cannot pick up
|
|
21
|
+
* items. (Only Tainted Forgotten can pick up items.)
|
|
20
22
|
*/
|
|
21
|
-
export declare function
|
|
23
|
+
export declare function hasOpenPocketItemSlot(player: EntityPlayer): boolean;
|
|
@@ -1,39 +1,65 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
require("lualib_bundle");
|
|
2
3
|
local ____exports = {}
|
|
3
|
-
local
|
|
4
|
-
local
|
|
5
|
-
|
|
6
|
-
local
|
|
7
|
-
|
|
8
|
-
local
|
|
9
|
-
local
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
local ____PocketItemType = require("types.PocketItemType")
|
|
5
|
+
local PocketItemType = ____PocketItemType.PocketItemType
|
|
6
|
+
function ____exports.getPocketItems(self, player)
|
|
7
|
+
local pocketItem = player:GetActiveItem(ActiveSlot.SLOT_POCKET)
|
|
8
|
+
local hasPocketItem = pocketItem ~= CollectibleType.COLLECTIBLE_NULL
|
|
9
|
+
local pocketItem2 = player:GetActiveItem(ActiveSlot.SLOT_POCKET2)
|
|
10
|
+
local hasPocketItem2 = pocketItem2 ~= CollectibleType.COLLECTIBLE_NULL
|
|
11
|
+
local maxPocketItems = player:GetMaxPocketItems()
|
|
12
|
+
local pocketItems = {}
|
|
13
|
+
local pocketItemIdentified = false
|
|
14
|
+
local pocketItem2Identified = false
|
|
15
|
+
do
|
|
16
|
+
local slot = 0
|
|
17
|
+
while slot < 4 do
|
|
18
|
+
local card = player:GetCard(slot)
|
|
19
|
+
local pill = player:GetPill(slot)
|
|
20
|
+
if card ~= Card.CARD_NULL then
|
|
21
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.CARD, id = card})
|
|
22
|
+
elseif pill ~= PillColor.PILL_NULL then
|
|
23
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.PILL, id = pill})
|
|
24
|
+
elseif (hasPocketItem and (not hasPocketItem2)) and (not pocketItemIdentified) then
|
|
25
|
+
pocketItemIdentified = true
|
|
26
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.ACTIVE_ITEM, id = pocketItem})
|
|
27
|
+
elseif ((not hasPocketItem) and hasPocketItem2) and (not pocketItem2Identified) then
|
|
28
|
+
pocketItem2Identified = true
|
|
29
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.DICE_BAG_DICE, id = pocketItem2})
|
|
30
|
+
elseif hasPocketItem and hasPocketItem2 then
|
|
31
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.UNDETERMINABLE, id = 0})
|
|
32
|
+
else
|
|
33
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.EMPTY, id = 0})
|
|
34
|
+
end
|
|
35
|
+
if (slot + 1) == maxPocketItems then
|
|
36
|
+
break
|
|
37
|
+
end
|
|
38
|
+
slot = slot + 1
|
|
39
|
+
end
|
|
12
40
|
end
|
|
13
|
-
|
|
14
|
-
if cardName ~= nil then
|
|
15
|
-
return cardName
|
|
16
|
-
end
|
|
17
|
-
local itemConfigCard = itemConfig:GetCard(card)
|
|
18
|
-
if itemConfigCard == nil then
|
|
19
|
-
return defaultName
|
|
20
|
-
end
|
|
21
|
-
return itemConfigCard.Name
|
|
41
|
+
return pocketItems
|
|
22
42
|
end
|
|
23
|
-
function ____exports.
|
|
24
|
-
local
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
function ____exports.getFirstCardOrPill(self, player)
|
|
44
|
+
local pocketItems = ____exports.getPocketItems(nil, player)
|
|
45
|
+
for ____, pocketItem in ipairs(pocketItems) do
|
|
46
|
+
if (pocketItem.type == PocketItemType.CARD) or (pocketItem.type == PocketItemType.PILL) then
|
|
47
|
+
return pocketItem
|
|
48
|
+
end
|
|
28
49
|
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
return nil
|
|
51
|
+
end
|
|
52
|
+
function ____exports.hasOpenPocketItemSlot(self, player)
|
|
53
|
+
local character = player:GetPlayerType()
|
|
54
|
+
if character == PlayerType.PLAYER_THESOUL_B then
|
|
55
|
+
return false
|
|
32
56
|
end
|
|
33
|
-
local
|
|
34
|
-
|
|
35
|
-
|
|
57
|
+
local pocketItems = ____exports.getPocketItems(nil, player)
|
|
58
|
+
for ____, pocketItem in ipairs(pocketItems) do
|
|
59
|
+
if pocketItem.type == PocketItemType.EMPTY then
|
|
60
|
+
return true
|
|
61
|
+
end
|
|
36
62
|
end
|
|
37
|
-
return
|
|
63
|
+
return false
|
|
38
64
|
end
|
|
39
65
|
return ____exports
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
export declare function getMaxTrinketID(): int;
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Returns the slot number corresponding to where a trinket can be safely inserted.
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* ```
|
|
8
|
+
* const player = Isaac.GetPlayer();
|
|
9
|
+
* const trinketSlot = getOpenTrinketSlotNum(player);
|
|
10
|
+
* if (trinketSlot !== undefined) {
|
|
11
|
+
* // They have one or more open trinket slots
|
|
12
|
+
* player.AddTrinket(TrinketType.TRINKET_SWALLOWED_PENNY);
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function getOpenTrinketSlot(player: EntityPlayer): int | undefined;
|
|
17
|
+
/** Helper function to get all of the trinket entities in the room. */
|
|
4
18
|
export declare function getTrinkets(matchingSubType?: number): EntityPickup[];
|
|
5
19
|
/** This is a helper function to get a trinket description from a TrinketType. */
|
|
6
20
|
export declare function getTrinketDescription(trinketType: TrinketType | int): string;
|
|
@@ -14,4 +28,12 @@ export declare function getTrinketDescription(trinketType: TrinketType | int): s
|
|
|
14
28
|
* ```
|
|
15
29
|
*/
|
|
16
30
|
export declare function getTrinketName(trinketType: TrinketType | int): string;
|
|
31
|
+
/**
|
|
32
|
+
* Returns whether or not the player can hold an additional trinket, beyond what they are currently
|
|
33
|
+
* carrying. This takes into account items that modify the max number of trinkets, like Mom's Purse.
|
|
34
|
+
*
|
|
35
|
+
* If the player is the Tainted Soul, this always returns false, since that character cannot pick up
|
|
36
|
+
* items. (Only Tainted Forgotten can pick up items.)
|
|
37
|
+
*/
|
|
38
|
+
export declare function hasOpenTrinketSlot(player: EntityPlayer): boolean;
|
|
17
39
|
export declare function isGoldenTrinket(trinketType: TrinketType | int): boolean;
|
|
@@ -11,6 +11,24 @@ function ____exports.getMaxTrinketID(self)
|
|
|
11
11
|
local itemConfig = Isaac.GetItemConfig()
|
|
12
12
|
return itemConfig:GetTrinkets().Size - 1
|
|
13
13
|
end
|
|
14
|
+
function ____exports.getOpenTrinketSlot(self, player)
|
|
15
|
+
local maxTrinkets = player:GetMaxTrinkets()
|
|
16
|
+
local trinket0 = player:GetTrinket(0)
|
|
17
|
+
local trinket1 = player:GetTrinket(1)
|
|
18
|
+
if maxTrinkets == 1 then
|
|
19
|
+
return ((trinket0 == TrinketType.TRINKET_NULL) and 0) or nil
|
|
20
|
+
end
|
|
21
|
+
if maxTrinkets == 2 then
|
|
22
|
+
if trinket0 == TrinketType.TRINKET_NULL then
|
|
23
|
+
return 0
|
|
24
|
+
end
|
|
25
|
+
return ((trinket1 == TrinketType.TRINKET_NULL) and 1) or nil
|
|
26
|
+
end
|
|
27
|
+
error(
|
|
28
|
+
"The player has an unknown number of trinket slots: " .. tostring(maxTrinkets)
|
|
29
|
+
)
|
|
30
|
+
return nil
|
|
31
|
+
end
|
|
14
32
|
function ____exports.getTrinkets(self, matchingSubType)
|
|
15
33
|
if matchingSubType == nil then
|
|
16
34
|
matchingSubType = -1
|
|
@@ -57,6 +75,14 @@ function ____exports.getTrinketName(self, trinketType)
|
|
|
57
75
|
end
|
|
58
76
|
return itemConfigItem.Name
|
|
59
77
|
end
|
|
78
|
+
function ____exports.hasOpenTrinketSlot(self, player)
|
|
79
|
+
local character = player:GetPlayerType()
|
|
80
|
+
if character == PlayerType.PLAYER_THESOUL_B then
|
|
81
|
+
return false
|
|
82
|
+
end
|
|
83
|
+
local openTrinketSlot = ____exports.getOpenTrinketSlot(nil, player)
|
|
84
|
+
return openTrinketSlot ~= nil
|
|
85
|
+
end
|
|
60
86
|
function ____exports.isGoldenTrinket(self, trinketType)
|
|
61
87
|
return trinketType > GOLDEN_TRINKET_SHIFT
|
|
62
88
|
end
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./functions/pickups";
|
|
|
32
32
|
export * from "./functions/pills";
|
|
33
33
|
export * from "./functions/player";
|
|
34
34
|
export * from "./functions/playerHealth";
|
|
35
|
+
export * from "./functions/pocketItems";
|
|
35
36
|
export * from "./functions/position";
|
|
36
37
|
export * from "./functions/random";
|
|
37
38
|
export * from "./functions/revive";
|
package/dist/index.lua
CHANGED
|
@@ -262,6 +262,14 @@ do
|
|
|
262
262
|
end
|
|
263
263
|
end
|
|
264
264
|
end
|
|
265
|
+
do
|
|
266
|
+
local ____export = require("functions.pocketItems")
|
|
267
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
268
|
+
if ____exportKey ~= "default" then
|
|
269
|
+
____exports[____exportKey] = ____exportValue
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
265
273
|
do
|
|
266
274
|
local ____export = require("functions.position")
|
|
267
275
|
for ____exportKey, ____exportValue in pairs(____export) do
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.486",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.284",
|
|
29
29
|
"isaacscript-lint": "^1.0.67",
|
|
30
30
|
"typedoc": "^0.22.10",
|
|
31
31
|
"typescript": "4.4.4",
|