isaacscript-common 1.0.483 → 1.0.487
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/log.d.ts +11 -14
- package/dist/functions/log.lua +3 -0
- package/dist/functions/player.d.ts +16 -43
- package/dist/functions/player.lua +75 -84
- 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/dist/types/PocketItemDescription.d.ts +1 -0
- package/package.json +2 -2
package/dist/functions/log.d.ts
CHANGED
|
@@ -5,31 +5,28 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function getDebugPrependString(msg: string, numParentFunctions?: number): string;
|
|
7
7
|
/**
|
|
8
|
-
* Helper function to avoid typing out `Isaac.DebugString()`.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Helper function to avoid typing out `Isaac.DebugString()`. If you have the --luadebug launch flag
|
|
9
|
+
* turned on or the Racing+ sandbox enabled, then this function will also prepend the function name
|
|
10
|
+
* and the line number before the string.
|
|
11
11
|
*/
|
|
12
12
|
export declare function log(this: void, msg: string): void;
|
|
13
|
-
/**
|
|
14
|
-
* Helper function for printing out every damage flag that is turned on. Helpful when debugging.
|
|
15
|
-
*/
|
|
13
|
+
/** Helper function for printing out every damage flag that is turned on. Helpful when debugging. */
|
|
16
14
|
export declare function logAllDamageFlags(this: void, flags: int): void;
|
|
17
|
-
/**
|
|
18
|
-
* Helper function for printing out every entity flag that is turned on. Helpful when debugging.
|
|
19
|
-
*/
|
|
15
|
+
/** Helper function for printing out every entity flag that is turned on. Helpful when debugging. */
|
|
20
16
|
export declare function logAllEntityFlags(this: void, flags: int): void;
|
|
17
|
+
/** Helper function for printing out every flag that is turned on. Helpful when debugging. */
|
|
18
|
+
export declare function logAllFlags(this: void, flags: int, flagEnum: LuaTable, description?: string): void;
|
|
21
19
|
/**
|
|
22
|
-
* Helper function for printing out every flag that is turned on. Helpful when debugging.
|
|
20
|
+
* Helper function for printing out every game state flag that is turned on. Helpful when debugging.
|
|
23
21
|
*/
|
|
24
|
-
export declare function logAllFlags(this: void, flags: int, flagEnum: LuaTable, description?: string): void;
|
|
25
22
|
export declare function logAllGameStateFlags(this: void): void;
|
|
26
23
|
/**
|
|
27
24
|
* Helper function for printing out every projectile flag that is turned on. Helpful when debugging.
|
|
28
25
|
*/
|
|
29
26
|
export declare function logAllProjectileFlags(this: void, flags: int): void;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
*/
|
|
27
|
+
/** Helper function for printing out every use flag that is turned on. Helpful when debugging. */
|
|
28
|
+
export declare function logAllTearFlags(this: void, flags: int): void;
|
|
29
|
+
/** Helper function for printing out every use flag that is turned on. Helpful when debugging. */
|
|
33
30
|
export declare function logAllUseFlags(this: void, flags: int): void;
|
|
34
31
|
export declare function logArray<T>(this: void, array: T[]): void;
|
|
35
32
|
export declare function logColor(this: void, color: Color): void;
|
package/dist/functions/log.lua
CHANGED
|
@@ -68,6 +68,9 @@ end
|
|
|
68
68
|
function ____exports.logAllProjectileFlags(flags)
|
|
69
69
|
____exports.logAllFlags(flags, ProjectileFlags, "projectile")
|
|
70
70
|
end
|
|
71
|
+
function ____exports.logAllTearFlags(flags)
|
|
72
|
+
____exports.logAllFlags(flags, TearFlags, "tear")
|
|
73
|
+
end
|
|
71
74
|
function ____exports.logAllUseFlags(flags)
|
|
72
75
|
____exports.logAllFlags(flags, UseFlag, "use")
|
|
73
76
|
end
|
|
@@ -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
|
|
@@ -198,6 +155,22 @@ export declare function removeCollectibleCostume(player: EntityPlayer, collectib
|
|
|
198
155
|
*/
|
|
199
156
|
export declare function removeDeadEyeMultiplier(player: EntityPlayer): void;
|
|
200
157
|
export declare function removeTrinketCostume(player: EntityPlayer, trinketType: TrinketType | int): void;
|
|
158
|
+
/**
|
|
159
|
+
* Helper function to set an active collectible to a particular slot. This has different behavior
|
|
160
|
+
* than calling `player.AddCollectible()` with the `activeSlot` argument, because this function will
|
|
161
|
+
* not shift existing items into the Schoolbag and it handles `ActiveSlot.SLOT_POCKET2`.
|
|
162
|
+
*
|
|
163
|
+
* Note that if an item is set to `ActiveSlot.SLOT_POCKET2`, it will disappear after being used and
|
|
164
|
+
* will be automatically removed upon entering a new room.
|
|
165
|
+
*
|
|
166
|
+
* @param player The player to give the item to.
|
|
167
|
+
* @param collectibleType The collectible type of the item to give.
|
|
168
|
+
* @param activeSlot The slot to set.
|
|
169
|
+
* @param charge Optional. The argument of charges to set. If not specified, the item will be set
|
|
170
|
+
* with maximum charges.
|
|
171
|
+
* @param keepInPools Optional. Whether or not to remove the item from pools. False by default.
|
|
172
|
+
*/
|
|
173
|
+
export declare function setActiveItem(player: EntityPlayer, collectibleType: CollectibleType, activeSlot: ActiveSlot, charge?: int, keepInPools?: boolean): void;
|
|
201
174
|
/**
|
|
202
175
|
* If you want to stop the player from shooting without the blindfold costume, then simply call
|
|
203
176
|
* `player.TryRemoveNullCostume(NullItemID.ID_BLINDFOLD)` after invoking this function.
|
|
@@ -6,13 +6,15 @@ 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
|
|
12
|
+
local ____collectibles = require("functions.collectibles")
|
|
13
|
+
local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
|
|
14
14
|
local ____collectibleSet = require("functions.collectibleSet")
|
|
15
15
|
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
16
|
+
local ____util = require("functions.util")
|
|
17
|
+
local ensureAllCases = ____util.ensureAllCases
|
|
16
18
|
function ____exports.getPlayers(self, performExclusions)
|
|
17
19
|
if performExclusions == nil then
|
|
18
20
|
performExclusions = false
|
|
@@ -25,18 +27,18 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
25
27
|
do
|
|
26
28
|
local player = Isaac.GetPlayer(i)
|
|
27
29
|
if player == nil then
|
|
28
|
-
goto
|
|
30
|
+
goto __continue51
|
|
29
31
|
end
|
|
30
32
|
if ____exports.isChildPlayer(nil, player) then
|
|
31
|
-
goto
|
|
33
|
+
goto __continue51
|
|
32
34
|
end
|
|
33
35
|
local character = player:GetPlayerType()
|
|
34
36
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
35
|
-
goto
|
|
37
|
+
goto __continue51
|
|
36
38
|
end
|
|
37
39
|
__TS__ArrayPush(players, player)
|
|
38
40
|
end
|
|
39
|
-
::
|
|
41
|
+
::__continue51::
|
|
40
42
|
i = i + 1
|
|
41
43
|
end
|
|
42
44
|
end
|
|
@@ -206,24 +208,6 @@ function ____exports.getFinalPlayer(self)
|
|
|
206
208
|
local players = ____exports.getPlayers(nil)
|
|
207
209
|
return players[#players]
|
|
208
210
|
end
|
|
209
|
-
function ____exports.getOpenTrinketSlot(self, player)
|
|
210
|
-
local maxTrinkets = player:GetMaxTrinkets()
|
|
211
|
-
local trinket0 = player:GetTrinket(0)
|
|
212
|
-
local trinket1 = player:GetTrinket(1)
|
|
213
|
-
if maxTrinkets == 1 then
|
|
214
|
-
return ((trinket0 == TrinketType.TRINKET_NULL) and 0) or nil
|
|
215
|
-
end
|
|
216
|
-
if maxTrinkets == 2 then
|
|
217
|
-
if trinket0 == TrinketType.TRINKET_NULL then
|
|
218
|
-
return 0
|
|
219
|
-
end
|
|
220
|
-
return ((trinket1 == TrinketType.TRINKET_NULL) and 1) or nil
|
|
221
|
-
end
|
|
222
|
-
error(
|
|
223
|
-
"The player has an unknown number of trinket slots: " .. tostring(maxTrinkets)
|
|
224
|
-
)
|
|
225
|
-
return nil
|
|
226
|
-
end
|
|
227
211
|
function ____exports.getPlayerCloserThan(self, position, distance)
|
|
228
212
|
for ____, player in ipairs(
|
|
229
213
|
____exports.getPlayers(nil)
|
|
@@ -279,14 +263,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
279
263
|
do
|
|
280
264
|
local player = Isaac.GetPlayer(i)
|
|
281
265
|
if player == nil then
|
|
282
|
-
goto
|
|
266
|
+
goto __continue60
|
|
283
267
|
end
|
|
284
268
|
local playerHash = GetPtrHash(player)
|
|
285
269
|
if playerHash == playerToFindHash then
|
|
286
270
|
return i
|
|
287
271
|
end
|
|
288
272
|
end
|
|
289
|
-
::
|
|
273
|
+
::__continue60::
|
|
290
274
|
i = i + 1
|
|
291
275
|
end
|
|
292
276
|
end
|
|
@@ -299,43 +283,6 @@ function ____exports.getPlayerNumAllHearts(self, player)
|
|
|
299
283
|
local eternalHearts = player:GetEternalHearts()
|
|
300
284
|
return ((hearts + soulHearts) + boneHearts) + eternalHearts
|
|
301
285
|
end
|
|
302
|
-
function ____exports.getPocketItems(self, player)
|
|
303
|
-
local pocketItem = player:GetActiveItem(ActiveSlot.SLOT_POCKET)
|
|
304
|
-
local hasPocketItem = pocketItem ~= CollectibleType.COLLECTIBLE_NULL
|
|
305
|
-
local pocketItem2 = player:GetActiveItem(ActiveSlot.SLOT_POCKET2)
|
|
306
|
-
local hasPocketItem2 = pocketItem2 ~= CollectibleType.COLLECTIBLE_NULL
|
|
307
|
-
local maxPocketItems = player:GetMaxPocketItems()
|
|
308
|
-
local pocketItems = {}
|
|
309
|
-
local pocketItemIdentified = false
|
|
310
|
-
local pocketItem2Identified = false
|
|
311
|
-
do
|
|
312
|
-
local slot = 0
|
|
313
|
-
while slot < 4 do
|
|
314
|
-
local card = player:GetCard(slot)
|
|
315
|
-
local pill = player:GetPill(slot)
|
|
316
|
-
if card ~= Card.CARD_NULL then
|
|
317
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.CARD, id = card})
|
|
318
|
-
elseif pill ~= PillColor.PILL_NULL then
|
|
319
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.PILL, id = pill})
|
|
320
|
-
elseif (hasPocketItem and (not hasPocketItem2)) and (not pocketItemIdentified) then
|
|
321
|
-
pocketItemIdentified = true
|
|
322
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.ACTIVE_ITEM, id = pocketItem})
|
|
323
|
-
elseif ((not hasPocketItem) and hasPocketItem2) and (not pocketItem2Identified) then
|
|
324
|
-
pocketItem2Identified = true
|
|
325
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.DICE_BAG_DICE, id = pocketItem2})
|
|
326
|
-
elseif hasPocketItem and hasPocketItem2 then
|
|
327
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.UNDETERMINABLE, id = 0})
|
|
328
|
-
else
|
|
329
|
-
__TS__ArrayPush(pocketItems, {type = PocketItemType.EMPTY, id = 0})
|
|
330
|
-
end
|
|
331
|
-
if (slot + 1) == maxPocketItems then
|
|
332
|
-
break
|
|
333
|
-
end
|
|
334
|
-
slot = slot + 1
|
|
335
|
-
end
|
|
336
|
-
end
|
|
337
|
-
return pocketItems
|
|
338
|
-
end
|
|
339
286
|
function ____exports.getTotalCharge(self, player, activeSlot)
|
|
340
287
|
local activeCharge = player:GetActiveCharge(activeSlot)
|
|
341
288
|
local batteryCharge = player:GetBatteryCharge(activeSlot)
|
|
@@ -367,27 +314,6 @@ function ____exports.hasOpenActiveItemSlot(self, player)
|
|
|
367
314
|
end
|
|
368
315
|
return activeItemPrimary == CollectibleType.COLLECTIBLE_NULL
|
|
369
316
|
end
|
|
370
|
-
function ____exports.hasOpenPocketItemSlot(self, player)
|
|
371
|
-
local character = player:GetPlayerType()
|
|
372
|
-
if character == PlayerType.PLAYER_THESOUL_B then
|
|
373
|
-
return false
|
|
374
|
-
end
|
|
375
|
-
local pocketItems = ____exports.getPocketItems(nil, player)
|
|
376
|
-
for ____, pocketItem in ipairs(pocketItems) do
|
|
377
|
-
if pocketItem.type == PocketItemType.EMPTY then
|
|
378
|
-
return true
|
|
379
|
-
end
|
|
380
|
-
end
|
|
381
|
-
return false
|
|
382
|
-
end
|
|
383
|
-
function ____exports.hasOpenTrinketSlot(self, player)
|
|
384
|
-
local character = player:GetPlayerType()
|
|
385
|
-
if character == PlayerType.PLAYER_THESOUL_B then
|
|
386
|
-
return false
|
|
387
|
-
end
|
|
388
|
-
local openTrinketSlot = ____exports.getOpenTrinketSlot(nil, player)
|
|
389
|
-
return openTrinketSlot ~= nil
|
|
390
|
-
end
|
|
391
317
|
function ____exports.isBethany(self, player)
|
|
392
318
|
local character = player:GetPlayerType()
|
|
393
319
|
return (character == PlayerType.PLAYER_BETHANY) or (character == PlayerType.PLAYER_BETHANY_B)
|
|
@@ -436,6 +362,71 @@ function ____exports.removeTrinketCostume(self, player, trinketType)
|
|
|
436
362
|
end
|
|
437
363
|
player:RemoveCostume(itemConfigTrinket)
|
|
438
364
|
end
|
|
365
|
+
function ____exports.setActiveItem(self, player, collectibleType, activeSlot, charge, keepInPools)
|
|
366
|
+
if keepInPools == nil then
|
|
367
|
+
keepInPools = false
|
|
368
|
+
end
|
|
369
|
+
local game = Game()
|
|
370
|
+
local itemPool = game:GetItemPool()
|
|
371
|
+
local primaryCollectibleType = player:GetActiveItem(ActiveSlot.SLOT_PRIMARY)
|
|
372
|
+
local primaryCharge = player:GetActiveCharge(ActiveSlot.SLOT_PRIMARY)
|
|
373
|
+
local secondaryCollectibleType = player:GetActiveItem(ActiveSlot.SLOT_SECONDARY)
|
|
374
|
+
if charge == nil then
|
|
375
|
+
charge = getCollectibleMaxCharges(nil, collectibleType)
|
|
376
|
+
end
|
|
377
|
+
if not keepInPools then
|
|
378
|
+
itemPool:RemoveCollectible(collectibleType)
|
|
379
|
+
end
|
|
380
|
+
repeat
|
|
381
|
+
local ____switch87 = activeSlot
|
|
382
|
+
local ____cond87 = ____switch87 == ActiveSlot.SLOT_PRIMARY
|
|
383
|
+
if ____cond87 then
|
|
384
|
+
do
|
|
385
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
386
|
+
player:RemoveCollectible(primaryCollectibleType)
|
|
387
|
+
end
|
|
388
|
+
player:AddCollectible(collectibleType, charge, false)
|
|
389
|
+
break
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
____cond87 = ____cond87 or (____switch87 == ActiveSlot.SLOT_SECONDARY)
|
|
393
|
+
if ____cond87 then
|
|
394
|
+
do
|
|
395
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
396
|
+
player:RemoveCollectible(primaryCollectibleType)
|
|
397
|
+
end
|
|
398
|
+
if secondaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
399
|
+
player:RemoveCollectible(secondaryCollectibleType)
|
|
400
|
+
end
|
|
401
|
+
player:AddCollectible(secondaryCollectibleType, charge, false)
|
|
402
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
403
|
+
player:AddCollectible(primaryCollectibleType, primaryCharge, false)
|
|
404
|
+
end
|
|
405
|
+
break
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
____cond87 = ____cond87 or (____switch87 == ActiveSlot.SLOT_POCKET)
|
|
409
|
+
if ____cond87 then
|
|
410
|
+
do
|
|
411
|
+
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
412
|
+
player:SetActiveCharge(charge, activeSlot)
|
|
413
|
+
break
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
____cond87 = ____cond87 or (____switch87 == ActiveSlot.SLOT_POCKET2)
|
|
417
|
+
if ____cond87 then
|
|
418
|
+
do
|
|
419
|
+
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
420
|
+
break
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
do
|
|
424
|
+
do
|
|
425
|
+
ensureAllCases(nil, activeSlot)
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
until true
|
|
429
|
+
end
|
|
439
430
|
function ____exports.setBlindfold(self, player, enabled)
|
|
440
431
|
local game = Game()
|
|
441
432
|
local character = player:GetPlayerType()
|
|
@@ -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, slot = slot})
|
|
22
|
+
elseif pill ~= PillColor.PILL_NULL then
|
|
23
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.PILL, id = pill, slot = slot})
|
|
24
|
+
elseif (hasPocketItem and (not hasPocketItem2)) and (not pocketItemIdentified) then
|
|
25
|
+
pocketItemIdentified = true
|
|
26
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.ACTIVE_ITEM, id = pocketItem, slot = slot})
|
|
27
|
+
elseif ((not hasPocketItem) and hasPocketItem2) and (not pocketItem2Identified) then
|
|
28
|
+
pocketItem2Identified = true
|
|
29
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.DICE_BAG_DICE, id = pocketItem2, slot = slot})
|
|
30
|
+
elseif hasPocketItem and hasPocketItem2 then
|
|
31
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.UNDETERMINABLE, id = 0, slot = slot})
|
|
32
|
+
else
|
|
33
|
+
__TS__ArrayPush(pocketItems, {type = PocketItemType.EMPTY, id = 0, slot = slot})
|
|
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.487",
|
|
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",
|